当用户点击"输入"时,如何显示另一个提示?键?

时间:2015-04-09 01:58:54

标签: assembly lc3

我正在编写一个程序,最终将单词翻译成pig latin,到目前为止,我已将用户输入的字符存储到单独的内存位置(单词最多可以是19个字符)。

现在我想在用户点击回车键时打印另一个提示(在他们用英语输入他们的单词之后)。我看了一些例子,我看到他们在程序底部附近有一行说“NEWLINE .FILL x00A”。我知道这是输入密钥的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

0 个答案:

没有答案