| Details | Message |
|---|
Read-Only Author olivma ma Posted 19-Dec-2002 01:06 GMT Toolset C51 |  turn off the optimizer olivma ma 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? |
|
Read-Only Author Andrew Neil Posted 19-Dec-2002 09:11 GMT Toolset C51 |  RE: turn off the optimizer Andrew Neil "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?"
|
|
Read-Only Author olivma ma Posted 19-Dec-2002 18:07 GMT Toolset C51 |  RE: turn off the optimizer olivma ma 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. |
|
Read-Only Author Jon Ward Posted 19-Dec-2002 18:13 GMT Toolset C51 |  RE: turn off the optimizer Jon Ward How can I make sure it?
Look in the listing file.
Jon
|
|
Read-Only Author Andrew Neil Posted 20-Dec-2002 09:21 GMT Toolset C51 |  RE: turn off the optimizer Andrew Neil "Look in the listing file."
Or, in the debugger, check the disassembly listing.
|
|
Read-Only Author olivma ma Posted 20-Dec-2002 18:06 GMT Toolset C51 |  RE: turn off the optimizer olivma ma 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? |
|
Read-Only Author Andrew Neil Posted 20-Dec-2002 20:36 GMT Toolset C51 |  RE: turn off the optimizer Andrew Neil 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! |
|
Read-Only Author olivma ma Posted 20-Dec-2002 21:43 GMT Toolset C51 |  RE: turn off the optimizer olivma ma I got it. Thanks, Andrew. |
|