004015D0 push ebp
004015D1 mov ebp,esp
004015D3 sub esp,48h
004015D6 push ebx
004015D7 push esi
004015D8 push edi
004015D9 lea edi,[ebp-48h]
004015DC mov ecx,12h
004015E1 mov eax,0CCCCCCCCh
004015E6 rep stos dword ptr [edi] // 初始化堆栈
49: int x=5;
004015E8 mov dword ptr [ebp-4],5 // 局部变量ebp-4赋值5
50: switch (x)
51: {
004015EF mov eax,dword ptr [ebp-4]
004015F2 mov dword ptr [ebp-8],eax // 拷贝局部变量
004015F5 cmp dword ptr [ebp-8],0 // 局部变量和0比较
004015F9 je Grammer_switch+39h (00401609) // 相等则跳向case 0,否则继续和case 1 比较
004015FB cmp dword ptr [ebp-8],1 // 和1比较
004015FF je Grammer_switch+59h (00401629) // 相等则跳向case 1,否则继续和case 2 比较
00401601 cmp dword ptr [ebp-8],2 // 和2比较
00401605 je Grammer_switch+79h (00401649) // 相等则跳向case 2,否则继续和case 3 比较
00401607 jmp Grammer_switch+99h (00401669) // 以上条件都不满足,则跳向default处
52: case 0:
53: {
54: cout<<"x=0"<<endl;
00401609 push offset @ILT+45(std::endl) (00401032)
0040160E push offset string "x=0" (0043204c)
00401613 push offset std::cout (00439528)
00401618 call @ILT+175(std::operator<<) (004010b4)
0040161D add esp,8
00401620 mov ecx,eax
00401622 call @ILT+125(std::basic_ostream<char,std::char_traits<char> >::operator<<) (00401082)
55: }
56: break;
00401627 jmp Grammer_switch+0B7h (00401687) //跳出switch语句
57: case 1:
58: {
59: cout<<"x=1"<<endl;
00401629 push offset @ILT+45(std::endl) (00401032)
0040162E push offset string "x=1" (00432048)
00401633 push offset std::cout (00439528)
00401638 call @ILT+175(std::operator<<) (004010b4)
0040163D add esp,8
00401640 mov ecx,eax
00401642 call @ILT+125(std::basic_ostream<char,std::char_traits<char> >::operator<<) (00401082)
60: }
61: break;
00401647 jmp Grammer_switch+0B7h (00401687) //跳出switch语句
62: case 2:
63: {
64: cout<<"x=2"<<endl;
00401649 push offset @ILT+45(std::endl) (00401032)
0040164E push offset string "x=2" (00432044)
00401653 push offset std::cout (00439528)
00401658 call @ILT+175(std::operator<<) (004010b4)
0040165D add esp,8
00401660 mov ecx,eax
00401662 call @ILT+125(std::basic_ostream<char,std::char_traits<char> >::operator<<) (00401082)
65: }
66: break;
00401667 jmp Grammer_switch+0B7h (00401687) //跳出switch语句
67: default:
68: {
69: cout<<"x未知"<<endl;
00401669 push offset @ILT+45(std::endl) (00401032)
0040166E push offset string "x\xce\xb4\xd6\xaa" (0043203c)
00401673 push offset std::cout (00439528)
00401678 call @ILT+175(std::operator<<) (004010b4)
0040167D add esp,8
00401680 mov ecx,eax
00401682 call @ILT+125(std::basic_ostream<char,std::char_traits<char> >::operator<<) (00401082)
70: }
71: break;
72: }
73:
74: }
00401687 pop edi
00401688 pop esi
00401689 pop ebx
0040168A add esp,48h
0040168D cmp ebp,esp
0040168F call __chkesp (004092e0)
00401694 mov esp,ebp
00401696 pop ebp
00401697 ret
C++反汇编四(SWITCH语句)
最新推荐文章于 2023-05-26 13:24:53 发布