6

I was just disassembling and debugging an ARM binary for fun and I noticed something unusual. Consider the following set of instructions:-

   0x00008058 <+4>: mov r1, pc
   0x0000805c <+8>: add r1, r1, #24
   0x00008060 <+12>:    mov r0, #1

I tried setting a breakpoint at 0x0000805c and checked the value of the register r1. I was expecting to see 0x0000805c -- however, interestingly the value is 0x8060.

Why is this? Is this because of some sort of instruction pipelineing?

9

Yes, it's because of pipelining.

From http://winarm.scienceprog.com/arm-mcu-types/how-does-arm7-pipelining-works.html --

ARM pipelining

PC (Program Counter) is calculated 8 bytes ahead of current instruction.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy