Dear All How can I force the compiler to not generate the "BX LR" for the return function. I also set the option --ARM_only(in compiler + assembler + linker) but this is not useful and I have this code at last in axf file. my target in Keil is set to ARM7TDMI (I can not set my target to ARM7 or any other target without Thumb) so what can we do to prevent generate "BX LR"?
while (1)...?
I do not understand your reply!
void foo(void) { while(1) ; }
I love this one more, though:
void foo(void) { foo() ; }
;-)
Thanks but I want to solve it with the compiler options and not delete the return from the code!
"but I want to solve it with the compiler options and not delete the return from the code!"
Why? Either way you must rebuild the code.
I don't think you can suppressed the generation of BX LR. Are you seriously suggesting that the compiler does not generate that instruction even if the programmer inserted a "return" at the end of the function, only because of a compiler switch?
What are you looking to have instead of the BX LR ?
Wrong view.
A function either return or it doesn't return.
A compiler switch will not help you with that.
If you write code that never returns, then the compiler optimizer _may_ decide to skip any return code. Just as a function that ends with a call to another function normally have the return code removed and the call converted to a jump.
Anyway - you either program in C/C++. Or you program in assembler. Directly when _you_ think that the generated assembler must look a certain way, _you_ have to switch to writing that assembler yourself. The goal with C/C++ is that the programmer should not be in control of generated machine code instructions.
Ok, we can have "MOV PC,LR" instead of "BX LD" or we can have "BL" , I want to have pure ARM instructions not ARM/Thumb instructions.
The goal with C/C++ is that the programmer should not be in control of generated machine code instructions.
I do not mean to change the compiler or rewrite it!!, I only want to know how we can prevent the compiler to generate a ARM/Thumb code when we want it to produce the code for ARM_only target! return or not-return from a function is not my concern at all. I only want to tell the compiler not to generate the BX command. this is all the story!
"this is all the story!"
Why did you not say so from the beginning, them?! I am not sure you can do what you wish for.
I am not sure you can do what you wish for
why not? The BX is not ARM_only instruction so the compiler must not generate it when in ARM_only mode??!!
Check this out:
newsgroups.derkeiler.com/.../msg00031.html
There is likely to be plenty more if you were to consider looking!
Thanks, but how can I tell the linker to substitute the "BX LR" with "MOV PC,LR" ?