現在、LC-3 アセンブリ言語の課題に取り組んでいます。この割り当てでは、LC3 アセンブリ言語でプログラムを実装します。このプログラムは、ユーザー入力文字列を取得し、それらをユーザーにエコー バックして、文字列をパックします。プログラムはすでに完成していますが、2 つのサブルーチンを完成させる必要があります。Get String サブルーチンを実行していて、コードが無限ループに陥ってしまい、その理由がわかりません。それほど問題がなければ、誰かが私のコードを見て、問題を見つけられるかどうかを確認できますか? GETSTR サブルーチンを使用しているブランチと関係があると思いますが、よくわかりません。これまでの私のコードは次のとおりです。
enter code here .ORIG x3000
LEA R0, PROMPT ;Prompt for input
TRAP x22
LD R0, STRING ;Input a character string
JSR GETSTR
LD R0, NEWLIN ;Start a new output line
TRAP x21
LD R0, STRING ;Display the input string
TRAP x22
JSR PAKSTR ;Pack the character string
LD R0, NEWLIN ;Start a new output line
TRAP x21
LD R0, STRING
TRAP x24 ;Display the packed string
LD R0, NEWLIN
TRAP x21
TRAP x25 ;Halt
;Data
NEWLIN .FILL x0A
STRING .FILL x3100
PROMPT .STRINGZ "Enter a character string, hit ENTER> "
;------------------------------------------------------------
GETSTR ;Input a character string from the keyboard to memory
;Each input character is echoed at the console
;End of input is signalled by NEWLN (Enter key) x0A
;The end of the string in memory is marked by x0000
;Parameters - R0 : address of the string
ST R7, GET_7
JUMP ADD R2, R0,0
ADD R2, R2, 1
TRAP x20
BRnp JUMP
TRAP x21
LD R7, GET_7
RET
GET_7 .BLKW 1
;---------------------------------------------------------------------
PAKSTR ;Create a packed string from a 0-terminated character string
;The packed string overwrites the original string in memory
;The format of a packed string is described in Table A.2, p543
;Parameters - R0 : address of the string
ST R7, PAK_7
BACK ADD R0, R0, R0
TRAP x24
BRnp BACK
LD R7, PAK_7
RET
PAK_7 .BLKW 1
.END