所以我正在运行并为家庭作业创建这个程序,我在其中输入几个字符,然后将其与 7 进行比较,并计算输入了多少个 7,直到 # 符号结束程序。出于某种原因,我不知何故陷入了这个无限循环。我觉得我的逻辑没问题,但我根本不明白是什么导致它陷入无限循环。
main: LDX 0, i ;load 0 to acc
STX charCoun, d ;store 0 to charcount
while: CHARI charIn, d ;get char input
LDA charIn, d ;load input to acc
CPA 35, i ;compare to char #
BREQ endWhile ;if it equals to # branch to end while
CPA 55, i ;compare to char 7
BREQ count7 ;branch to count 7 if equal to char 7
BR while ;otherwise loop