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

how pc is updated during execution of SWI and any simple instruction like mov R1,R15?

when swi instruction is executed at that time it is said that pc is not updated yet so it is pointing to instruction next to swi instruction for example

addr         code

0x0000     swi 100
0x0004    mov r1,r2
0x0008    mov r2,r3


so in this code when swi instruction is being executed at that time value of PC is 0x0004 so that value will be copied to R14_SVC while going to swi handler.means value in PC in not address of instruction being executed +8 but +4 as can be seen.

but when following code is run i.e

addr        code

0x0000   mov R1,R15
0x0004   mov r2,r1
0x0008   mov r4,r5

so when first instruction is being executed means value of R15 goes to R1 that is 0x0008 so how pc is updated in this case means pc pointing to instruction being executed + 8 instead of +4.

why so?