|
|||||||||||
Technical Support Support Resources
Product Information |
C51: Avoiding MOVC Fetches from Code SpaceInformation in this article applies to:
QUESTIONWe have a special chip that is based on the Mentor 8051EW core. The memory configuration of this device allows downloading to RAM in some particular areas, but blocks the execution of the MOVC instruction in the same memory area for security reasons. It appears that the Keil C51 Compiler embeds tables into the program code and requires the MOVC instruction (which is blocked). Is there a way to locate constant tables to a different memory area? ANSWERThe compiler embeds constant tables into program code to improve performance of code constructs like case statements. The constants are handled using the library functions ?C?xCASE and ?C?LSTKxxxx. So, if your MAP file lists these library routines, you likely have constant tables embedded in your program's code space. Case Statements Case statements are implemented using several different strategies. One is to store the case information in a jump table in code space. In such a situation, the ?C?xCASE library routine handles the switch-case statement. You can avoid this type of constant table in one of several ways:
?C?LSTKxxxx Function Calls To remove calls to the ?C?LSTKxxxx function, enable Project - Options for Target - 'far' memory type support (which sets the VARBANKING compiler directive). Project Configuration To solve this issue, you must configure your project using a special code banking configuration. The LX51 Linker/Locater provides support for the Mentor 8051EW memory extensions. So you may configure your system with just one code bank using the L51IBANK.A51 file and the example provided in \KEIL\C51\EXAMPLES\M8051EW\L51IBANK. This code banking example allows you to define a Memory Bank for constants (so constant tables are not mixed in with program code). MORE INFORMATION
SEE ALSOLast Reviewed: Thursday, February 25, 2021 | ||||||||||
|
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.