我想知道当程序从中断服务程序返回时程序计数器在哪里?我知道发生中断事件时,会将PC推入堆栈.但是,下一个或同一个地址(刚刚执行过一个)将什么地址推入堆栈?当我们拥有
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 stack. But what address is pushed into the stack the next one or the same one(just executed one)?When we have
first instruction; interrupt event here; go inside the ISR; exit ISR; second instruction;OR
first instruction; interrupt event here; go inside the ISR exit ISR; first instruction;我的意思是,PC是否指向在ISR进入之前执行的指令,还是转到下一条指令(从ISR返回之后)? 我希望你能明白.
I mean, does the PC points to the instruction executed prior to the ISR entrance, or it goes to the next instruction(after return from the ISR)? I hope you get the idea.
推荐答案由于在CPU处于精确的固定状态之前无法处理中断,因此如果在指令中间引发了中断,则跳转至指令执行后,将执行中断向量程序.
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.
因此,当从中断过程返回时,PC将在第一个指令之后指向该指令.
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 ...更多推荐
返回中断处理程序后,程序计数器在哪里?
发布评论