.model
.data

yea db "y$"
num db 100 dup(' ')
input1 db "Enter number of integers: $"
output db "The Fibonacci series: $"
choice db "so far you can only input up to 11$"
temp db ?
temp2 db ?
ctr db 0
i db 0
n db 10
n1 db 100
back1 db ?

.code
main proc far

mov ax, @data
mov ds, ax
	
	mov ax, 600h
	mov bh, 07h
	mov ch, 0h
	mov cl, 0h
	mov dh, 18h
	mov dl, 4fh
	int 10h
	
	
; shadow
	mov ax, 600h
	mov bh, 02h
	mov ch, 0bh
	mov cl, 1h
	mov dh, 0dh
	mov dl, 25h
	int 10h
	
; white
	mov ax, 600h
	mov bh, 0f0h
	mov ch, 0ah
	mov cl, 2h
	mov dh, 0ch
	mov dl, 26h
	int 10h
	
; white
	mov ax, 600h
	mov bh, 0f0h
	mov ch, 0ah
	mov cl, 21h
	mov dh, 0ch
	mov dl, 26h
	int 10h
	
; black
	mov ax, 600h
	mov bh, 00h
	mov ch, 0ah	
	mov cl, 28h
	mov dh, 0dh
	mov dl, 4eh
	int 10h
	
;white
	mov ax, 600h
	mov bh, 00h
	mov ch, 0bh
	mov cl, 29h
	mov dh, 0ch
	mov dl, 4dh
	int 10h
	
;white
	mov ax, 600h
	mov bh, 0f0h
	mov ch, 0ah
	mov cl, 29h
	mov dh, 0ch
	mov dl, 4dh
	int 10h
	
begin:
	lea bx, num
	mov si, 0
	lea di, temp
	
	mov ah, 2
	mov bh, 0
	mov dh, 0bh
	mov dl, 07h
	int 10h
	
	
;print value
	mov ah, 9
	lea dx, input1
	int 21h
	
lbl_back:
	
	cmp SI, 1
	je begin
	
input:
	mov ah, 1
	int 21h
	mov [bx+di], al
	cmp al, 08h
	je backspace
	cmp al, 0Dh
	je outputcursor
	mov [bx+si], al
	inc si
	inc ctr
	jmp input
	
backspace:
	mov ah, 2
	mov dl, 20h
	int 21h
	dec di
	mov back1, 27h
	add back1, di
	mov ah, 2h
	mov bh, 0h
	mov dh, 09h
	mov dl, back1
	int 10h
	cmp back1, 32
	mov si, 1
	je lbl_back
	jmp input
	
outputcursor:
	
	mov ah, 2
	mov bh, 0
	mov dh, 0ah
	mov dl, 2Dh
	int 10h
	;print the value
	mov ah, 9
	lea dx, output
	int 21h

;output
	
	mov ah, 2
	mov bh, 0
	mov dh, 0ch
	mov dl, 2Dh
	int 10h
	cmp si, 1
	je _1digit
	
_2digit:
	mov al, [bx+0]
	sub al, 48
	mul n
	mov dl, [bx+1]
	sub dl, 48
	add al, dl
	jmp print
	
_1digit:
	mov al, [bx+0]
	sub al, 48
	
print:
	mov ctr, al
	mov al, 1
	mov bl, 1
	mov cl, 0
	
beginloop:
	cmp ctr, 0
	jle relayexit
	mov al, bl
	mov bl, cl
	add al, bl
	mov temp, al
	mov cl, temp
	cmp temp, 10
	jge layat
	add temp, 48
	
	;mov ah, 2
	;mov dl, 20h
	;int 21h
	
	;mov ah, 2
	;mov dl, temp
	;int 21h
	;dec ctr
	;jmp beginloop
	
next:
	mov ah, 2
	mov dl, temp
	int 21h
	
space:
	mov ah, 2
	mov dl, 20h
	int 21h
	
	dec ctr
	jmp beginloop
	
layat:
	cmp temp, 100
	jge filter3
	
filter2:
	mov ax, 0
	mov al, temp
	div n
	
	mov temp, ah
	mov temp2, al
	
	mov ah, 2
	mov dl, temp2
	add dl, 48
	int 21h
	
	mov ah, 2
	mov dl, temp
	add dl, 48
	int 21h
	
	;space
	mov ah, 2
	mov dl, 20h
	int 21h
	
	dec ctr
	jmp beginloop
	
relayexit:
	jmp short exit
	
relay:
	jmp beginloop
	
filter3:
	mov ax, 0
	mov al, temp
	div n1
	
	mov temp, ah
	mov temp2, al
	
	mov ah, 2
	mov dl, temp2
	add dl, 48
	int 21h
	
filter4:
	mov ax, 0
	mov al, temp
	div n
	
	mov temp2, al
	
	mov ah, 2
	mov dl, temp2
	add dl, 48
	int 21h
	
	mov ah, 2
	mov dl, temp
	int 21h
	dec ctr
	jmp beginloop
	
	
exit:
	
	mov ah, 2
	mov bh, 0
	mov dh, 28h
	mov dl, 1h
	int 10h	

	mov ah, 4ch
	int 21h
	
main endp
end main
