我刚刚注意到一些奇怪的空主函数的汇编语言代码。用Visual C++编译器解释空C`main`函数的奇怪程序集
//filename: main.c
void main()
{
}
拆解:
push ebp
mov ebp,esp
sub esp,0C0h; why on the earth is it reserving 192 bytes?
push ebx
push esi
push edi ; good compiler. Its saving ebx, esi & edi values.
lea edi,[ebp-0C0h] ; line 1
mov ecx,30h ; line 2
mov eax,0CCCCCCCCh ; line 3
rep stos dword ptr es:[edi] ; line 4
xor eax,eax ; returning value 0. Code following this line is explanatory.
pop edi ; restoring the original states of edi,esi & ebx
pop esi
pop ebx
mov esp,ebp
pop ebp
ret
- 为什么地球上它保留了功能192个字节,其中没有任何变量
- 怎么了四大行:1号线, 2,第3行,第4行?它试图做什么&为什么?
为什么不突出显示代码语法? – claws 2010-07-29 13:25:05
装配非空主语句时产生了什么程序集,以及将main的返回类型更改为int时会发生什么? – 2010-07-29 13:29:17
值得指出的是主要回报int。使用void作为main不是很好。 – nmichaels 2010-07-29 13:30:21