C++反汇编二(if...else语句)
2012-02-11 00:39
363 查看
17: void Grammar_if_else() 18: { 00401450 push ebp 00401451 mov ebp,esp 00401453 sub esp,44h 00401456 push ebx 00401457 push esi 00401458 push edi 00401459 lea edi,[ebp-44h] 0040145C mov ecx,11h 00401461 mov eax,0CCCCCCCCh 00401466 rep stos dword ptr [edi] // 初始化 19: int x=5; 00401468 mov dword ptr [ebp-4],5 // 局部变量ebp-4赋值 20: if (x==5) 0040146F cmp dword ptr [ebp-4],5 // 局部变量与5比较 00401473 jne Grammar_if_else+45h (00401495) // 不相等则跳向00401495(即else开始处),相等则继续向下执行 21: { 22: cout<<"相等"<<endl; 00401475 push offset @ILT+40(std::endl) (0040102d) // 0040148E处的operator<<的参数2 std::endl入栈 0040147A push offset string "\xcf\xe0\xb5\xc8" (0043201c) // 00401484处的operator<<的参数2 "相等"入栈 // 与下面2条语句组合为调用operator<< 0040147F push offset std::cout (00439528) // 00401484处的operator<<的参数1 std::cout入栈 00401484 call @ILT+165(std::operator<<) (004010aa) // 调用operator<< 00401489 add esp,8 // 平衡堆栈,由于是不定长参数,所以由调用者平衡堆栈 0040148C mov ecx,eax // 返回值cout作为0040148E处的operator<<的参数1,寄存器ecx传递参数1 0040148E call @ILT+120(std::basic_ostream<char,std::char_traits<char> >::operator<<) (0040107d) 23: } 24: else 00401493 jmp Grammar_if_else+63h (004014b3) // 如果执行了if前半句,则跳过else直接到else结尾,保证2者只有一个执行. 25: { 26: cout<<"不相等"<<endl; 00401495 push offset @ILT+40(std::endl) (0040102d) 0040149A push offset string "\xb2\xbb\xcf\xe0\xb5\xc8" (00432024) 0040149F push offset std::cout (00439528) 004014A4 call @ILT+165(std::operator<<) (004010aa) 004014A9 add esp,8 004014AC mov ecx,eax 004014AE call @ILT+120(std::basic_ostream<char,std::char_traits<char> >::operator<<) (0040107d) 27: } 28: } 004014B3 pop edi 004014B4 pop esi 004014B5 pop ebx 004014B6 add esp,44h 004014B9 cmp ebp,esp 004014BB call __chkesp (00409100) 004014C0 mov esp,ebp 004014C2 pop ebp 004014C3 ret 由此可知,IF...ELSE语句与IF语句一样,也与高级语言的跳转指令正好相反.
相关文章推荐
- C++反汇编三(IF_ELSE多分支语句)
- C++反汇编->if语句分析
- C++反汇编一(if语句)
- IF...ELSE IF...ELSE IF...ELSE多分枝语句的反汇编判断
- C++反汇编->if语句分析
- C++程序员学Java系列之九:流程控制语句if,else
- 图解在反汇编中识别VC++之if-else分支语句
- C/C++学习(一)题目:求1+2+…+n,要求不能使用乘除法、for、while、if、else、switch、case等关键字以及条件判断语句(A?B:C)。
- IF...ELSE...语句的反汇编判断
- 5.9运用if-else语句
- Verilog中if..else和case语句分析
- Shell if else语句
- DAY_02浅谈ifelse与switch语句的不同 菜狗子的修炼之路
- C++学习 【3.3】 程序设计初步--选择结构和if语句
- Interview----求 1+2+...+n, 不能用乘除法、for、while if、else、switch、case 等关键字以及条件判断语句 (A?B:C)
- If-else 语句 和 三元运算符
- shell 判断语句 if else
- javascript下if else语句和三目运算符性能测试
- if....elif...else语句
- 如何在代码中减少if else语句的使用