Why does the value of R13 decrease by 4 for each register that is POPped, but the value
of R15 increase by 4 at the end of the execution of the POP instruction in our ARM
microcontroller?
R13 is stack pointer and R15 is program counter. R13, stack pointer points to last occupied stack address. After ecxecution of POP, the contents which are saved in stack beacuase of Pushing have to be restored. Usually 5 contents r0,r1,r2,r3,r4,r5 are pushed in stack and in the process stack point is increased by 5 and they have to be restored on popping. Hence, current stack pointer should be decreased by 4 to get the pushed contents.
On executing POP instruction after restoring contents, program control has to be transfered to the next instruction, Hence program counter R15 gets increased by 4.
Get Answers For Free
Most questions answered within 1 hours.