阶乘函数 注意事项

.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

猜你喜欢

转载自www.cnblogs.com/xpylovely/p/11100344.html