내 코드는 사용자가 지정한 숫자를 기반으로 피보나치 시리즈의 요소를 생성하는 것입니다. 내가 입력 한 숫자가있을 때마다 출력하는 것 외에는 무한 루프가됩니다. 아니. 여기에 입력 내가 요소 .. 그리고 내가 피보나치 시퀀스를 인쇄하는 데 사용하는 절차입니다 : 필요한 경우 내 완벽하게 작성된 코드 내가 EMU8086 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
- 입니다
감사합니다,
에뮬레이터를 사용하여 코드를 단계별로 실행하지 않았습니까? – Jester
그래,하지만 난 아직 어디 초보자이며 그게 거의 내 첫 코드는 오류가 어디 있는지 찾을 수 없습니다 .. –