I have the following code:
#make_COM#
org 100h
A DD 13d
x DD 0d
y DD 1d
z DD 0d
mov dx,A
dec dx
xor cx,cx
while_begin:
cmp cx,dx
jge while_end
mov ax,x
mov bx,y
add ax,y
daa
mov z,ax
mov x, bx
mov bx,z
mov y, bx
inc cx
jmp while_begin
while_end:
mov ax,x
int 20h
This code should retrieve a number from the Fibonacci sequence with a given index in the A variable. But this code only works as long as variable A is less than or equal to 12
UPD: This is my current code, now it works for values of A greater than 12:
#make_COM#
org 100h
A DW 16
x DW 0d
y DW 1d
z DW 0d
mov dx,[A]
sub dx,2
xor cx,cx
while_begin:
cmp cx,dx
jge while_end
mov ax,[x]
add ax,[y]
mov [z],ax
mov ax,[y]
mov [x],ax
mov ax,[z]
mov [y],ax
inc cx
jmp while_begin
while_end:
mov ax,[x]
add ax,[y]
daa
mov [z],ax
mov ax,[y]
mov [x],ax
mov ax,[z]
mov [y],ax
int 20h
The problem was how I used the A variable and how I used its value. Proof of work