When does an ARM7 processor increase its PC register?

Posted by Summer_More_More_Tea on Stack Overflow See other posts from Stack Overflow or by Summer_More_More_Tea
Published on 2010-04-15T11:35:25Z Indexed on 2010/04/15 12:53 UTC
Read the original article Hit count: 304

Hi everyone:

I'm thinking about this question for a time: when does an ARM7(with 3 pipelines) processor increase its PC register.

I originally thought that after an instruction has been executed, the processor first check is there any exception in the last execution, then increase PC by 2 or 4 depending on current state. If an exception occur, ARM7 will change its running mode, store PC in the LR of current mode and begin to process current exception without modifying the PC register.

But it make no sense when analyzing returning instructions. I can not work out why PC will be assigned LR when returning from an undefined-instruction-exception while LR-4 from prefetch-abort-exception, don't both of these exceptions happened at the decoding state? What's more, according to my textbook, PC will always be assigned LR-4 when returning from prefetch-abort-exception no matter what state the processor is(ARM or Thumb) before exception occurs. However, I think PC should be assigned LR-2 if the original state is Thumb, since a Thumb-instruction is 2 bytes long instead of 4 bytes which an ARM-instruction holds, and we just wanna roll-back an instruction in current state. Is there any flaws in my reasoning or something wrong with the textbook.

Seems a long question. I really hope anyone can help me get the right answer.

Thanks in advance.

© Stack Overflow or respective owner

Related posts about arm

Related posts about computer-architecture