📄 fib2.asm
字号:
data segment
flag dw 0
crlf1 db 13,10,'$'
input1 db 'Input Data:',13,10,'$'
fib dw 1,1,300 dup(?)
constant dw 1000,100,10,1
data ends
;***********************************************************
code segment
assume cs:code,ds:data
main proc far
start:
push ds
sub ax,ax
push ax
mov ax,data
mov ds,ax
call scren
call curs
first:
call input
call crlf
call fibs
call output
ret
;------------------------------------------------------------
input proc near
mov bx,0
lea dx,input1
mov ah,09h
int 21h
newchar:
mov ah,1
int 21h
sub al,30h
jl exit
cmp al,9d
jg exit
cbw
xchg ax,bx
mov cx,10d
mul cx
xchg ax,bx
add bx,ax
jmp newchar
exit:
ret
input endp
;------------------------------------------------------------
fibs proc near
mov cx,bx
sub cx,2
mov si,4
a1:
mov ax,fib[si-4]
add ax,fib[si-2]
mov fib[si],ax
add si,2
dec cx
jnz a1
ret
fibs endp
;------------------------------------------------------------
output proc near
push bx
push cx
push si
push di
mov flag,0
mov cx,4
lea si,constant
mov di,bx
dec di
shl di,1
mov bx,fib[di]
dec_div:
mov ax,bx
mov dx,0
div word ptr[si]
mov bx,dx
mov dl,al
cmp flag,0
jnz print1
cmp dl,0
je skip
mov flag,1
print1:
add dl,30h
mov ah,02h
int 21h
skip:
add si,2
loop dec_div
pop di
pop si
pop cx
pop bx
ret
output endp
;--------------------------------------------------------------
crlf proc near
lea dx,crlf1
mov ah,09h
int 21h
ret
crlf endp
;------------------------------------------------------------
scren proc near
mov ah,06h
mov bh,1eh
mov cx,0
mov dx,184fh
int 10h
ret
scren endp
;------------------------------------------------------------
curs proc near
mov ah,02
mov bh,0
mov dh,0
mov dl,0
int 10h
ret
curs endp
;------------------------------------------------------------
code ends
end start
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -