首页 > 代码库 > 函数调用约定
函数调用约定
- __stdcall
-
__cdecl
- __fastcall
vc6.0:
int
__stdcall/__cdecl/__fastcall add(int x, int y)
{
return x+y;
}
void main()
{
add(2,3);
}
1.__stdcall:
1: int __stdcall add(int x, int y)
2: {
00401020 push
ebp
00401021 mov ebp,esp
00401023 sub esp,40h
00401026 push ebx
00401027 push esi
00401028 push edi
00401029 lea edi,[ebp-40h]
0040102C mov ecx,10h
00401031 mov eax,0CCCCCCCCh
00401036 rep stos dword ptr [edi]
3: return x+y;
00401038
mov eax,dword ptr [ebp+8]
0040103B add
eax,dword ptr [ebp+0Ch]
4: }
0040103E pop edi
0040103F pop esi
00401040 pop ebx
00401041 mov esp,ebp
00401043 pop ebp
00401044
ret 8
5:
6:
7: void main()
8: {
00401050 push ebp
00401051 mov ebp,esp
00401053 sub esp,40h
00401056 push ebx
00401057 push esi
00401058 push edi
00401059 lea edi,[ebp-40h]
0040105C mov ecx,10h
00401061 mov eax,0CCCCCCCCh
00401066 rep stos dword ptr [edi]
9: add(2,3);
00401068 push
3
0040106A push 2
0040106C call @ILT+0(add) (00401005)
10: }
00401071 pop
edi
00401072 pop esi
00401073 pop ebx
00401074 add esp,40h
00401077 cmp ebp,esp
00401079 call __chkesp (00401090)
0040107E mov esp,ebp
00401080 pop ebp
00401081 ret
00401005 jmp add (00401020)
2.__cdecl:
1: int __cdecl add(int x, int y)
2: {
00401020 push
ebp
00401021 mov ebp,esp
00401023 sub esp,40h
00401026 push ebx
00401027 push esi
00401028 push edi
00401029 lea edi,[ebp-40h]
0040102C mov ecx,10h
00401031 mov eax,0CCCCCCCCh
00401036 rep stos dword ptr [edi]
3: return x+y;
00401038
mov eax,dword ptr [ebp+8]
0040103B add
eax,dword ptr [ebp+0Ch]
4: }
0040103E pop edi
0040103F pop esi
00401040 pop ebx
00401041 mov esp,ebp
00401043 pop ebp
00401044
ret
5:
6:
7: void main()
8: {
00401050 push ebp
00401051 mov ebp,esp
00401053 sub esp,40h
00401056 push ebx
00401057 push esi
00401058 push edi
00401059 lea edi,[ebp-40h]
0040105C mov ecx,10h
00401061 mov eax,0CCCCCCCCh
00401066 rep stos dword ptr [edi]
9: add(2,3);
00401068 push
3
0040106A push 2
0040106C call @ILT+10(add) (0040100f)
00401071 add
esp,8
10: }
00401074
pop edi
00401075 pop esi
00401076 pop ebx
00401077 add esp,40h
0040107A cmp ebp,esp
0040107C call __chkesp (00401090)
00401081 mov esp,ebp
00401083 pop ebp
00401084 ret
0040100F jmp add (00401020)
3.__fastcall
1: int __fastcall add(int x, int y)
2: {
00401020 push
ebp
00401021 mov ebp,esp
00401023 sub esp,48h
00401026 push ebx
00401027 push esi
00401028 push edi
00401029 push
ecx
0040102A lea edi,[ebp-48h]
0040102D mov ecx,12h
00401032 mov eax,0CCCCCCCCh
00401037 rep stos dword ptr [edi]
0040103A mov dword ptr [ebp-8],edx
0040103D mov dword ptr [ebp-4],ecx
3: return x+y;
00401040
mov eax,dword ptr [ebp-4]
00401043 add
eax,dword ptr [ebp-8]
4: }
00401046 pop edi
00401047 pop esi
00401048 pop ebx
00401049 mov esp,ebp
0040104B pop ebp
0040104C ret
5:
6:
7: void main()
8: {
00401050 push
ebp
00401051 mov ebp,esp
00401053 sub esp,40h
00401056 push ebx
00401057 push esi
00401058 push edi
00401059 lea edi,[ebp-40h]
0040105C mov ecx,10h
00401061 mov eax,0CCCCCCCCh
00401066 rep stos dword ptr [edi]
9: add(2,3);
mov
edx,3
0040106D 00401072 call @ILT+15(add) (00401014)
10: }
00401077 pop
edi
00401078 pop esi
00401079 pop ebx
0040107A add esp,40h
0040107D cmp ebp,esp
0040107F call __chkesp (00401090)
00401084 mov esp,ebp
00401086 pop ebp
00401087 ret
00401014 jmp add (00401020)
====================================================================================
1: int __fastcall add(int x, int y, int z)
2: {
0040D480 push
ebp
0040D481 mov ebp,esp
0040D483 sub esp,48h
0040D486 push ebx
0040D487 push esi
0040D488 push edi
0040D489 push ecx
0040D48A lea edi,[ebp-48h]
0040D48D mov ecx,12h
0040D492 mov eax,0CCCCCCCCh
0040D497 rep stos dword ptr [edi]
0040D499 pop ecx
0040D49A mov dword ptr [ebp-8],edx
0040D49D mov dword ptr [ebp-4],ecx
3: return x+y+z;
0040D4A0
mov eax,dword ptr [ebp-4]
0040D4A3 add
eax,dword ptr [ebp-8]
0040D4A6 add eax,dword
ptr [ebp+8]
4: }
0040D4A9
pop edi
0040D4AA pop esi
0040D4AB pop ebx
0040D4AC mov esp,ebp
0040D4AE pop ebp
0040D4AF ret
4
5:
6:
7:
void main()
8: {
00401050
push ebp
00401051 mov ebp,esp
00401053 sub esp,40h
00401056 push ebx
00401057 push esi
00401058 push edi
00401059 lea edi,[ebp-40h]
0040105C mov ecx,10h
00401061 mov eax,0CCCCCCCCh
00401066 rep stos dword ptr [edi]
9: add(2,3,4);
push 4
0040106A mov edx,3
0040106F mov ecx,2
00401074 call @ILT+20(add) (00401019)
10: }
00401079 pop
edi
0040107A pop esi
0040107B pop ebx
0040107C add esp,40h
0040107F cmp ebp,esp
00401081 call __chkesp (00401090)
00401086 mov esp,ebp
00401088 pop ebp
00401089 ret
00401019 jmp add (0040d480)
函数调用约定