I have a problem with this LC-3 program, I can't get the string to display from the if
/else
statement. I don't know if I'm doing the statement wrong, or if I am displaying the string wrong. The goal is to have it display the IF
when the user enters 0
and the else
(halt the program) when they enter a 1
.
.ORIG x3000
START:
; clear registers
AND R0, R0, 0
AND R1, R0, 0
AND R2, R0, 0
AND R3, R0, 0
AND R4, R0, 0
; print greeting
LEA R0, GREETING
PUTS
; get user-input
; echo it back
GETC
PUTC
; store entered string
ST R0, USERINPUT
;FIRST IF STATEMENT
OUTPUT LD R2, USERINPUT
BRz ENDIF
LEA R3, GREETING
;ELSE
ENDIF
LD R2, USERINPUT
HALT
DONE
; stop the processor
HALT
GREETING: .STRINGZ "\nWelcome to the game.\nDo you want to play?\n0:Yes 1:No\n: "
GREETINGTWO: .STRINGZ "\nTest if statement: "
; variables
USERINPUT: .FILL 0
; end of code
.END