|
test.c 代码:
#include<stdio.h>
void hi(void)
{
printf("hi");
}
int main(int argc, char *argv[])
{
hi();
return 0;
}
//编译时没有任何优化,请教下面的汇编代码的理解,实在不知道具体是怎么生成的..
//我的环境gcc version 3.4.2 20041017 (Red Hat 3.4.2-6.fc3)+GNU gdb Red Hat Linux (6.1post-1.20040607.41rh)
main函数的汇编代码:
0x08048380 <main+0>: push %ebp
0x08048381 <main+1>: mov %esp,%ebp
0x08048383 <main+3>: sub $0x8,%esp
0x08048386 <main+6>: and $0xfffffff0,%esp
0x08048389 <main+9>: mov $0x0,%eax
0x0804838e <main+14>: add $0xf,%eax
0x08048391 <main+17>: add $0xf,%eax
0x08048394 <main+20>: shr $0x4,%eax
0x08048397 <main+23>: shl $0x4,%eax
0x0804839a <main+26>: sub %eax,%esp
0x0804839c <main+28>: call 0x8048368 <hi>
0x080483a1 <main+33>: mov $0x0,%eax
0x080483a6 <main+38>: leave
0x080483a7 <main+39>: ret
hi函数的汇编代码:
0x08048368 <hi+0>: push %ebp
0x08048369 <hi+1>: mov %esp,%ebp
0x0804836b <hi+3>: sub $0x8,%esp
0x0804836e <hi+6>: sub $0xc,%esp
0x08048371 <hi+9>: push $0x8048488
0x08048376 <hi+14>: call 0x80482b0 <_init+56>
0x0804837b <hi+19>: add $0x10,%esp
0x0804837e <hi+22>: leave
0x0804837f <hi+23>: ret |
|