当前位置:网站首页>2. Judgment statement
2. Judgment statement
2022-07-23 10:19:00 【Chicken Island~】
C++ Code
bool isWorth{
};
if (isWorth == true) {
std::cout << 1;
}
else {
std::cout << 0;
}
Assembly code
mov byte ptr [ebp-5],0
movzx eax,byte ptr [ebp-5]
cmp eax,1
jne 00A1573E
00795725 mov esi,esp
push 1
mov ecx,dword ptr ds:[00A210D4h]
call dword ptr ds:[00A210DCh]
cmp esi,esp
call 00A113C0
EB 17 jmp 00A15755
mov esi,esp
push 0
mov ecx,dword ptr ds:[00A210D4h]
call dword ptr ds:[00A210DCh]
cmp esi,esp
call 00A113C0
Machine code
C6 45 FB 00
0F B6 45 FB
83 F8 01
75 19
8B F4
6A 01
8B 0D D4 10 A2 00
FF 15 DC 10 A2 00
3B F4
E8 84 BC FF FF
EB 17
8B F4
6A 00
8B 0D D4 10 A2 00
FF 15 DC 10 A2 00
3B F4
E8 6B BC FF FF
Raise questions :
- cpu Through what mechanism Jump To 00795725 This memory address ?
- if Why is there a line at the end of the code jmp Instructions ? answer : In order to skip over else The code in the code block , avoid else The code block is executed .
Modify the code
> By modifying a single conditional variable isWorth To observe the changes :
> Found that when isWorth by 1 when , register EFL Nothing will change
> When isWorth by 0 when , register EFL There is a change .
Design experiments
When we run isWorth by true The program , perform cmp Instructions , Only found TF It has changed

When we run isWorth by false The program , perform cmp Instructions ,ZF, AF, SF, CF,TF There is a change

Found that regular :
- cmp Instructions will affect ZF position
- When ZF Position as 1 when ,jne Instructions are the same as ordinary instructions , After the execution , Can make EIP The address of +2; When ZF Position as 0 when ,jne Instructions will make EIP The address of
It is amended as follows jne Address in the instruction , The address in the instruction is else Code inside The first address
Come to the conclusion :
- if else The essence of is actually mov, cmp,jne,jmp The combination of instructions
边栏推荐
- 十年架构五年生活-05第一次出差
- What is per title encoding?
- GNN third party Library: pyg (pytorch geometric) [the library based on pytorch can help users quickly build and train their own graph neural network model] [deepwalk, line, GCN, gat, etc.]
- How to add an operator in ONEFLOW
- 数学向量基本知识
- Undo log日志详解
- Sum of three numbers: (sort + double pointer + pruning)
- 【VSCODE】当前工作目录非当前文件夹/pathlib打印cwd路径错误
- switch语句的工作原理
- 转行软件测试薪资10K | 手中有粮心中有底,在任何时候都是真理
猜你喜欢
随机推荐
Illustration and text demonstrate the movable range of the applet movable view
Ten year structure five year Life-05 first business trip
如何将list中相同字段值归类在同一个list下
Leetcode-99. restore binary search tree
SSM framework takeout ordering system
【VSCODE】当前工作目录非当前文件夹/pathlib打印cwd路径错误
60 open-ended test questions, recite them and get a pay rise directly
【C语言基础】16 可变数组(数组长度可扩展)
Time series dataset: power transformer dataset (etdataset)
Android开发学习日记--内容提供者(跨应用间的数据库修改)
Earning power "needs to be accumulated
Self organization is the two-way rush of managers and members
S2SH+mysql的在线英语学习系统
Airtest脚本的点击位置与点击偏移
STM32 - input capture experiment
Deeply understand mvcc and bufferpool caching mechanism
Anaconda 换源以及安装opencv
SSH supermarket inventory management system
Online English learning system based on s2sh+mysql
利用反射对修饰符为final的成员变量进行修改








