Assembly asm代码问题,计算阶乘

Assembly asm代码问题,计算阶乘,assembly,x86,factorial,Assembly,X86,Factorial,给定一个数字,这个程序计算阶乘,但它不再适用于大于9的数字 .section .data .section .text .globl _start _start: pushl $10 movl %eax, %ebx call func addl $4, %esp movl %eax, %ebx movl $1, %eax int $0x80 .type func,@function func: pushl %ebp movl %esp, %ebp movl

给定一个数字,这个程序计算阶乘,但它不再适用于大于9的数字

.section .data
.section .text
.globl _start

_start:
pushl $10
movl %eax, %ebx

call func
addl $4, %esp  
movl %eax, %ebx

movl $1, %eax
int $0x80

.type func,@function

func:
    pushl %ebp
    movl %esp, %ebp
    movl 8(%ebp), %eax
    cmpl $1, %eax
    je fim_loop
    decl %eax
    pushl %eax
    call func
    movl 8(%ebp), %ebx
    imull %ebx, %eax

    fim_loop:
        movl %ebp, %esp
        popl %ebp
        ret

编译并运行程序后,echo$?应该返回结果,但这返回的是0而不是正确的结果,有人知道这段代码有什么问题吗?

似乎程序的退出值大小有限,我认为最大值是255,所以我应该使用sys_write或libc中的一些东西