Write in LC-2 assembler, using the device registers introduced in chapter 8, a program that reads characters from the terminals and echoes input lower-case letters back to the monitor. All other charcters are ignored.
This answer was provided by Bryan Powell and slighted edited by me.
START LDI R1,KBSR ; Test the status register
BRzp START
LDI R0,KBDR ; Read the character into R0
LD R1,aNEG
ADD R1,R1,R0
BRn START ; Don't print if < 'a'
LD R1,zNEG
ADD R1,R1,R0
BRp START ; Don't print if > 'z'
ECHO LDI R1,CRTSR ; Print it here
BRzp ECHO
STI R0,CRTDR
BR START
KBSR .FILL xF400
KBDR .FILL xF401
CRTSR .FILL xF3FC
CRTDR .FILL xF3FF
aNEG .FILL #-97 ; -'a'
zNEG .FILL #-122 ; -'z'
.END