l 求出前20个斐波那契数,斐波那契数的定义为:
f0=0,f1=1,fn+2=fn+fn+1
今天考试,谁在线的快帮忙回下~!谢谢啦
~~~~~~SOS
.MODEL Small
.DATA
X DW 0
Y DW 1
.STACK 200H
.CODE
MAIN PROC FAR
MOV AX,@DATA
MOV DS,AX
MOV AX,X
CALL OUTPUT
CALL SPACE1
MOV AX,Y
CALL OUTPUT
MOV CX,18
L: CALL SPACE1
MOV AX,X
MOV BX,Y
ADD AX,BX
MOV X,BX
MOV Y,AX
CALL OUTPUT
LOOP L
MOV AH,4CH
INT 21H
MAIN ENDP
;DX要输出的数
OUTPUT PROC NEAR
PUSH CX
CMP AX,0
JNZ NOUT
MOV DL,30H
MOV AH,02H
INT 21H
JMP XR
NOUT:MOV BX,10
MOV CX,5
LO1: MOV DX,0
DIV BX
PUSH DX
LOOP LO1
MOV CX,5
MOV BX,0
LO2: POP DX
CMP DX,0
JNZ XO3
CMP BX,0
JZ XO6
XO3: ADD DX,30H
MOV AH,02H
INT 21H
MOV BX,1
XO6: LOOP LO2
XR: POP CX
RET
OUTPUT ENDP
SPACE1 PROC NEAR
MOV DL,20H
MOV AH,02H
INT 21H
RET
SPACE1 ENDP
END