为想明白的函数指针
int *max(int a,int b){ if(a>b) return &a;
else return &b;
}
void main()
{
int * p = max(40,50);
int * q = max(10,20);
printf("%d \n",(*q) + (* p) );
printf("%d \n",(*max(79,89))+(*max(10,40)));
} push ebp
.text:00401091 mov ebp, esp
.text:00401093 sub esp, 44h
.text:00401096 push ebx
.text:00401097 push esi
.text:00401098 push edi
.text:00401099 push 32h ; b
.text:0040109B push 28h ; a
.text:0040109D call j__max
.text:004010A2 add esp, 8
.text:004010A5 mov , eax
.text:004010A8 push 46h ; b
.text:004010AA push 3Ch ; a
.text:004010AC call j__a1
.text:004010B1 add esp, 8
.text:004010B4 mov eax,
.text:004010B6 mov ecx,
.text:004010B9 add eax,
.text:004010BB push eax
.text:004010BC push offset format ; "%d \n"
.text:004010C1 call _printf
.text:004010C6 add esp, 8
.text:004010C9 pop edi
.text:004010CA pop esi
.text:004010CB pop ebx
.text:004010CC mov esp, ebp
.text:004010CE pop ebp
.text:004010CF retn
.text:004010CF _main endp
int *__cdecl j__a1(int a, int b)
.text:0040100F j__a1 proc near ; CODE XREF: _main+1Cp
.text:0040100F jmp _a1
.text:0040100F j__a1 endp
.text:0040100F
.text:0040100F ; ---------------------------------------------------------------------------
.text:00401014 db 1Ch dup(0CCh)
.text:00401030
.text:00401030 ; =============== S U B R O U T I N E =======================================
.text:00401030
.text:00401030 ; Attributes: bp-based frame
.text:00401030
.text:00401030 ; int *__cdecl max(int a, int b)
.text:00401030 _max proc near ; CODE XREF: j__maxj
.text:00401030
.text:00401030 a = dword ptr 8
.text:00401030 b = dword ptr 0Ch
.text:00401030
.text:00401030 push ebp
.text:00401031 mov ebp, esp
.text:00401033 sub esp, 40h
.text:00401036 push ebx
.text:00401037 push esi
.text:00401038 push edi
.text:00401039 mov eax,
.text:0040103C cmp eax,
.text:0040103F jle short loc_401046
.text:00401041 lea eax,
.text:00401044 jmp short loc_401049
.text:00401046 ; ---------------------------------------------------------------------------
.text:00401046
.text:00401046 loc_401046: ; CODE XREF: _max+Fj
.text:00401046 lea eax,
.text:00401049
.text:00401049 loc_401049: ; CODE XREF: _max+14j
.text:00401049 pop edi
.text:0040104A pop esi
.text:0040104B pop ebx
.text:0040104C mov esp, ebp
.text:0040104E pop ebp
.text:0040104F retn
.text:0040104F _max endp
.text:0040104F
.text:0040104F ; ---------------------------------------------------------------------------
.text:00401050 db 10h dup(0CCh)
.text:00401060
.text:00401060 ; =============== S U B R O U T I N E =======================================
.text:00401060
.text:00401060 ; Attributes: bp-based frame
.text:00401060
.text:00401060 ; int *__cdecl a1(int a, int b)
.text:00401060 _a1 proc near ; CODE XREF: j__a1j
.text:00401060
.text:00401060 a = dword ptr 8
.text:00401060 b = dword ptr 0Ch
.text:00401060
.text:00401060 push ebp
.text:00401061 mov ebp, esp
.text:00401063 sub esp, 40h
.text:00401066 push ebx
.text:00401067 push esi
.text:00401068 push edi
.text:00401069 mov eax,
.text:0040106C cmp eax,
.text:0040106F jle short loc_401076
.text:00401071 lea eax,
.text:00401074 jmp short loc_401079
.text:00401076 ; ---------------------------------------------------------------------------
.text:00401076
.text:00401076 loc_401076: ; CODE XREF: _a1+Fj
.text:00401076 lea eax,
.text:00401079
.text:00401079 loc_401079: ; CODE XREF: _a1+14j
.text:00401079 pop edi
.text:0040107A pop esi
.text:0040107B pop ebx
.text:0040107C mov esp, ebp
.text:0040107E pop ebp
.text:0040107F retn
.text:0040107F _a1 endp
想明白了,结贴/:12 看了有收获 /:L 给点中文……新手更明白……
页:
[1]