int c = 0;
int i = 0;
for(i =0 ; i< 10; i++)
{
c += i;
}
转化成汇编如下:
mov [ebp - 4], 0 //0000001
mov [ebb - 8], 0 //0000002
mov [ebp - 4], 0 //0000003
jmp 0000006 //0000004
add [ebp -4], 1 //0000005
cmp [ebp-4], 10 //0000006
jge 00000012 //0000007
mov eax, [ebp-8] //0000008
add eax, [ebp-4] //0000009
mov [ebp-8], eax //00000010
jmp 0000005 //00000011
//00000012
Release 版的代码:
00401000 xor eax,eax
00401002 xor ecx,ecx
00401004 add eax,ecx
00401006 inc ecx
00401007 cmp ecx,0Ah
0040100A jl Add+4 (00401004)