#include <stdio.h>
int test (int a, int b)
{
return (a + b);
}
int main()
{
int a = 10;
int b = 20;
test (10, 20);
return (0);
}
参数2(20) |
参数1(10) |
函数返回地址(0x80483ea) |
旧有的 EBP |
movl %ebp, %esp
popl %ebp
.section .data
precision:
.byte 0x7f, 0x00
.section .bss
.lcomm result, 4
.section .text
.global _start
_start:
nop
finit
fldcw precision
pushl $10
call area
addl $4, %esp
movl %eax, result
movl $1, %eax
movl $0, %ebx
int $0x80
area:
pushl %ebp #旧有EBP保存
movl %esp, %ebp #EBP在此作用为承上启下,即可向上寻址传递参数,亦可向下寻址局部变量
subl $4, %esp #为局部变量开辟空间
fldpi
filds 8(%ebp)
fmul %st(0), %st(0)
fmulp %st(0), %st(1)
fstps -4(%ebp)
movl -4(%ebp), %eax
movl %ebp, %esp #弹出局部变量
popl %ebp #恢复旧有EBP
ret #子函数返回到主函数中
欢迎光临 曲径通幽论坛 (http://www.groad.net/bbs/) | Powered by Discuz! X3.2 |