Keil™, An ARM® Company

Technical Support

C51: ADDRESS SPACE OVERFLOW WITH FAR CONST


Information in this article applies to:

  • C51 Version 7
  • CX51 Version 7

QUESTION

I need many constants in my project and for this reason I initialize them as follows (This is just and example, the real initialization is a lot more complex and longer):

const char far * text1[]= "Text1";
const char far * text2[]= "Text2";

However, it appears that these constants are still in the CODE space. During linkage I get the following error:

*** ERROR L107: ADDRESS SPACE OVERFLOW
    SPACE:   CODE
    SEGMENT: ?CO?MAIN

How can I put the constants into the 'const far' memory type?

ANSWER

There are two solutions to this problem. The STRING compiler directive locates strings into various memory classes. At the beginning of your source file, specify:

#pragma STRING (far)   // locate string constants into 'far const' memory

You may define the explicit memory type of the constants by using another variable as shown below:

const char far       text1a[]= "Text1";
const char far       text2a[]= "Text2";
const char far * far text1[]= text1a;
const char far * far text2[]= text2a;

You may also look to the example ConstFar in the folder Keil\c51\Examples\FarMemory\1MB Constants on Classic 8051. This shows you some techniques that might be useful for you.

MORE INFORMATION

  • Refer to STRING in the Cx51 User's Guide.

SEE ALSO

Last Reviewed: Friday, July 15, 2005


Did this article provide the answer you needed?
 
Yes
No
Not Sure