Disassembly Understanding function Call procedure

Source: Internet
Author: User

void Main () {013a4600  PushEBP013a4601  movEbp,esp013a4603  SubESP,0CCH013a4609  Pushebx013a460a  PushESI013a460b  PushEDI013a460c  LeaEDI,[EBP-0CCH]013a4612  movecx,33h013a4617  movEAX,0CCCCCCCCH013a461c  RepSTOs DWORD ptres:[edi]intresult = SUM (1,2,3,4);013a461e  Push        4  013a4620  Push        3  013a4622  Push        2  013a4624  Push        1  013a4626  Pagersum (013a1442h)013a462b  Addesp,10h013a462e  movdword ptr [Result],eax}013a4631  XOREax,eax013a4633  PopEDI013a4634  PopESI013a4635  Popebx013a4636  AddESP,0CCH013a463c  CMPEbp,esp013a463e  Pager__rtc_checkesp (013a12d5h)013a4643  movESP,EBP013a4645  PopEBP013a4646  ret  

intSumintAintBintMintN) {013a5160  PushEBP013a5161  movEbp,esp013a5163  SubESP,0CCH013a5169  Pushebx013a516a  PushESI013a516b  PushEDI013a516c  LeaEDI,[EBP-0CCH]013a5172  movecx,33h013a5177  movEAX,0CCCCCCCCH013a517c  RepSTOs DWORD ptres:[edi]intc = One;013a517e  movDWORD ptr [C],0BH return a + B + C;013a5185  movEax,dword ptr [a]013a5188  AddEax,dword ptr [b]013a518b  AddEax,dword ptr [c]}013a518e  PopEDI013a518f  PopESI013a5190  Popebx013a5191  movESP,EBP013a5193  PopEBP013a5194  ret 

A picture illustrates my understanding:

The process of creating a new stack frame is drawn, and the process of exiting the current stack frame is reversed. Pop edi, pop esi, pop ebx, mov esp,ebp, pop ebp. After that, the EDI,ESI,EBX reverts to its original state, and EBP points to the previous stack frame stack, and the ESP points to the top of the previous stack frame.

Disassembly Understanding function Call procedure

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.