0
這顯示沒有錯誤,但是當用輸入0運行時,它顯示的輸出是「0 1 1 b - 」 其中輸出應該像「0 1 1 2 3 5 ....」 ......「下面是代碼Fibonacci in Assembly Language
.model small
.stack 100h
.data
cons dw 1
num db 0
result db 10 dup('$'),0ah,0dh
.code
input proc ;Input procedure Starts
xor ax,ax
xor bx,bx
xor cx,cx
xor dx,dx
mov cx,-1
tag1:
mov ah,01
int 21h
mov bl,al
sub bx,48
push bx
inc cx
cmp al,0dh
jne tag1
pop bx
tag2:
pop bx
mov ax,cons
mul bx
add num,al
mov ax,cons
mov dx,10
mul dx
mov cons,ax
loop tag2
ret
input endP ; Input procedure Ends
fabio proc ; Procedure to find out the sequence and print it
mov ax,0
mov bx,0
mov cx,5
mov dx,0
mov al,num
mov bl,num
add bx,1
add ax,48
add bx,48
mov dx,ax
mov ah,02
int 21h ; printing 1 of the 2 first numbers
mov dx,0
mov dx,bx
mov ah,02
int 21h
mov al,num
mov bl,num
add bx,1
tag4:
add al,bl ; the problem lies from somewhere here to the code below
mov num,al
mov bl,al
add al,1
mov dx,0
add num,48
mov dl,num
mov ah,02
int 21h
loop tag4
ret
fabio endP
proc main
mov ax,@data
mov ds,ax
call input
call fabio
mov ax,4c00h
int 21h
end main
main endP
學習使用調試器,使用更好的標籤名稱並添加註釋。 – Jester