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

Why does this piece of assembly not work?

Hello all,

Can you tell mw why this piece of code:

LDMDB   R13, {R0 - LR}^
NOP
MOVS    PC, LR // hand over control to task

does not update registers R13 and R14 (but does update R0 - R12)? The write back operator (!) is indeed not present (i.e.

LDMDB R13!...

but this does not compile) which may explain R13, but why isn't then R14 being updated? Even if I try to separately extract R13, R14 from by buffer (pointed by R13) it does not work. Any ideas?

Parents
  • LDMDB R13, {R0 - LR}^

    The optional ^ symbol at the end of a load multiple instruction indicates the special form of this instruction which restores the CPSR from the SPSR.

    This instruction is switching mode, therefore a different R13 and R14 are visible.

    This is similar in operation to MOVS PC, LR which also restores the CPSR from the SPSR. You need one or the other, not both.

Reply
  • LDMDB R13, {R0 - LR}^

    The optional ^ symbol at the end of a load multiple instruction indicates the special form of this instruction which restores the CPSR from the SPSR.

    This instruction is switching mode, therefore a different R13 and R14 are visible.

    This is similar in operation to MOVS PC, LR which also restores the CPSR from the SPSR. You need one or the other, not both.

Children