当前位置:网站首页>【问题思考总结】为什么寄存器清零是在用户态进行的?
【问题思考总结】为什么寄存器清零是在用户态进行的?
2022-07-01 05:33:00 【kev_gogo】
问题提出
在看到王道书上这个题的时候,我首先想到这个不是有很多寄存器是不透明的吗,因此不是应该用户态一定操作不了,甚至是管态都操作不了吗,基于这个思想,我进行了一定的查阅。
思考
经过查找发现,事实上如果想到了汇编的层面(但是这对我一个非科班学生没学过真的有点难唉,感慨学艺不精)就简单很多了。举一个最简单的例子:int i=0,这句代码实际上就是将一个寄存器里的值设为0,而这样的操作显然是很平常的操作,也完全用不到进入管态,因此是在用户态(目态)进行。
延伸思考
C语言细节
经过思考我又想到难道所有设置变量都是在寄存器中?可是寄存器是有限的啊,于是查找发现在C语言中用户可以自己定义寄存器变量如:register int i=0,这样的格式,而即便不这样做,编译器也可能会将变量存在寄存器中因为显然对于某些变量存在寄存器中可以极大提高系统的效率(比如经常使用的变量,在循环中的变量,基于局部性原理,这个括号内为个人猜想)。
寄存器细节
另外,为了证实寄存器可以存放变量,我又想起了程序员透明和程序员不透明这个知识点,经过查阅发现,通用寄存器是汇编程序员不透明,这也证实了之前的汇编层调用寄存器说法的真实性
参考资料
【1】http://www.cskaoyan.com/thread-7075-1-10.html
【2】https://blog.csdn.net/HumanpieceY/article/details/85917291
边栏推荐
- What is the at instruction set often used in the development of IOT devices?
- Educational administration management system of SSM (free source code)
- 如何选择导电滑环材料
- QT等待框制作
- 3D建模與處理軟件簡介 劉利剛 中國科技大學
- Mongodb學習篇:安裝後的入門第一課
- Txncoordsender of cockroachdb distributed transaction source code analysis
- 0xc000007b应用程序无法正常启动解决方案(亲测有效)
- And search: the suspects (find the number of people related to the nth person)
- 数字金额加逗号;js给数字加三位一逗号间隔的两种方法;js数据格式化
猜你喜欢
![[RootersCTF2019]babyWeb](/img/b4/aa8f8e107a9dacbace72d4717b1834.png)
[RootersCTF2019]babyWeb
![[RootersCTF2019]babyWeb](/img/b4/aa8f8e107a9dacbace72d4717b1834.png)
[RootersCTF2019]babyWeb

JDBC common interview questions

基于TI DRV8424驱动步进电机实现调速和行程控制

液压滑环的特点讲解

Application of industrial conductive slip ring

Mongodb學習篇:安裝後的入門第一課

2/15 (awk, awk conditions, awk processing design can perform additional tasks, and use awk array +for loop to realize advanced search)

el-cascader回显失败;el-cascader回显不出来

Things generated by busybox
随机推荐
Speed regulation and stroke control based on Ti drv8424 driving stepper motor
Txncoordsender of cockroachdb distributed transaction source code analysis
提高企业产品交付效率系列(1)—— 企业应用一键安装和升级
Causes of short circuit of conductive slip ring and Countermeasures
轻松上手Fluentd,结合 Rainbond 插件市场,日志收集更快捷
El cascade echo failed; El cascader does not echo
第05天-文件操作函数
el-form表单新增表单项动态校验;el-form校验动态表单v-if不生效;
Detailed explanation of set
Ebpf cilium practice (2) - underlying network observability
Variable binding and deconstruction for rudimentary rust
Design and application of immutable classes
Usage and principle of synchronized
College community management system based on boot+jsp (with source code download link)
LRU cache for leveldb source code analysis
Wild melon or split melon?
Set集合详细讲解
Numeric amount plus comma; JS two methods of adding three digits and a comma to numbers; JS data formatting
CentOS 7使用yum安装PHP7.0
Unity uses SQLite