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 use 'userclass' to control code placement ?

I am using

C51 COMPILER V9.53.0.0
LX51 LINKER/LOCATER V4.66.30.0

and trying to use the "#pragma userclass" command within c51 source files, and the CLASSES linker command
to position various blocks of code.

At the top of one particular source file I have

#pragma userclass (code = D_BOOT)

At the top of a few other source files I have

#pragma userclass (code = MY_GO)

and then I use a linker command

CLASSES(CODE_D_BOOT(C:0x0-C:0x7FF),CODE_MY_GO(C:0x800-C:0xF9FF),CODE(C:0x800-C:0xF9FF))

I am using the OMF2 compiler command as well.

My hope was that ALL code from the source file with "D_BOOT" would be located from 0-0x7FF, all
my other code would be located between 0x800 - 0xF9FF, and then all library code would be located
between 0x800 - 0xF9FF.

I end up with several calls, from code between 0 - 0x7FF, to functions around 0x0900.

I can see from disassembly that those functions at ~0x0900 are manipulating the DPTR register, and
that there are many calls to them through my code.

It would appear this is the result of optimization, taking precedence over my use of the userclass
command.

How can I ensure that all code from my one source module is located between 0 - 0x7FF and NOT
make any calls outside of this range ?

I would welcome any advice and thank you in advance.