我们现在正在考试汇编只考了一题~…注:重修…救救我们~…
请各位 大哥 大姐 帮忙
题目是 第一项为1 第二项 为1 第 3 项 为前两项 之和
例如 1 1 2 3 5 8 13 21 34 55
就是这样…用汇编编出来…
谢谢啊~~
代码初稿仅供参考,只显示小于1000的数值,结果如下:
1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 987
代码如下:
DSEG SEGMENT ‘DATA’
DSEG ENDS
SSEG SEGMENT STACK ‘STACK’
DW 100h DUP(?)
SSEG ENDS
CSEG SEGMENT ‘CODE’
;*******************************************
ASSUME CS:CSEG,DS:DSEG,ES:DSEG,SS:SSEG
START PROC FAR
; Store return address to OS:
PUSH DS
MOV AX, 0
PUSH AX
; set segment registers:
MOV AX, DSEG
MOV DS, AX
MOV ES, AX
init:
mov si,1
mov di,0
first:
add si,di
mov ax,si
cmp ax,1000d ;if(ax>=1000d)jmp exit
jge exit
call bindec
next:
add di,si
mov ax,di
cmp ax,1000d ;if(ax>=1000d)jmp exit
jge exit
call bindec
jmp first
;return to operating system:
exit:
RET
START ENDP
;subroutine to convert binary in AX to decimal
bindec proc near
cmp ax,100d
jl m_10d
m_100d: mov cx,100d
call decdiv
m_10d: cmp ax,10d
jl m_1d
mov cx,10d
call decdiv
m_1d: mov cx,1
call decdiv
blank:
xor al,al
mov al,20h ;add a space key
call printf
ret
bindec endp
;subroutine to divide number in AX by CX
decdiv proc near
mov dx,0
div cx
add al,30h ;convert to ASCII
call printf
mov ax,dx
ret
decdiv endp
;subroutine to printf
printf proc near
mov bx,0
mov ah,0eh ;display function
int 10h
ret
printf endp
;*******************************************
CSEG ENDS
END START ; set entry point.