if…else特征
#include<stdio.h>
int main()
{
int flag=0;
if(flag==0)
{
printf("%d\n",flag);
}
else
{
printf("else \n");
}
return 0;
}
汇编
2: int main()
3: {
00401010 push ebp
00401011 mov ebp,esp
00401013 sub esp,44h
00401016 push ebx
00401017 push esi
00401018 push edi
00401019 lea edi,[ebp-44h]
0040101C mov ecx,11h
00401021 mov eax,0CCCCCCCCh
00401026 rep stos dword ptr [edi]
4:
5: int flag=0;
00401028 mov dword ptr [ebp-4],0
6:
7: if(flag==0)
0040102F cmp dword ptr [ebp-4],0
00401033 jne main+38h (00401048) //跳转至else内容,否则进入if里面
8: {
9: printf("%d\n",flag);
00401035 mov eax,dword ptr [ebp-4]
00401038 push eax
00401039 push offset string “%d\n” (0042201c)
0040103E call printf (004010c0)
00401043 add esp,8
10: }
11: else
00401046 jmp main+45h (00401055)
12: {
13: printf(“else \n”);
00401048 push offset string “else \n” (00422fa4)
0040104D call printf (004010c0)
00401052 add esp,4
14: }
15:
16: return 0;
00401055 xor eax,eax
17: }
00401057 pop edi
00401058 pop esi
00401059 pop ebx
0040105A add esp,44h
0040105D cmp ebp,esp
0040105F call __chkesp (00401140)
00401064 mov esp,ebp
00401066 pop ebp
00401067 ret
结论
cmp
jxx
…
…
jmp(配合无条件跳转)