当前位置:网站首页>CPU的异常处理
CPU的异常处理
2022-06-26 23:52:00 【拉普拉强】
概述
什么是异常?正常流程之外的流程都叫做异常,中断是异常的一种。
现场保护:中断发生的时候,CPU需要记录当前程序的上下文,然后再去处理异常,以便异常处理完成后,返回到原先的程序当中去。
硬中断和软中断
硬中断就是硬件产生的中断,软中断是一条会汇编指令,只要一执行,就会产生软中断。
异常向量表
所有CPU都有异常向量表,用于处理异常,是硬件决定的。详细来说,出现异常时,CPU转跳到异常处理表,这个行为是硬件决定的,至于异常向量表里面具体的实现动作,是软件定义的。
异常发生的时候,CPU自动把PC寄存器转跳到异常向量处理处理异常。

如图所示,异常向量表是一个这样的数据结构:不同的异常连续地存放在地址空间中,每个异常对应的向量内容是一个32位的地址,异常发生的时候,CPU将PC寄存器的内容设置成向量指向的地址,CPU进而会去执行地址指向的程序。
ARM的异常处理流程
- 将CPSR拷贝到当前模式地SPSR中,以便异常处理后,程序状态寄存器的恢复
- 修改CPSR上的标志位,使CPU进入ARM模式,因为Thumb模式不支持异常的处理
- 设置中断禁止位,禁止相应的中断(可选)
- 保存返回地址到LR寄存器中,以便异常处理后,能够接着上次的位置执行程序
- 设置PC程序寄存器,为响应的异常向量
- 执行异常处理函数
- 从SPSR恢复CPSR
- 从LR寄存器恢复PC
- 继续运行上一次的程序
边栏推荐
- 【leetcode】275. H index II
- Big guys talk about the experience sharing of the operation of the cutting-edge mindspore open source community. Come up with a small notebook!
- go语言的爬虫和中间件
- [microservice]eureka
- 12色彩环三原色
- 當Transformer遇見偏微分方程求解
- Where is it safer to open an account to buy funds
- Understanding of "the eigenvectors corresponding to different eigenvalues cannot be orthogonalized"
- Super hard core! Can the family photo album on Huawei's smart screen be classified automatically and accurately?
- 国产框架MindSpore联合山水自然保护中心,寻找、保护「中华水塔」中的宝藏生命
猜你喜欢

如何通俗易懂的描述机器学习的流程?
![[微服務]認識微服務](/img/62/e826e692e7fd6e6e8dab2baa4dd170.png)
[微服務]認識微服務
![[vscode] setting sync, a plug-in for synchronizing extensions and settings](/img/e0/4889b59105e9815d11ae31988f58f2.jpg)
[vscode] setting sync, a plug-in for synchronizing extensions and settings

Microservices and container choreography in go

My advanced learning notes of C language ----- keywords

运用物理信息神经网络求解流体力学方程

kubernetes可视化界面dashboard

深度学习方法求解平均场博弈论问题

为什么EDR需要深度防御来打击勒索软件?

剑指 Offer 10- II. 青蛙跳台阶问题
随机推荐
CVE-2022-30190 Follina Office RCE分析【附自定义word模板POC】
能在手机上开户炒股吗 网上开户炒股安全吗
Mindspire, a domestic framework, cooperates with Shanshui nature conservation center to find and protect the treasure life in the "China water tower"
The user adds a timer function in the handler () goroutine. If it times out, it will be kicked out
How to use Pinia (I) introduce Pinia into the project
Using physical information neural network to solve hydrodynamics equations
Cve-2022-30190 follina office rce analysis [attached with customized word template POC]
[UVM actual battle== > episode_3] ~ assertion, sequence, property
My advanced learning notes of C language ----- keywords
Is it safe to open a compass account?
12色彩环三原色
Deep learning method for solving mean field game theory problems
Where is it safer to open an account to buy funds
[微服務]認識微服務
matlab数据类型 —— 字符型
技术干货|什么是大模型?超大模型?Foundation Model?
股票怎样在手机上开户安全吗 网上开户炒股安全吗
利用burp精准定位攻击者
Serial port debugging tool mobaxtermdownload
“message“:“Bad capabilities. Specify either app or appTopLevelWindow to create a session“