I have two subroutines with exactly same content but different names. I want them to be located in different addresses. I don't want the two subroutines to share same code, and I set the optimizer to "0". But still one of the subroutines is not working. How can I turn off the optimizer?
"I set the optimizer to "0". But still one of the subroutines is not working." Did you remember to do a full rebuild? Did this achieve your goal of having the two functions located in different addresses? What do you mean by "not working?"
I have 2 subroutines A and B with same content but different names. I relocated the subroutine B to 0xE000, so that when subroutine B is called, there is no instruction execution below memory address 0xE000, because subroutine B will program some data bytes into flash memory below 0xE000. In the .M51 file, I see that subroutine B is reloacated, but I am not sure if the compiler has optimized subroutine B and replace the content with a call back to subroutine A. How can I make sure it? Thank you for your kind support.
How can I make sure it? Look in the listing file. Jon
"Look in the listing file." Or, in the debugger, check the disassembly listing.
Thanks for the suggestion. I looked through the de-assembly window in the debugger and found the cause of the problem. Both my subroutine A and B have if(...)command, and the if(...) is replaced by a subroutine C?ULCMP which is located in address 0x0123. When subroutine B is called, it will also execute C?ULCMP in 0x0123 for the if(...). But my intention is to locate subroutine B to address above 0xF000, so that when it is called, no execution will take place in code memory address below 0xF000. How to prevent the compiler from extracting some general subroutines to share by the user written subroutines?
That'll be a library routine - see: http://www.keil.com/support/docs/1965.htm You might have to write your own compare routine for longs? Remember that the 8051 is only an 8-bit processor, so the instruction set has no built-in support for any operation involving anything larger than a single byte!
I got it. Thanks, Andrew.