Keil Logo

C51: Changing the order of obj-files crashes Program

Information in this article applies to:

  • C51 All Versions


I have a problem that causes a routine not to work, but only at a particular CODE location.

If I move the routine to a different CODE area it will work, move it back and it stops. What's going on?


There are a few things that you should check.

  1. Make sure that the startup files are the last files in the link list. The startup code (STARTUP.A51) and the initialization code (INIT.A51) must be the last 2 files in the link list.
  2. Make sure that any RTX configuration files are at the end of the link list.
  3. Make sure that you don't have assembly modules (or C modules) that use ACALL and AJMP instructions that also cross over a 2K-page boundary. There are 2 types of JMP and CALL instructions in the 8051: LCALL/LJMP and ACALL/AJMP. If you have a program that exhibits weird behavior just by moving files around, it might be that you have a module that's compiled for ROM(SMALL) or ROM(COMPACT) that winds up straddling a 2K page. If that's the case, the AJMP or ACALL will wind up jumping to the wrong page (2K before the intended destination). This may be due to an assembly file or a library routine.

There is a bug in the log and pow floating-point routines in the C51 Version 5.10 library that may cause this problem. The Version 5.11 library update corrects this problem and is available on the Keil web site at:


Last Reviewed: Thursday, February 25, 2021

Did this article provide the answer you needed?
Not Sure
  Arm logo
Important information

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.

Change Settings

Privacy Policy Update

Arm’s Privacy Policy has been updated. By continuing to use our site, you consent to Arm’s Privacy Policy. Please review our Privacy Policy to learn more about our collection, use and transfers
of your data.