今天闲来无事.就想看看sizeof到底是怎么回事.于是,反汇编之!
- int _tmain(int argc, _TCHAR* argv[])
- {
- int i=sizeof(int);
- return 0;
- }
反汇编后
int _tmain(int argc, _TCHAR* argv[])
{
00411370 push ebp
00411371 mov ebp,esp
00411373 sub esp,0CCh
00411379 push ebx
0041137A push esi
0041137B push edi
0041137C lea edi,[ebp-0CCh]
00411382 mov ecx,33h
00411387 mov eax,0CCCCCCCCh
0041138C rep stos dword ptr es:[edi] //这前面代码是申请0XCC个局部栈空间,并初始化为0xCCCCCCCCh
//int i=sizeof(int);
0041138E mov dword ptr [i],4 //原来是编译器替换掉了sizeof的值
//return 0;
00411395 xor eax,eax
}