This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

How to position code via SEGMENTS directive

I am using Keil C51 toolset with C51 COMPILER V9.53.0.0 and LX51 LINKER/LOCATER V4.66.30.0
and a device with a 64K code space.

I am using the SEGMENTS directive

SEGMENTS (?PR?*?btldr( C:0xE000 ))

To position all of the code in the "btldr.c" module in a segment starting at 0xE000. I can
get that working, and see in the .COD file that it is indeed there.

I then add a single function to btldr.c

void test( void )
{ val++
}

and recompile. It is no longer positioned at 0xE000. It is NOT an issue that there is
not enough room in the segment. I can change it to 0xD000 and it still is not positioned
there.

Can someone explain why this might be happening ?

Thank you

  • I believe I may have accomplished my goal. I used the Userclass directive at the
    top of btldr.c,

    #pragma userclass (code = IAP)

    And then the CLASSES directive in invoking the LX51 linker

    CLASSES( CODE_IAP (C:0xE000 - C:0xFF00 ))

    In looking at the listing output it appears this is what I wanted.

    I am still curious as to why my initial attempt failed the way it did.

    Thank you.