Skip to main content

AddToAny

Share/Save

LC3 Program to echo user entered characters

No replies
vaibhav
vaibhav's picture
User offline. Last seen 5 days 9 hours ago. Offline
Joined: 08/19/2009

I need a program to echo the user entered strings. I have write this code. but its not working properly. Please help me out.

			.ORIG x3000 
LEA R0, Message ; display a message
PUTS
LEA R1, FirstChar ; R1 points to the first
; character which will be entered

; the loop for echoing user's input
Next LD R2, LF_ASCII
GETC ; read in one character
OUT ; write character entered
ADD R3, R1, 1 ; R3 points to the next character
ADD R4, R0, R2 ; check whether the input is LF
BRnp Next ; if input is LF check whether it's,


Message .STRINGZ "Please enter a string: "
LF_ASCII .FILL -10
FirstChar .BLKW 10

.END