[ASM] 递归计算阶乘

 

    org 100h
    jmp start
    
stack:
    db 
256  dup( 0 )
topofstack:
    db 
0

; add your code here
start:
    mov ax, cs
    mov ds, ax
    
    mov ss, ax
    mov sp, topofstack
    
    mov ax, 
0x0003
    push ax
    call f
    pop ax
    hlt
    
f:
    push bp
    push ax
    
    mov bp, sp
    mov ax, [bp
+ 6 ]
    cmp ax, 
0x0001
    je exit
    
    dec ax
    push ax
    call f
    pop ax
    
    mul [bp
+ 6 ]
    
exit:
    mov [bp
+ 6 ], ax
    pop ax
    pop bp
    ret

 

你可能感兴趣的:([ASM] 递归计算阶乘)