当前位置:网站首页>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
- 继续运行上一次的程序
边栏推荐
- 这3个并发编程的核心,竟然还有人不知道?
- 利用burp精准定位攻击者
- Can I open an account for stock trading on my mobile phone? Is it safe to open an account for stock trading on the Internet
- Pinpoint attackers with burp
- In the Internet industry, there are many certificates with high gold content. How many do you have?
- 国产框架MindSpore联合山水自然保护中心,寻找、保护「中华水塔」中的宝藏生命
- 代码之外:写作是倒逼成长的最佳方式
- 入侵痕迹清理
- The fourth bullet of redis interview eight part essay (end)
- com. fasterxml. jackson. databind. exc.MismatchedInputException: Expected array or string. at [Source:x
猜你喜欢

利用burp精准定位攻击者

Nacos installation guide

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

Common techniques of email attachment phishing

When transformer encounters partial differential equation solution

PHP code audit series (I) basis: methods, ideas and processes

Using physical information neural network to solve hydrodynamics equations

当Transformer遇见偏微分方程求解

The fourth bullet of redis interview eight part essay (end)

剑指 Offer 10- II. 青蛙跳台阶问题
随机推荐
[microservices] Understanding microservices
深度学习方法求解平均场博弈论问题
Why does EDR need defense in depth to combat ransomware?
Alibaba cloud server purchase, basic configuration, (xshell) remote connection and environment building
Analysis on the advantages and disadvantages of the best 12 project management systems at home and abroad
Leetcode skimming 4 Find the median of two positive arrays
Implement the queue through two stacks
Would you like to buy stocks? Where do you open an account in a securities company? The Commission is lower and safer
Cvpr2022 stereo matching of asymmetric resolution images
巧记大小端字节序
Can I open an account for stock trading on my mobile phone? Is it safe to open an account for stock trading on the Internet
【Vscode】预览md文件
万字详解-MindArmour 小白教程!
On cap theorem in distributed system development technology
在线上买养老年金险正规安全吗?有没有保单?
當Transformer遇見偏微分方程求解
Is it safe to open an account and speculate in stocks on the mobile phone? Is it safe to open an account and speculate in stocks on the Internet
When transformer encounters partial differential equation solution
安利!如何提优质的ISSUE?学霸是这样写的!
手机炒股靠谱吗 网上开户炒股安全吗