[org 0x0100]
jmp main
fibonacci:
push bp
mov bp , sp
push ax
push bx
mov ax , [bp+4]
cmp ax , 0
je exit0
cmp ax , 1
je exit1
sub sp , 2
mov ax , [bp+4]
dec ax
push ax
call fibonacci
sub sp , 2
mov ax , [bp+4]
dec ax
push ax
call fibonacci
pop ax
pop bx
add ax , bx
mov [bp+6] , ax
jmp exit2
exit0:
mov word [bp+6] , 0
jmp exit2
exit1:
mov word [bp+6] , 1
exit2:
pop bx
pop ax
pop bp
ret 2
main:
push ax
push 3
call fibonacci
pop ax
mov ax , 0x4c00
int
0x21
No comments
Post a Comment