当前位置:网站首页>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
- 继续运行上一次的程序
边栏推荐
- CVE-2022-30190 Follina Office RCE分析【附自定义word模板POC】
- Simulation of delta variant strain of novel coronavirus (mindsponge application)
- [microservice]eureka
- Cvpr2022 stereo matching of asymmetric resolution images
- 超硬核!华为智慧屏上的家庭相册竟可以自动精准分类?
- Leetcode skimming 4 Find the median of two positive arrays
- 安利!如何提优质的ISSUE?学霸是这样写的!
- Is it safe to buy pension insurance online? Is there a policy?
- Leetcode 718. Longest repeating subarray (violence enumeration, to be solved)
- 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
猜你喜欢

On cap theorem in distributed system development technology

Technical dry goods | top speed, top intelligence and minimalist mindspore Lite: help Huawei watch become more intelligent

50 tips that unity beginners can definitely use

Safe and cost-effective payment in Thailand

国内外最好的12款项目管理系统优劣势分析

Simulation of delta variant strain of novel coronavirus (mindsponge application)

Memorizing byte order of big and small end

Thesis study -- Analysis of the influence of rainfall field division method on rainfall control rate

我的c语言进阶学习笔记 ----- 关键字

巧记大小端字节序
随机推荐
Can't write to avoid killing and can easily go online CS through defender
墨者学院-SQL注入漏洞测试(报错盲注)
Cvpr2022 stereo matching of asymmetric resolution images
Would you like to buy stocks? Where do you open an account in a securities company? The Commission is lower and safer
Oracle database basics concepts
如何通俗易懂的描述机器学习的流程?
How to use Pinia (I) introduce Pinia into the project
Is it safe to buy pension insurance online? Is there a policy?
利用burp精准定位攻击者
安利!如何提优质的ISSUE?学霸是这样写的!
com.fasterxml.jackson.databind.exc.MismatchedInputException: Expected array or string. at [Source:x
Using physical information neural network to solve hydrodynamics equations
手机炒股靠谱吗 网上开户炒股安全吗
How to easily describe the process of machine learning?
手机能开户炒股吗 网上开户炒股安全吗
技术干货|什么是大模型?超大模型?Foundation Model?
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
Technical dry goods | what is a big model? Oversized model? Foundation Model?
Cve-2022-30190 follina office rce analysis [attached with customized word template POC]
My advanced learning notes of C language ----- keywords