Program Description: Output multi-line content, the content is as follows:
*
***
*****
*******
*****
***
*
1#include <iostream>2 using namespacestd;3 intMain ()4 {5cout <<" *"<<Endl;6cout <<" ***"<<Endl;7cout <<" *****"<<Endl;8cout <<"*******"<<Endl;9cout <<" *****"<<Endl;Tencout <<" ***"<<Endl; Onecout <<" *"<<Endl; A -System"Pause"); - return 0; the}
Debug Disassembly Code
intMain () {00ff5e00 push ebp //Enter function after the first thing, save the bottom pointer, used to exit the function to restore the bottom of the stack. 00FF5E01 mov ebp,esp //adjust stack bottom pointer to stack top 00ff5e03 sub esp,0c0h //For local variable request memory space 00ff5e09 PU SH ebx 00ff5e0a push esi 00ff5e0b push EDI //Save Ebx,esi,edi, that is, save the field and restore when exiting the function. 00ff5e0c Lea EDI,[EBP-0C0H] //The first address of the memory assigned to the local variable is placed in the EDI 00ff5e12 mov ecx,30h 00ff5e17 mov eax,0cccccccch //debug, for tuning It is convenient to initialize all local variables to 0CCCCCCCCH. 00FF5E1C Rep stos dword ptr Es:[edi] //With the value of EAX initialized to the address pointed to by Es:[edi] (the memory header address assigned to the local variable), in DWORD (4 bytes), the number of cycles is the value in ECX. Because within a function,
//The memory space allocated for local variables is contiguous, so this sentence is initialized with all local variables as values in EAX. cout<<" *"<<ENDL;00FF5E1E mov esi,esp 00ff5e20 push 0ff14a6h 00ff5e25 push 0ffcc70h 00FF5E2A mov Eax,dword PTR ds:[0100009ch] 00ff5e2f push eax 00ff5e30 call std::operator<<<std::char_traits<Char> >(0FF14BFH) //Call the operator<< member function of the cout object (overloaded operator <<). 00ff5e35 add ESP,800FF5E38 mov ecx,eax 00ff5e3a call dword ptr ds:[1000090h] 00FF5E40 cmp esi,esp 00ff5e4 2 Call __rtc_checkesp (0FF132FH) //debug a unique function to detect stack balance. This function is called when the function exits with Debug. cout<<" ***"<<ENDL;00FF5E47 mov esi,esp 00ff5e49 push 0ff14a6h 00ff5e4e push 0ffcd24h 00ff5e53 mov Eax,dword PTR ds:[0100009ch] 00ff5e58 push eax 00ff5e59 call std::operator<<<std::char_traits<Char> >(0FF14BFH) 00ff5e5e add ESP,800FF5E61 mov ecx,eax 00ff5e63 call dword ptr ds:[1000090h] 00ff5e69 cmp esi,esp 00ff5e6 B call __rtc_checkesp (0FF132FH) cout<<" *****"<<endl;00ff5e70 mov esi,esp cout<<" *****"<<endl;00ff5e72 push 0ff14a6h 00ff5e77 push 0ffce64h 00ff5e7c mov eax,dword ptr ds:[0100009c H] 00ff5e81 push eax 00ff5e82 call std::operator<<<std::char_traits<Char> >(0FF14BFH) 00ff5e87 add ESP,800FF5E8A mov ecx,eax 00ff5e8c call dword ptr ds:[1000090h] 00ff5e92 cmp esi,esp 00ff5e9 4 Call __RTC_CHECKESP (0FF132FH) cout<<"*******"<<ENDL;00FF5E99 mov esi,esp 00ff5e9b push 0ff14a6h 00ff5ea0 push 0ffd1a8h 00FF5EA5 mov Eax,dword PTR ds:[0100009ch] 00FF5EAA push eax 00FF5EAB call std::operator<<<std::char_traits<Char> >(0FF14BFH) 00ff5eb0 add ESP,800FF5EB3 mov ecx,eax 00ff5eb5 call dword ptr ds:[1000090h] 00ff5ebb cmp esi,esp 00FF5EB D call __rtc_checkesp (0FF132FH) cout<<" *****"<<ENDL;00FF5EC2 mov esi,esp 00ff5ec4 push 0ff14a6h 00ff5ec9 push 0ffce64h 00ff5ece mov Eax,dword PTR ds:[0100009ch] 00ff5ed3 push eax 00FF5ED4 call std::operator<<<std::char_traits<Char> >(0FF14BFH) 00ff5ed9 add ESP,800FF5EDC mov ecx,eax 00ff5ede call dword ptr ds:[1000090h] 00ff5ee4 cmp esi,esp 00ff5ee 6 Call __rtc_checkesp (0FF132FH) cout<<" ***"<<Endl;00ff5eeb mov esi,esp 00ff5eed push 0ff14a6h 00ff5ef2 push 0ffcd24h 00FF5EF7 mov Eax,dword PTR ds:[0100009ch] 00FF5EFC push eax 00FF5EFD call std::operator<<<std::char_traits<Char> >(0FF14BFH) 00ff5f02 add ESP,800FF5F05 mov ecx,eax 00ff5f07 call dword ptr ds:[1000090h] 00ff5f0d cmp esi,esp 00ff5f0 F call __rtc_checkesp (0FF132FH) cout<<" *"<<ENDL;00FF5F14 mov esi,esp 00ff5f16 push 0ff14a6h 00ff5f1b push 0ffcc70h 00FF5F20 mov Eax,dword PTR ds:[0100009ch] 00ff5f25 push eax 00ff5f26 call std::operator<<<std::char_traits<Char> >(0FF14BFH) 00ff5f2b add ESP,800FF5F2E mov ecx,eax 00ff5f30 call dword ptr ds:[1000090h] 00ff5f36 cmp esi,esp 00ff5f3 8 Call __RTC_CHECKESP (0FF132FH) system ("Pause"); 00FF5F3D mov esi,esp 00ff5f3f push 0ffcbb0h 00ff5f44 call DWORD ptr ds:[10001d0h] 00ff5f 4 A add ESP,400FF5F4D cmp esi,esp 00ff5f4f call __RTC_CHECKESP (0FF132FH)return 0; 00ff5f54 xor eax,eax}00ff5f56 pop edi 00ff5f57 pop esi 00ff5f58 pop ebx Recovery site 00ff5f59 add esp,0c0h //c/c++ function calling convention is _cdecel by default, that is, the stack is balanced by the caller. 00ff5f5f cmp ebp,esp 00ff5f61 call __RTC_CHECKESP (0FF132FH) 00ff5f66 mov esp,ebp // Restore stack bottom pointer 00ff5f68 pop EBP 00ff5f69 ret
Optimized disassembly code under release
intMain () {011412a0 push EBP//save stack bottom pointer 011412A1 mov ebp,esp//adjust stack bottom pointer to stack top 011412A3 and ESP,0FFFFFF F8H//Request memory space for local variables cout<<" *"<<ENDL;011412A6 push 1141a80h 011412AB push ecx 011412AC mov ecx,dword ptr ds:[1143054h] 01 1412B2 mov edx,11431bch 011412B7 call std::operator<<<std::char_traits<Char> >(01141840h) 011412BC add ESP,4011412BF mov ecx,eax 011412c1 call dword ptr ds:[1143034h] cout<<" ***"<<endl;011412c7 push 1141a80h 011412CC push ecx 011412CD mov ecx,dword ptr ds:[1143054h] 01 1412D3 mov edx,11431c4h 011412D8 call std::operator<<<std::char_traits<Char> >(01141840h) 011412DD add ESP,4011412E0 mov ecx,eax 011412E2 call dword ptr ds:[1143034h] cout<<" *****"<<endl;011412e8 push 1141a80h 011412ED push ecx 011412EE mov ecx,dword ptr ds:[1143054h] 01 1412F4 mov edx,11431cch 011412F9 call std::operator<<<std::char_traits<Char> >(01141840h) 011412FE add ESP,4 01141301mov ecx,eax01141303Call dword ptr ds:[1143034h] cout<<"*******"<<Endl;01141309push 1141a80h 0114130E push ecx 0114130F mov ecx,dword ptr ds:[1143054h]01141315mov edx,11431d4h 0114131A call std::operator<<<std::char_traits<Char> >(01141840h) 0114131F add ESP,4 01141322mov ecx,eax01141324Call dword ptr ds:[1143034h] cout<<" *****"<<endl;0114132a push 1141a80h cout<<" *****"<<endl;0114132f push ecx01141330mov ecx,dword ptr ds:[1143054h]01141336mov edx,11431cch 0114133B call std::operator<<<std::char_traits<Char> >(01141840h)01141340Add ESP,4 01141343mov ecx,eax01141345Call dword ptr ds:[1143034h] cout<<" ***"<<endl;0114134b Push 1141a80h01141350push ECX01141351mov ecx,dword ptr ds:[1143054h]01141357mov edx,11431c4h 0114135C call std::operator<<<std::char_traits<Char> >(01141840h)01141361Add ESP,4 01141364mov ecx,eax01141366Call dword ptr ds:[1143034h] cout<<" *"<<endl;0114136c Push 1141a80h01141371push ECX01141372mov ecx,dword ptr ds:[1143054h]01141378mov edx,11431bch 0114137D call std::operator<<<std::char_traits<Char> >(01141840h)01141382Add ESP,4 01141385mov ecx,eax01141387Call DWORD ptr ds:[1143034h] System ("Pause"); 0114138D push 11431DCh01141392Call dword ptr DS:[11430DCH]01141398Add ESP,4 return 00114139B xor eax,eax}0114139d mov esp,ebp//restore stack top pointer}0114139f pop EBP//recovery stack bottom pointer 011413a0 RET
C + + Disassembly instance (1)-Output multiple lines