如何在汇编语言代码中修复无限循环:

时间:2019-04-08 22:00:56

标签: assembly pep8-assembly

因此,我正在运行并创建用于家庭作业的程序,在该程序中我输入了两个字符,然后将其与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

0 个答案:

没有答案