gdb) set disassembly-flavor intel
(gdb) disass main
Dump of assembler code for function main:
0x08048461 <+0>: push ebp
0x08048462 <+1>: mov ebp,esp
0x08048464 <+3>: and esp,0xfffffff0
0x08048467 <+6>: sub esp,0x20
0x0804846a <+9>: mov DWORD PTR [esp+0x1c],0x804842d
0x08048472 <+17>: mov DWORD PTR [esp+0x4],0x3
0x0804847a <+25>: mov DWORD PTR [esp],0x5
0x08048481 <+32>: mov eax,DWORD PTR [esp+0x1c]
0x08048485 <+36>: call eax
0x08048487 <+38>: mov DWORD PTR [esp+0x4],eax
0x0804848b <+42>: mov DWORD PTR [esp],0x80485b0 // %d\n
0x08048492 <+49>: call 0x8048300 <printf@plt>
0x08048497 <+54>: mov DWORD PTR [esp+0x1c],0x8048439
0x0804849f <+62>: mov DWORD PTR [esp+0x4],0x3
0x080484a7 <+70>: mov DWORD PTR [esp],0x5
0x080484ae <+77>: mov eax,DWORD PTR [esp+0x1c]
0x080484b2 <+81>: call eax
0x080484b4 <+83>: mov DWORD PTR [esp+0x4],eax
0x080484b8 <+87>: mov DWORD PTR [esp],0x80485b0
0x080484bf <+94>: call 0x8048300 <printf@plt>
0x080484c4 <+99>: mov DWORD PTR [esp+0x1c],0x8048445
0x080484cc <+107>: mov DWORD PTR [esp+0x4],0x3
---Type <return> to continue, or q <return> to quit---
0x080484d4 <+115>: mov DWORD PTR [esp],0x5
0x080484db <+122>: mov eax,DWORD PTR [esp+0x1c]
0x080484df <+126>: call eax
0x080484e1 <+128>: mov DWORD PTR [esp+0x4],eax
0x080484e5 <+132>: mov DWORD PTR [esp],0x80485b0
0x080484ec <+139>: call 0x8048300 <printf@plt>
0x080484f1 <+144>: mov DWORD PTR [esp+0x1c],0x8048454
0x080484f9 <+152>: mov DWORD PTR [esp+0x4],0x3
0x08048501 <+160>: mov DWORD PTR [esp],0x5
0x08048508 <+167>: mov eax,DWORD PTR [esp+0x1c]
0x0804850c <+171>: call eax
0x0804850e <+173>: mov DWORD PTR [esp+0x4],eax
0x08048512 <+177>: mov DWORD PTR [esp],0x80485b0
0x08048519 <+184>: call 0x8048300 <printf@plt>
0x0804851e <+189>: leave
0x0804851f <+190>: ret
End of assembler dump.
(gdb) disass div
Dump of assembler code for function div:
0x08048439 <+0>: push ebp
0x0804843a <+1>: mov ebp,esp
0x0804843c <+3>: mov eax,DWORD PTR [ebp+0x8]
0x0804843f <+6>: cdq
0x08048440 <+7>: idiv DWORD PTR [ebp+0xc]
0x08048443 <+10>: pop ebp
0x08048444 <+11>: ret
End of assembler dump.
(gdb) disass mul
Dump of assembler code for function mul:
0x0804842d <+0>: push ebp
0x0804842e <+1>: mov ebp,esp
0x08048430 <+3>: mov eax,DWORD PTR [ebp+0x8]
0x08048433 <+6>: imul eax,DWORD PTR [ebp+0xc]
0x08048437 <+10>: pop ebp
0x08048438 <+11>: ret
End of assembler dump.
(gdb) disass add
Dump of assembler code for function add:
0x08048454 <+0>: push ebp
0x08048455 <+1>: mov ebp,esp
0x08048457 <+3>: mov eax,DWORD PTR [ebp+0xc]
0x0804845a <+6>: mov edx,DWORD PTR [ebp+0x8]
0x0804845d <+9>: add eax,edx
0x0804845f <+11>: pop ebp
0x08048460 <+12>: ret
End of assembler dump.
(gdb) disass min
Dump of assembler code for function min:
0x08048445 <+0>: push ebp
0x08048446 <+1>: mov ebp,esp
0x08048448 <+3>: mov eax,DWORD PTR [ebp+0xc]
0x0804844b <+6>: mov edx,DWORD PTR [ebp+0x8]
0x0804844e <+9>: sub edx,eax
0x08048450 <+11>: mov eax,edx
0x08048452 <+13>: pop ebp
0x08048453 <+14>: ret
End of assembler dump.
#include <stdio.h>
int (*funcptr) (int, int);
int mul(int a1,int b1);
int div(int a2,int b2);
int min(int a3,int b3);
int add(int a4,int a4);
int main(int argc,char *argv[])
{
funcptr = mul;
printf(“%d\n”,funcptr(5,3));
funcptr = div;
printf(“%d\n”,funcptr(5,3));
funcptr = min;
printf(“%d\n”,funcptr(5,3));
funcptr = add;
printf(“%d\n”,funcptr(5,3));
return 0;
}
int div(int a1,int b1)
{
return a1/b1;
}
int add(int a4,int b4)
{
return a4+b4;
}
int min(int a3,int b3)
{
return a3-b3;
}
int mul(int a1,int b1)
{
return a1*b1;
}