当前位置:网站首页>【学习笔记】从汇编看 a+++a与 a+a++的区别
【学习笔记】从汇编看 a+++a与 a+a++的区别
2022-07-24 05:38:00 【曾胖神父】
汇编代码查看方法
使用VS2019,新建断点在需要查看的代码文件里,然后点击调试,在调试过程中,点击调试-》窗口-》反汇编,就能看到当前代码的汇编格式了
a+++a与 a+a++的汇编指令与直译
声明变量 a,b,c的汇编指令
int a = 1;
00007FF9854D0FDC mov dword ptr [rbp+34h],1
int b = 1;
00007FF9854D0FE3 mov dword ptr [rbp+30h],1
int c = 1;
00007FF9854D0FEA mov dword ptr [rbp+2Ch],1
a+++a的汇编指令
00007FF9854D0FF1 mov ecx,dword ptr [rbp+34h]
00007FF9854D0FF4 mov dword ptr [rbp+28h],ecx
00007FF9854D0FF7 mov ecx,dword ptr [rbp+34h]
00007FF9854D0FFA inc ecx
00007FF9854D0FFC mov dword ptr [rbp+34h],ecx
00007FF9854D0FFF mov ecx,dword ptr [rbp+28h]
00007FF9854D1002 add ecx,dword ptr [rbp+34h]
00007FF9854D1005 mov dword ptr [rbp+2Ch],ecx
a+++a的汇编指令直译
把变量a内存地址的数据赋给寄存器ecx
寄存器ecx的数据赋给rbp+28h内存地址
把变量a内存地址的数据赋给寄存器ecx
寄存器ecx的值自加1
寄存器ecx的数据赋给变量a内存地址(PS:这个时候就a完成自增并且a=2)
把rbp+28h内存地址的数据赋给寄存器ecx
将寄存器ecx的值与变量a内存地址的值相加,并将值赋予寄存器ecx
寄存器ecx的数据赋给变量c内存地址
a+a++的汇编指令
00007FF9854D100F mov ecx,dword ptr [rbp+34h]
00007FF9854D1012 mov dword ptr [rbp+24h],ecx
00007FF9854D1015 mov ecx,dword ptr [rbp+34h]
00007FF9854D1018 mov dword ptr [rbp+20h],ecx
00007FF9854D101B mov ecx,dword ptr [rbp+34h]
00007FF9854D101E inc ecx
00007FF9854D1020 mov dword ptr [rbp+34h],ecx
00007FF9854D1023 mov ecx,dword ptr [rbp+24h]
00007FF9854D1026 add ecx,dword ptr [rbp+20h]
00007FF9854D1029 mov dword ptr [rbp+30h],ecx
a+a++的汇编指令直译
把变量a内存地址的数据赋给寄存器ecx
寄存器ecx的数据赋给rbp+24h内存地址
把变量a内存地址的数据赋给寄存器ecx
寄存器ecx的数据赋给rbp+20h内存地址
把变量a内存地址的数据赋给寄存器ecx
寄存器ecx的值自加1
寄存器ecx的数据赋给变量a内存地址(PS:这个时候就a完成自增并且a=2)
把rbp+24h内存地址的数据赋给寄存器ecx
将寄存器ecx的值与rbp+20内存地址的值相加,并将值赋予寄存器ecx(结果为2)
寄存器ecx的数据赋给变量b内存地址
a+++a与 a+a++的汇编指令的区别
a+++a与 a+a++的汇编指令的直接区别在于a+a++声明了一个新的内存地址,该内存地址装载了a未自增的值,并且参与计算的是该内存地址,而非自增后的a。
边栏推荐
- kubernetes简介和架构及其原理
- 【LVGL】【阶段总结1】
- Experiment: creation, expansion, and deletion of LVM logical volumes
- 不运动也能增肌???打一针冬眠黑熊的血清就行
- [lvgl] [stage summary 1]
- nodejs开启多进程并实现进程间通信
- Esp32 ultra detailed learning record: NTP synchronization time
- PostgreSQL date handler usage
- JS - calculate the side length and angle of a right triangle
- Promise
猜你喜欢
随机推荐
Detailed analysis of the process (life cycle) of class loading
[small object velocimeter] only principle, no code
创建WPF项目
(静态,动态,文件)三个版本的通讯录
带你深入了解MySQL数据库扣减库存原理
sql server 同步数据库 跨网段无公网ip几个常见小问题问题
歹徒逃亡3
[lvgl layout] flexible layout
Why can't index be the key of V-for?
Special effects - Cherry Blossom falling background effects
Redis data type -string (string type)
【ESP8266点焊机】基于 ESP8266 for Arduino
【LVGL(6)】显示中文设置,制作中文字库
Kubernetes' deployment, service concept, dynamic capacity expansion
类加载的过程(生命周期)详情分析
[esp8266 spot welder] Based on esp8266 for Arduino
SparkSQL核心使用,220724,
[lvgl layout] grid layout
Solution: exit status 1 and exit status 145 appear when the console uses NVM to control the node version
Special effects - click with the mouse and the fireworks will burst


![[lvgl] [stage summary 1]](/img/39/c6e96ae7971a2350769ef5b5950f8f.png)
![[lvgl (3)]](/img/d3/1e2bad232f29c6c75ff163a6c0f378.png)


![JS: why [] = =! [] return true?](/img/36/94839bf4ce6bd06d2cbe989828c791.png)
![[lvgl (1)] a brief introduction to lvgl](/img/2e/2e155f1d3669c27ad1b090ca954224.png)

