[org 0x0100]
jmp main
factorial:
push bp
mov bp , sp
push ax
push dx
cmp word [bp+4] , 1
je exit
sub sp , 2
mov ax , [bp+4]
dec ax
push ax
call factorial
pop ax
mov dx , 0
mul word [bp+4]
mov [bp+6] , ax
jmp exit2
exit:
mov word [bp+6] , 1
exit2:
pop dx
pop ax
pop bp
ret 2
main:
sub sp , 2
push 7
call factorial
pop ax
mov ax , 0x4c00
int 0x21
No comments
Post a Comment