用汇编语言求斐波那契数列第K项

来源:学生作业帮助网 编辑:六六作业网 时间:2024/11/23 18:43:24
用汇编语言求斐波那契数列第K项用汇编语言求斐波那契数列第K项用汇编语言求斐波那契数列第K项stacksegmentstack''stack''dw32dup(0)stackendsdatasegmentA

用汇编语言求斐波那契数列第K项
用汇编语言求斐波那契数列第K项

用汇编语言求斐波那契数列第K项
stack segment stack 'stack'
dw 32 dup(0)
stack ends
data segment
A DB 8 DUP(0)
OBF DB 3,0,3 DUP(0)
data ends
code segment
begin proc far
assume ss:stack,cs:code,ds:data
push ds
sub ax,ax
push ax
mov ax,data
mov ds,ax
MOV DX,OFFSET OBF
MOV AH,10
INT 21H
MOV AL,OBF+1
CMP AL,1
JA NEX2
MOV CL,OBF+2
AND CL,0FH
JMP NEX1
NEX2:MOV AL,OBF+2
AND AL,0FH
MOV CL,10
MUL CL
MOV AH,OBF+3
AND AH,0FH
ADD AL,AH
MOV CL,AL
NEX1:MOV CH,0
CMP CX,3
JB ONE
SUB CX,2
MOV AX,1
MOV BX,1
AGAIN:MOV DX,AX
ADD AX,BX
MOV BX,DX
LOOP AGAIN
MOV BX,7
MOV A[BX],'$'
MOV CX,10
AG:MOV DX,0
DIV CX
OR DL,30H
DEC BX
MOV A[BX],DL
AND AX,AX
JNZ AG
SUB BX,2
MOV WORD PTR A[BX],0A0DH
MOV DX,BX
ADD DX,OFFSET A
MOV AH,9
INT 21H
JMP LAST
ONE:MOV DL,0AH
MOV AH,2
INT 21H
MOV DL,31H
MOV AH,2
INT 21H
LAST:RET
begin endp
code ends
end begin

根据n值,计算斐波那契数,并存放在一连续数组中已知:Fib(1)=1,Fib(2)code segment assume cs:code ds:code start: mov ax,cs mov ds,ax lea