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

How to make make MDK generate disassembly using "bx lr"?

The subroutine(C source code) is the same, but when compiled:

The DEMO's disassembly:

    PUSH {r4-r7}
    ...
    ...
    ...
    POP {r4-r7}
    BX  lr

My project's disassembly:

    PUSH {r4, lr}
    ...
    ...
    ...
    POP {r4, pc}

The situation is I clean all the RAM during the subroutine to 0. So after "POP {r4, pc}", the program is crashed.
I don't konw assembly language very well. So what could I do to make the ARMCC generate disassembly code using "BX lr" to make my code work?
I'm using STM32F103/MDK5/ARMCC5.06.

Parents
  • Thanks for your replay (Westonsupermare Pier & Per Westermark)

    The whole process is:
    Power_on --> Reset_handler -> Selftest -> main

    1. The Reset handler is assembler file.
    2. The selftest is C file, including CPU/FLASH/RAM selftest which is called from separate files.
    3. The RAM selftest file is C file which is just 6 <for loops> inside, and do not call any other subroutine.

    1. When call RAM selftest subroutine, the compiler generate "BL.W" to write the return address into LR which it's supposed to do and it's right.
    2. It doesn't make any sense that the compiler generate "PUSH LR" stuff for me. Because I don't call any subroutines in the RAM selftest.
    2. After the RAM test is done, it's supposed to generate "BX LR"(in the demo) other than "POP R4, PC" to return.

    If I can't make something outside the source code to make the ARMCC generate "BX LR" for me, I'll have to do it manually using assembler.

    Thanks for your help again.
    And I'm trying rewrite the RAM selftest file using assembly language. Hope it words.

Reply
  • Thanks for your replay (Westonsupermare Pier & Per Westermark)

    The whole process is:
    Power_on --> Reset_handler -> Selftest -> main

    1. The Reset handler is assembler file.
    2. The selftest is C file, including CPU/FLASH/RAM selftest which is called from separate files.
    3. The RAM selftest file is C file which is just 6 <for loops> inside, and do not call any other subroutine.

    1. When call RAM selftest subroutine, the compiler generate "BL.W" to write the return address into LR which it's supposed to do and it's right.
    2. It doesn't make any sense that the compiler generate "PUSH LR" stuff for me. Because I don't call any subroutines in the RAM selftest.
    2. After the RAM test is done, it's supposed to generate "BX LR"(in the demo) other than "POP R4, PC" to return.

    If I can't make something outside the source code to make the ARMCC generate "BX LR" for me, I'll have to do it manually using assembler.

    Thanks for your help again.
    And I'm trying rewrite the RAM selftest file using assembly language. Hope it words.

Children