私のコードは、フィボナッチシリーズの要素をユーザーが指定した数値に基づいて生成するものです。何かを入力するたびに無限ループに入りますある種の。要素I入力...と、ここで私はフィボナッチ数列をプリントアウトするために使用する手順です:フィボナッチシリーズを生成中の無限ループasm8086
displayFib proc
MOV DX, 30h ; move value 30 hexadecimal to DX, which represents 0
call display
MOV AX, input
CMP AX, 0 ;if the input is 0 in hexadecimal ASCII value then jump to finish
JE finish_it
mov ah,9 ; formating - coma
mov dx,offset msg3
int 21h
;display the 1st term
MOV DX, 31h ; move value 31 hexadecimal to DX, which represents 1
call display
CMP input, 1 ;if the input is 1 in hexadecimal ASCII value then jump to finish
JE finish_it
MOV CX, input ;intializing counter, knowing that first 2 terms were displayed already
SUB CX, 2
repeat:
mov ah,9 ; formating - coma
mov dx,offset msg3
int 21h
MOV AX, fibn_2 ; calculating the n'th term of a sequence n = (n-1) + (n-2)
ADD AX, fibn_1
MOV fib, AX
MOV DX, fib
MOV saveCount, CX ;saving the state of the counter as it will be modified in the displayNum
call displayNum
;display the n'th term (current term)
MOV CX, saveCount ;restoring state of the counter
MOV AX, fibn_1 ; n-1 in the next round of a loop will be n-2
MOV fibn_2, AX
MOV AX, fib ;n'th term in the next round will be n-1
MOV fibn_1, AX
DEC CX ;decrementing counter
JNZ repeat ; loop until counter = 0
finish_it:
ret
displayFib endp
- 私はemu8086
- hereを使用しています
を必要に応じて、私の完全書かれたコードでありますおかげで、
コードをステップ実行するためにエミュレータを使用していませんか? – Jester
はい私は持っているが、私はエラーがまだ初心者で、それはほとんど私の最初のコードですどこに見つけることができません.. –