chapter4.1
// chapter4.cpp : 定义控制台应用程序的入口点。
//
#include "stdafx.h"
int _tmain(int argc, _TCHAR* argv[])
{
const size_t size = 16;
int carr[size];
for(int idx = 0; idx != size; ++idx)
{
carr[idx] = idx;
}
return 0;
}
debug
od
00412FE0 55 push ebp
00412FE1 8BEC mov ebp, esp
00412FE3 81EC 20010000 sub esp, 120
00412FE9 53 push ebx
00412FEA 56 push esi
00412FEB 57 push edi
00412FEC 8DBD E0FEFFFF lea edi, dword ptr [ebp-120]
00412FF2 B9 48000000 mov ecx, 48
00412FF7 B8 CCCCCCCC mov eax, CCCCCCCC
00412FFC F3:AB rep stos dword ptr es:[edi]
00412FFE C745 F8 1000000>mov dword ptr [ebp-8], 10
00413005 C745 A4 0000000>mov dword ptr [ebp-5C], 0
0041300C EB 09 jmp short 00413017
0041300E 8B45 A4 mov eax, dword ptr [ebp-5C]
00413011 83C0 01 add eax, 1
00413014 8945 A4 mov dword ptr [ebp-5C], eax
00413017 837D A4 10 cmp dword ptr [ebp-5C], 10
0041301B 74 0C je short 00413029
0041301D 8B45 A4 mov eax, dword ptr [ebp-5C]
00413020 8B4D A4 mov ecx, dword ptr [ebp-5C]
00413023 894C85 B0 mov dword ptr [ebp+eax*4-50], ecx
00413027 ^ EB E5 jmp short 0041300E
00413029 33C0 xor eax, eax
0041302B 52 push edx
0041302C 8BCD mov ecx, ebp
0041302E 50 push eax
0041302F 8D15 44304100 lea edx, dword ptr [413044]
00413035 E8 52E0FFFF call 0041108C
0041303A 58 pop eax
0041303B 5A pop edx
0041303C 5F pop edi
0041303D 5E pop esi
0041303E 5B pop ebx
0041303F 8BE5 mov esp, ebp
00413041 5D pop ebp ; 0012FFB8
00413042 C3 retn
ida
.text:00412FE0
.text:00412FE0 ; =============== S U B R O U T I N E =======================================
.text:00412FE0
.text:00412FE0 ; Attributes: bp-based frame
.text:00412FE0
.text:00412FE0 _wmain proc near ; CODE XREF: j__wmainj
.text:00412FE0
.text:00412FE0 var_120 = byte ptr -120h
.text:00412FE0 idx = dword ptr -5Ch
.text:00412FE0 var_50 = dword ptr -50h
.text:00412FE0 size = dword ptr -8
.text:00412FE0
.text:00412FE0 000 push ebp
.text:00412FE1 004 mov ebp, esp
.text:00412FE3 004 sub esp, 120h
.text:00412FE9 124 push ebx
.text:00412FEA 128 push esi
.text:00412FEB 12C push edi
.text:00412FEC 130 lea edi, [ebp+var_120]
.text:00412FF2 130 mov ecx, 48h
.text:00412FF7 130 mov eax, 0CCCCCCCCh
.text:00412FFC 130 rep stosd
.text:00412FFE 130 mov [ebp+size], 10h
.text:00413005 130 mov [ebp+idx], 0
.text:0041300C 130 jmp short loc_413017
.text:0041300E ; ---------------------------------------------------------------------------
.text:0041300E
.text:0041300E loc_41300E: ; CODE XREF: _wmain+47j
.text:0041300E 130 mov eax, [ebp+idx]
.text:00413011 130 add eax, 1
.text:00413014 130 mov [ebp+idx], eax
.text:00413017
.text:00413017 loc_413017: ; CODE XREF: _wmain+2Cj
.text:00413017 130 cmp [ebp+idx], 10h
.text:0041301B 130 jz short loc_413029
.text:0041301D 130 mov eax, [ebp+idx]
.text:00413020 130 mov ecx, [ebp+idx]
.text:00413023 130 mov [ebp+eax*4+var_50], ecx
.text:00413027 130 jmp short loc_41300E
.text:00413029 ; ---------------------------------------------------------------------------
.text:00413029
.text:00413029 loc_413029: ; CODE XREF: _wmain+3Bj
.text:00413029 130 xor eax, eax
.text:0041302B 130 push edx
.text:0041302C 134 mov ecx, ebp
.text:0041302E 134 push eax
.text:0041302F 138 lea edx, dword_413044
.text:00413035 138 call j_@_RTC_CheckStackVars@8 ; _RTC_CheckStackVars(x,x)
.text:0041303A 130 pop eax
.text:0041303B 12C pop edx
.text:0041303C 128 pop edi
.text:0041303D 124 pop esi
.text:0041303E 120 pop ebx
.text:0041303F 11C mov esp, ebp
.text:00413041 004 pop ebp
.text:00413042 000 retn
.text:00413042 _wmain endp
.text:00413042
.text:00413042 ; --------------------------------------------------
release
od
00401000 /$ 83EC 40 sub esp, 40
00401003 |. 33C0 xor eax, eax
00401005 |> 40 /inc eax
00401006 |. 83F8 10 |cmp eax, 10
00401009 |.^ 75 FA \jnz short 00401005
0040100B |. 33C0 xor eax, eax
0040100D |. 83C4 40 add esp, 40
00401010 \. C3 retn
ida
.text:00401000 assume es:nothing, ss:nothing, ds:_data, fs:nothing, gs:nothing
.text:00401000
.text:00401000 ; =============== S U B R O U T I N E =======================================
.text:00401000
.text:00401000
.text:00401000 ; int __cdecl main(int argc, const char **argv, const char *envp)
.text:00401000 _main proc near ; CODE XREF: ___tmainCRTStartup+10Ap
.text:00401000
.text:00401000 argc = dword ptr 4
.text:00401000 argv = dword ptr 8
.text:00401000 envp = dword ptr 0Ch
.text:00401000
.text:00401000 sub esp, 40h
.text:00401003 xor eax, eax
.text:00401005
.text:00401005 loc_401005: ; CODE XREF: _main+9j
.text:00401005 inc eax
.text:00401006 cmp eax, 10h
.text:00401009 jnz short loc_401005
.text:0040100B xor eax, eax
.text:0040100D add esp, 40h
.text:00401010 retn
.text:00401010 _main endp
.text:00401010
.text:00401011
.text:00401011 ; =============== S U B R O U T I N E =======================================