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

Replacing branch-instruction with address assignment to PC

Hi,

in a thumb-assembly file (my toolchain is gcc 4.8), I want to replace a branch with address assignment to the program-counter.
So instead of:

b   lbl

I want to have something like:

pc = address(lbl)


This solution works. Here, I use the following code to store the address of a label in a register (here r12) and assign this to the pc.

But when I, as shown below, use the stack to restore the value of r12 the execution crashes:

If I, as you can see below, first store the address from the stack in the r12 and then move it to pc the code runs without any problem.

 

any ideas what could be the reason why in pop {pc} (in the second code-segment) doesn't work?

PS. The code is being executed on a Cortex-M4F

0