阶乘函数 注意事项

.section .data
.section .text
.global _start
.global fun
_start:
pushl $5
call fun
addl $4, %esp
movl %eax, %ebx
movl $1, %eax
int $0x80
.type fun, @function
fun:
pushl %ebp
movl %esp, %ebp
movl 8(%ebp), %eax
cmpl $1, %eax
je end_fun
decl %eax
pushl %eax
call fun
movl 8(%ebp), %ebx
imull %ebx, %eax  //为什么不直接用%ebx,返回值始终存储再%eax中
end_fun:
movl %ebp, %esp
popl %ebp
ret

posted @ 2019-06-27 23:32  MoonXu  阅读(159)  评论(0编辑  收藏  举报