START   ST      R1,SaveR1     ; Save registers needed
        ST      R2,SaveR2     ; by this routine
        ST      R3,SaveR3
;
        LD      R2,Newline
L1      LDI     R3,CRTSR
        BRzp    L1            ; Loop until Monitor is ready
        STI     R2,CRTDR      ; Move cursor to new clean line
;
        LEA     R1,Prompt     ; Starting address of prompt string
Loop    LDR     R0,R1,#0      ; Write the input prompt
        BRz     Input         ; End of prompt string
L2      LDI     R3,CRTSR
        BRzp    L2            ; Loop until Monitor is ready
        STI     R0,CRTDR      ; Write next prompt character
        ADD     R1,R1,#1      ; Increment Prompt pointer
        BR      Loop          ; Get next prompt character
;
Input   LDI     R3,KBSR       ; 
        BRzp    Input         ; Poll until a character is typed
        LDI     R0,KBDR       ; Load input character into R0
L3      LDI     R3,CRTSR
        BRzp    L3            ; Loop until Monitor is ready
        STI     R0,CRTDR      ; Echo input character
;
L4      LDI     R3,CRTSR
        BRzp    L4            ; Loop until Monitor is ready
        STI     R2,CRTDR      ; Move cursor to new clean line
        LD      R1,SaveR1     ; Restore registers
        LD      R2,SaveR2     ; to original values
        LD      R3,SaveR3
        BR      NEXT_TASK     ; Do the program's next task
;
SaveR1  .FILL   x0000         ; Allocated space for registers saved
SaveR2  .FILL   x0000
SaveR3  .FILL   x0000
CRTSR   .FILL   xF3FC
CRTDR   .FILL   xF3FF
KBSR    .FILL   xF400
KBDR    .FILL   xF401
Newline .FILL   x000A         ; ASCII code for newline 
Prompt  .STRINGZ "Input a character>"