Where the program counter goes after returning the interrupt handler?

前端 未结 4 1076
名媛妹妹
名媛妹妹 2020-12-18 11:59

Hi I am wondering where the program counter goes when the program returns from interrupt service routine? I know when the interrupt event occurs the PC is pushed into the st

4条回答
  •  生来不讨喜
    2020-12-18 12:25

    Since an interrupt can't be handled until the CPU is in a precise fixed state, if the interrupt is raised in the middle of an instruction then the jump to the interrupt vector procedure will occur after the execution of the instruction.

    So when coming back from the interrupt procedure the PC will be pointing to the instruction after the first.

    first instruction fetch (PC is updated meanwhile)
    first instruction decode
    interrupt is raised
    first instruction execution
    ** now and only now the CPU checks for a possible interrupt **
    interrupt is present, pushing PC on stack and other things
    jump to interrupt address
    execution of interrupt
    return from interrupt (pop of PC and other things)
    second instruction fetch 
    ...
    

提交回复
热议问题