最終的に単語を豚のラテン語に翻訳するプログラムを書いていますが、これまでのところ、ユーザー入力の文字を別々のメモリ位置に保存しました (単語は最大 19 文字まで)。
ここで、ユーザーがエンター キーを押したときに別のプロンプトを出力したいと考えています (英語で単語を入力し終わった後)。いくつかの例を見てきましたが、プログラムの一番下に "NEWLINE .FILL x00A" という行があることがわかりました。これが Enter キーの ASCII コードであることは理解していますが、「Enter」を押した後に別のプロンプトを表示する必要があることをプログラムに伝える方法がわかりません。ヒントやアイデアをいただければ幸いです。
.ORIG x3000
START ST R1,SAVER1
ST R2,SAVER2
ST R3,SAVER3
LEA R1,PROMPT ; loading the address of the first character of prompt
LOOP LDR R0,R1,#0 ; loading the first character into R0
BRz INPUT ; if at 0, or at the end of the string, (.STRINGZ initializes length+1 memory locations,
; last location being 0), then go to instruction labeles "INPUT"; else go to next instructio
L2 LDI R3,DSR ; loading the display status register into R3
BRzp L2 ; if display status register is not clear (meaning monitor is still processing char), then load DSR again
STI R0,DDR ; store R0 into DDR's memory location
ADD R1,R1,#1 ; increment prompt address so that we can move through the string until the end
BRnzp LOOP ; this will go to the LOOP instruction no matter what
LEA R4,ENGLWORD
INPUT GETC ; now that user has typed, read char into R0
OUT ; write char in R0 to console
STR R0,R4,#0
ADD R4,R4,#1
BRnzp INPUT
LD R1,SAVER1 ; restore R1 to original value
LD R2,SAVER2 ; restore R2 to original value
LD R3,SAVER3 ; restore R3 to original value
SAVER1 .BLKW 1 ; allocates 1 memory location for SAVER1
SAVER2 .BLKW 1 ; allocates 1 memory location for SAVER2
SAVER3 .BLKW 1 ; allocates 1 memory location for SAVER3
ENGLWORD .BLKW 19
ENTER .FILL x0A
PROMPT .STRINGZ "English word: " ; initializes a sequence of stringLength+1 memory locations to hold string
DSR .FILL xFE04
DDR .FILL xFE06
KBSR .FILL xFE00
KBDR .FILL xFE02
HALT
.END