function calling convention

Source: Internet
Author: User

    1. __stdcall
    2. __cdecl
    3. __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);
movedx,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);
Push4
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)


function calling convention

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.