汇编计算阶乘(MIPS)

初学汇编,不规范的地方望提出

.data     
    msg: .asciiz"Enter a Number "
    msg1: .asciiz"The result is: "
.text                   
main:                    
    li $v0,4             
    la $a0,msg           
    syscall              
    li $v0,5              
    syscall               
    move $s0,$v0          
    li $v0,1              
factorial:              
    mult $s0,$v0          
    mfhi $t2            
    mflo $t3             
    sll $t2,$t2,8        
    add $v0,$t2,$t3      
    sub $s0,$s0,1         
    bgt $s0,1,factorial   
done:                    
    move $t4,$v0
    li $v0,4
    la $a0,msg1
    syscall
    move $a0,$t4         
    li $v0,1              
    syscall              
li     $v0, 10           
syscall                 

你可能感兴趣的:(汇编)