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

Prevent to generate "BX LR"

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"?

Parents
  • 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.

Reply
  • 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.

Children