ARM Technical Support Knowledge Articles

USE SPECIFIC ADDRESS RANGE FOR MOVC

Applies to: C51 C Compiler

Answer


Information in this article applies to:


QUESTION

I need to use an 8051 device variant where the MOVC instruction is broken.

MOVC A,@A+DPTR can only access constants in an certain address space (C:0xA000 - C:0xAFFF). Access to other memory regions fails. It is not possible to use the instruction MOVC A,@A+PC at all.

I know that the C51 Compiler uses MOVC instructions a lot. Is there a way to configure the Keil C51 Compiler, so that above restrictions can be achived?

ANSWER

When you avoid certain constructs in the C source code it is possible to minimize the MOVC instructions. In addition all constants need to be located to the specific address memory.

Configure Compiler and Linker/Locater:

The following explains the configuration settings for uVision, the C51 Compiler and the LX51 Linker/Locater that are required to avoid MOVC instructions.

With the settings described above all constant segments are already located to address space C:0xA000-c:0xAFFF. In addition you need to check your program code for the following issues:

Check for ?C?CCASE, ?C?ICASE, or ?C?LCASE Library Calls:

The C51 Compiler may embed DB and DW constants into the program code segment. Use the Compiler Code Listing file to check whether the code generated uses ?C?CCASE, ?C?ICASE, or ?C?LCASE library calls . If the compiler uses one of these library calls, you need to break the switch/case statements apart into several switch/case constructs (each less than 7 case statements). Refer to C51: SWITCH/CASE STATEMENTS for more information.

Do Not Use bit Initalizations at File Level:

Example:

bit b=1;

void func (void)  {
   ...
}

These sequences require execution of MOVC A,@A+PC instruction in INIT.A51. Instead move the bit initialization to beginning of main.

Avoid the following function calls

The C51 Run-Time Library has several routines that have DB/DW statements embedded in the libary code. Therefore, you need to avoid the following function calls in your application program.

Generate Linker *.COD File and Check for DB/DW Statements

The following settings enable a linker code listing file (extension *.COD) that might help you to analyze the compiler output for DB and DW statements that are embedded in the code.

Using the above methods almost 100% ensures that the generated code is safe and does not contain any hidden DB/DW statements. In this way you can work with the broken 8051 device until you receive the final silicon version.

SEE ALSO

Article last edited on: 2005-01-11 17:36:58

Rate this article

[Bad]
|
|
[Good]
Disagree? Move your mouse over the bar and click

Did you find this article helpful? Yes No

How can we improve this article?

Link to this article
Copyright © 2011 ARM Limited. All rights reserved. External (Open), Non-Confidential