now i just need to have ax=bl+al, al=bl, and bl=ax, any idea on how to do that?
For al=bl and bl=al, you can use the exchange instruction:
xchg al,bl
except that you need to use 16 bit registers in order to go up to fib(24) (46368), so that would be:
add ax,bx
xchg ax,bx
Optionally, you could do the xchg first.
xchg ax,bx
add ax,bx
You'll need to use a register other than ax, since it will be needed to convert binary to decimal and for the int 21 calls.
In case you're not already doing this, you can use debug.com as a crude assembler by redirecting its input to read it's commands from a text file. The commands will enter instructions and data, then use "n" to give a name of the program to write, "rcx" to set cx to the number of bytes to write, then "w" command to write the program. "q" exits debug.
This allows you to edit the text file until you get the program to work, as opposed to entering commands directly with debug. Here is an example input file for Fibonacci program named fib16.in:
a100
sub sp,+10
mov bp,sp
mov byte ptr [bp+05],0d
mov byte ptr [bp+06],0a
mov byte ptr [bp+07],24
mov di,ffff
mov si,0001
mov cx,0019
mov bx,000a
xchg si,di
add si,di
mov bp,sp
add bp,+05
mov ax,si
dec bp
xor dx,dx
div bx
or dl,30
mov [bp+00],dl
cmp bp,sp
jnz 0128
mov ah,09
mov dx,sp
int 21
loop 011d
add sp,+10
mov ax,4c00
int 21
nfib16.com
rcx
47
w
q
To "assemble" this file enter the command:
debug <fib16.in
This will create a program called fib16.com, which you can then run with or without debug.
Here is a regular assembly version of the same program:
; Fibonacci
.model tiny,c
.code
org 0100h
main proc far
sub sp,16 ;allocate space for string
mov bp,sp
mov byte ptr 5[bp],00dh ;bp[5] = 00d,00a,'$'
mov byte ptr 6[bp],00ah
mov byte ptr 7[bp],024h
mov di,0ffffh ;fib(-2)
mov si,00001h ;fib(-1)
mov cx,25 ;loop: fib(0) to fib(24)
mov bx,10 ;used to convert to string
main0: xchg si,di ;fib step
add si,di
mov bp,sp ;display si
add bp,5
mov ax,si
main1: dec bp
xor dx,dx
div bx
or dl,030h
mov [bp],dl
cmp bp,sp
jne main1
mov ah,009h
mov dx,sp
int 21h
loop main0 ;loop till done
add sp,16 ;restore sp
mov ax,04c00h ;exit
int 21h
main endp
end main