返回中断处理程序后,程序计数器在哪里?

编程入门 行业动态 更新时间:2024-10-28 14:26:31
本文介绍了返回中断处理程序后,程序计数器在哪里?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我想知道当程序从中断服务程序返回时程序计数器在哪里?我知道发生中断事件时,会将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 ...

更多推荐

返回中断处理程序后,程序计数器在哪里?

本文发布于:2023-11-05 04:30:06,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1559907.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:程序   计数器

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!