当前位置:网站首页>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
边栏推荐
- C语言——几道C语言经典习题
- 开源进销存系统,10分钟搞定,建议收藏!
- 数据库设计
- 多线程中的「lost wake up 问题」| 为什么wait()和notify()需要搭配synchonized关键字使用?
- Comprehensive summary of software quality management practice
- EasyCVR新版本(v2.5.0)目录分级功能如何使用?
- How does the browser import and export | delete bookmarks? Here are the steps
- 七大排序--万字详解
- Data middle office, Bi business interview (III): how to choose the right interviewees
- 华泰证券可以网上开户吗安全吗
猜你喜欢
随机推荐
QT error: error c2039 "value": not a member of "`global namespace"
Jeecgboot import document
指针的底层机制
What is the experience of writing concurrent tool classes (semaphore, cyclicbarrier, countdownlatch) by yourself in line 30?
多线程中的「lost wake up 问题」| 为什么wait()和notify()需要搭配synchonized关键字使用?
Can Huatai Securities open an account online? Is it safe
How to build and use redis fragment cluster
What are you doing at two in the morning?
Visual full link log tracking
华泰证券可以网上开户吗安全吗
客户至上 | 国产BI领跑者,思迈特软件完成C轮融资
Is it safe for Huatai Securities to open an account online? Is it true
Illustration and text demonstrate the movable range of the applet movable view
Compose原理解析系列之一Compose的设计原理
What is per title encoding?
Nine charts overview the cycle law of encryption Market
S2SH+mysql的在线英语学习系统
ssm框架外卖订餐系统
【C语言基础】14 文件、声明和格式化输入输出
Read write barrier in memory barrier -- concurrency problem



![[MySQL] cursor](/img/60/19236cee3adafe27c431582ec053f8.png)





