%OUT-------------------------------------------------------------------------
%OUT- Prints the Fibonacci series
%out- input: The no. of terms to which to print (maximum 18h)
%out- output: The series with the specified no. of terms
%out – author: Ayon and Ariyam
%OUT-------------------------------------------------------------------------
if1
include C:\Masm615\bin\macrolib.lby
endif
.model small
.stack
.data
ip db "Enter No. of terms to display: ","$"
op db " The Fibonacii Series: ","$"
err db " Input value > 18H !!","$"
.code
main proc
showmsg ip
input ;get the no. of terms to compute till
mov cl,al
cmp cl,18h
jbe ok
showmsg err
jmp xx
ok: showmsg op
mov bh,01h
space
output
space
output ;print 1st two terms
sub cl,02h ;1st 2-terms covered
mov ch,00h
mov bx,0001h ;hold f(i)
mov ax,0001h ;hold f(i-1), DX<-hold f(i-2)
lp: mov dx,ax
mov ax,bx
mov bx,ax
add bx,dx
push ax
push bx
space
output ;print MSDs
mov bh,bl
output ;print LSDs
pop bx
pop ax
dec cx
cmp cx,0000h
ja lp
xx: exit
main endp
end main
No comments:
Post a Comment
Do you think this information useful or was not up to the mark? Comment if you have any advices or suggestions about the post.