00401500 push ebp
00401501 mov ebp,esp
00401503 sub esp,44h
00401506 push ebx
00401507 push esi
00401508 push edi
00401509 lea edi,[ebp-44h]
0040150C mov ecx,11h
00401511 mov eax,0CCCCCCCCh
00401516 rep stos dword ptr [edi] // 初始化
32: int x=3;
00401518 mov dword ptr [ebp-4],3 // 局部变量ebp-4赋值
33: if (5>x)
0040151F cmp dword ptr [ebp-4],5 // 局部变量和5比较
00401523 jge Grammar_if_else_if+45h (00401545) // 大于等于则跳向下一个个分支语句.否则继续向下执行
34: {
35: cout<<"小于"<<endl;
00401525 push offset @ILT+40(std::endl) (0040102d) // 相等则输出相等
0040152A push offset string "\xd0\xa1\xd3\xda" (00432034)
0040152F push offset std::cout (00439528)
00401534 call @ILT+170(std::operator<<) (004010af)
00401539 add esp,8
0040153C mov ecx,eax
0040153E call @ILT+120(std::basic_ostream<char,std::char_traits<char> >::operator<<) (0040107d)
36: }
37: else if (5<x)
00401543 jmp Grammar_if_else_if+89h (00401589) // 输出相等后直接跳向分支语句结束
00401545 cmp dword ptr [ebp-4],5 // 继续和5比较
00401549 jle Grammar_if_else_if+6Bh (0040156b) // 小于等于则跳向下一条分支语句处,否则继续向下执行
38: {
39: cout<<"大于"<<endl;
0040154B push offset @ILT+40(std::endl) (0040102d)
00401550 push offset string "\xb4\xf3\xd3\xda" (0043202c)
00401555 push offset std::cout (00439528)
0040155A call @ILT+170(std::operator<<) (004010af)
0040155F add esp,8
00401562 mov ecx,eax
00401564 call @ILT+120(std::basic_ostream<char,std::char_traits<char> >::operator<<) (0040107d)
40: }
41: else
00401569 jmp Grammar_if_else_if+89h (00401589) // 输出大于后直接跳向分支语句结束
42: {
43: cout<<"相等"<<endl;
0040156B push offset @ILT+40(std::endl) (0040102d) // 以上分支条件都不满足,则执行else语句
00401570 push offset string "\xcf\xe0\xb5\xc8" (0043201c)
00401575 push offset std::cout (00439528)
0040157A call @ILT+170(std::operator<<) (004010af)
0040157F add esp,8
00401582 mov ecx,eax
00401584 call @ILT+120(std::basic_ostream<char,std::char_traits<char> >::operator<<) (0040107d)
44: }
45: }
00401589 pop edi // 平衡堆栈
0040158A pop esi
0040158B pop ebx
0040158C add esp,44h
0040158F cmp ebp,esp
00401591 call __chkesp (004091d0)
00401596 mov esp,ebp
00401598 pop ebp
00401599 ret // 返回给调用者
C++反汇编三(IF_ELSE多分支语句)
最新推荐文章于 2023-10-08 18:00:46 发布