; CS2011, A Term 1999
; Prof. Sergio A. Alvarez

title Recursive Factorial

.model small
.stack

.data
n dw 5

.code
main proc
.startup
   push n
   call factorial
.exit
main endp

factorial proc
   push bp
   mov bp,sp
   push bx
   mov bx,[bp+4]
   cmp bx,0
   jnz recurse
      mov ax,1
   jmp done
   recurse:
      mov ax,bx
      dec ax
      push ax
      call factorial
      mul bl
   done:
      pop bx
      pop bp
      ret 2
factorial endp

end

