How to assign initial values in code memory with specific location?

I want to define some values in code memory with specific location. For example

code unsigned char MyArray[] _at_ 0xF000 = {0x01, 0x02};


After that, I can use "MyArray[0]" and "MyArray[1]" to access the memory at 0xF000 and 0xF001.
How can I achieve this?

  • I normally store version and copyright information at a fixed location in the ROM image - And always do it by using an assembler module.

    For example:

    ;Within assembly file
    
             Public MyArray
    
             Cseg At 0F000h
    
    MyArray:
             Db   01h,02h
    
    
    ;Within C file
    extern char code MyArray[];
    ...
      Val = MyArray[1];
    ...
    

    I may have a few minor semantics wrong here (because I'm doing it from memory), but I hope it shows the basics.

More questions in this forum