HelloWorld

C:

#include <stdio.h>
int main(){
printf("HELLO WORLD");
return 0;
}

对其进行反汇编:

push ebp
.text:00401501 mov ebp, esp
.text:00401503 and esp, 0FFFFFFF0h
.text:00401506 sub esp, 10h
.text:00401509 call ___main
.text:0040150E mov dword ptr [esp], offset aHelloWorld ; "HELLO WORLD"
.text:00401515 call _printf
.text:0040151A mov eax, 0
.text:0040151F leave
.text:00401520 retn
.text:00401520 _main endp

 

 

 

C++:

#include <iostream>
using namespace std;
int main()
{
cout<<"Hello world"<<endl;
return 0;
}

反汇编:

.text:00401500 lea ecx, [esp+4]
.text:00401504 and esp, 0FFFFFFF0h
.text:00401507 push dword ptr [ecx-4]
.text:0040150A push ebp
.text:0040150B mov ebp, esp
.text:0040150D push ecx
.text:0040150E sub esp, 14h
.text:00401511 call ___main
.text:00401516 mov dword ptr [esp+4], offset aHelloWorld ; "Hello world"
.text:0040151E mov dword ptr [esp], offset __ZSt4cout ; std::ostream::sentry *
.text:00401525 call __ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc ; std::operator<<<std::char_traits<char>>(std::basic_ostream<char,std::char_traits<char>> &,char const*)
.text:0040152A mov dword ptr [esp], offset __ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_ ; std::endl<char,std::char_traits<char>>(std::basic_ostream<char,std::char_traits<char>> &)
.text:00401531 mov ecx, eax
.text:00401533 call __ZNSolsEPFRSoS_E ; std::ostream::operator<<(std::ostream & (*)(std::ostream &))
.text:00401538 sub esp, 4
.text:0040153B mov eax, 0
.text:00401540 mov ecx, [ebp+var_4]
.text:00401543 leave
.text:00401544 lea esp, [ecx-4]
.text:00401547 retn
.text:00401547 _main endp

posted @ 2015-11-20 13:16  李翀先森  阅读(270)  评论(0编辑  收藏  举报