资源描述:
《编译原理课程设计之函数调用分析(compiler theory, curriculum design, function call analysis)》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、编译原理课程设计之函数调用分析(Compilertheory,curriculumdesign,functioncallanalysis)Thereare3methodsforcallingfunctionsinWindowssystems:__stdcall,__cdecl,PASCALThefirsttwopassargumentsfromrighttoleft,andthelastistopassargumentsfromlefttoright__stdcallisthestandardwayforWindowssystemstocallAPI__cdeclisthes
2、tandardinvocationofANSI-CTherearesomedifferencesbetween__stdcalland__cdecl:1.__stdcallreturnstheEBPandESPpointersfromthecalledfunction,inthiscasef_stcall()2.__cdeclreturnstheEBPandESPpointersbycallingfunctions,inthiscasef_cdecl()======================================================#include
3、"stdio.h""Void,__stdcall,f_stdcall(int,a,int,b){Intc;C=a+b;}Voidf_cdeclr(int,a,int,b){Intc;C=a+b;}(main){Int,left,=1,right,=2;F_stdcall(left,right);F_cdeclr(left,right);Printf("%d,%d",1,2);}========================================================================1:#include"stdio.h""2:=======
4、==============================================================Disassemblyofthef_stdcall()function=====================================================================3:,void,__stdcall,f_stdcall(int,a,int,b)4:{004012F0pushEBP//main.ebpparentfunctionpreservationbase004012F1movEBP,esp//opensta
5、ckf_stdcall.ebp004012F3,sub,esp,44h,//40h,int,C,4H004012F6pushebx//initializethe44hspace,11cycles004012F7pushESI004012F8pushEDI004012F9,lea,EDI,[ebp-44h]004012FC,MOV,ECX,11h00401301,MOV,eax,0CCCCCCCCh00401306,Rep,STOs,DWORD,PTR,[edi]5:intc;6:c=a+b;00401308moveax,DWORDPTR[ebp+8]a//+8//parame
6、ters,thereasonintheabovesaid0040130Baddeax,DWORDPTR[ebp+0Ch]B//parameters0040130E,MOV,DWORD,PTR,[ebp-4],andeax//aresavedinC7:}00401311popEDI00401312popESI00401313popebx00401314,MOV,esp,EBP00401316popEBP//main.ebprecovery00401317RET8//[ebp-8]-8================================================
7、=====================Disassemblyofthef_cdecl()function=====================================================================8:9:,void,f_cdeclr(int,a,int,b)10:{Thebase00401070pushEBP//savemain.ebp00401071movEBP,esp//madetorunstackf_cdecl.ebp00401073subESP,