当前位置:网站首页>汇编编写中断
汇编编写中断
2022-04-21 22:08:00 【bin elf】
Cortex-A 芯片一上电 SP 指针还没初始化,C 语言没法运行
C 环境(C语言环境就是保证C 语言能够正常运行)还没准备好,[C 语言中的函数调用涉及到出栈入栈,出栈入栈就要对堆栈进行操作-----这里与SP指针有关-----堆栈其实就是一段内存,这段内存比较特殊,由SP 指针访问,SP 指针指向栈顶]
所以肯定不能运行 C 代码,
必须先用汇编语言设置好 C 环境,设置SP指针,初始化DDR,因为芯片本身没有RAM,或者内部RAM 不开放给用户使用,用户代码需要在DDR 中运行,因此一开始要用汇编来初始化DDR 控制器。
汇编程序的默认入口标号是_start,不过我们也可以在链接脚本中使用 ENTRY 来指明其它的入口点。
无中断:
一般启动文件的汇编功能为:完成C环境的初始化,之后跳转到c代码
_start:
①选择ARM芯片的处理器模式,为SVC模式
(一般选择的是SVC(特权)模式和IRQ(中断))
②设置SP栈指针
③跳转到main函数中
有中断:
启动文件的汇编功能为:配置中断向量表完成C环境的初始化,之后跳转到c代码
_start:
①配置中断函数向量表(显而易见,当中断发生时,无论当前程序在哪里运行,都会跑到这个表所指向的地址,在这个地址处,我们就可以编写自己的中断处理函数了)
②配置所有中断的初始化函数

基地址+偏移=当前发的中断--------------决定着调用什么中断服务函数
保存现场
进入SVC模式(允许其他中断进入)
保存当前LR值
执行中断处理函数
弹出LR
再次进入中断模式
恢复现场
当一个中断函数处理完,必须得向GICC_EOIR寄存器写入终端号
恢复现场(将程序状态寄存器保存,保存LR(连接寄存器)的值--存着PC值)
版权声明
本文为[bin elf]所创,转载请带上原文链接,感谢
https://blog.csdn.net/weixin_47295886/article/details/123538282
边栏推荐
- 【ES6】数组的扩展
- php如何给数组增加一个数组元素
- 繁凡的对抗攻击论文精读(二)CVPR 2021 元学习训练模拟器进行超高效黑盒攻击(清华)
- ISMAR 2022 journal paper (tvcg) contribution exchange
- [best practice] patrol inspection item: local disk type inspection of cloud server (CVM) instance
- Database design and Implementation
- Because the epidemic makes the garment industry fully realize the necessity of digital transformation.
- ServiceWorker 缓存与 HTTP 缓存
- 2022年重庆最新建筑八大员(土建)模拟题库及答案
- [ES6] let and const commands
猜你喜欢

The third floor of leetcode Langya list - the container with the most water

Oracle级联删除表(不受外键约束)

Database design and Implementation

Intensive reading of Fanfan's anti attack paper (II) CVPR 2021 yuan learning training simulator for ultra efficient black box attack (Tsinghua)

Free your hands and recommend a low code tool open source by Alibaba, yyds~

INT 102_ TTL 09

Interview must brush algorithm top101 knapsack nine lectures Top13

Oracle cascade delete table (not subject to foreign key constraints)
![[webgl] simple tutorial](/img/11/208371dbc9bb1175f199ed21d4f651.png)
[webgl] simple tutorial

How does PHP add an array element to an array
随机推荐
Classification of software testing and principles of software testing
kotlin核心编程,Android开发面试解答之Handler
Windowns offline wsl2 installation
JS to realize automatic scrolling of announcements
面试必刷算法TOP101之背包九讲篇 TOP13
外包学生管理系统架构设计文档
How does wechat applet realize the function of jumping from commodity list to commodity details page
Database design and Implementation
Thread safety for the first time. This article is enough
Definition of software testing
LU decomposition, LDLT decomposition and Cholesky decomposition_ Zjuzly's blog - CSDN blog_ ldlt
软件的生命周期
Jupyter notebook has no run button
Domestic API management artifact eolink, I love it
In depth analysis of static, const, volatile, extern and register keywords
INT 102_TTL 09
ROS——使用OpenCV实现摄像头的发送和接收
字节日常实习(已OC)
云原生微服务的下一站,微服务引擎 MSE 重磅升级
正则表达式