I have spent a lot of time on this. Here is my observation: I am porting a piece of GNU code to the MCB2130 card using the Keil toolset (including the limited compiler that comes with the board). I have a function call: handle = function1(a, b, c, d); handle is unsigned char. function1 has a number of different return codes. When I look at the generated code for one specific return code, I see the following: 923: return (-20); 00000024 4800 LDR R0,=0xFFFFFFEC 00000026 E0EC B L_204 ; T=0x00000202 924: } So far so good.... but when I get to label L_204, I see the following: 0000022A L_204: 0000022A 4886 LDR R0,=0x218 0000022C 4485 ADD R13,R13,R0 0000022E B001 ADD R13,#0x4 00000230 BC08 POP {R3} 00000232 4718 BX R3 00000234 ENDP ; Obviously, the first thing that this code does is to overwitre the return code. My handle is assigned a wrong value. I found out that if I remove some code inside function1, especially a call to another function, the L_204 code does not overwrite the return code (obvisouly function1 is now broken). I am going to try the GNU compiler. Any idea ?
This problem (obviously) does not exist with the GNU compiler. The exact same source now behave correctly. The generated code is roughly twice bigger (but I am told that most of the increase comes with the use of printf in GNU, not verified).
I found out that if I remove some code inside function1, especially a call to another function, the L_204 code does not overwrite the return code (obvisouly function1 is now broken). ... Any idea ? Yes. Please contact our technical support department and report this problem so that we can get it fixed in the next compiler release. Jon
Looks like you are using an outdated version of the CA compiler. A problem similar to yours has been fixed in February. Please try again with a current version.
How do I get the update ? I have the evaluation version of the compiler that I received with the MCB2130 board (needless to say my evaluation is not going well !). The "get update" page requires a license.
Just read the instructions in the eval package. It will tell you that you can download the lastest eval code from this web site. You will need to fill out a contact sheet, but thats all that you will need. ADB
Here's the link: http://www.keil.com/demo/eval/arm.htm Jon
Thanks this helps. Problem is fixed in the new version.