Question
Problem with assembly language code( outputting stored characters) Write an LC-3 assembly language program to read and store in memory a character string (length
Problem with assembly language code( outputting stored characters)
Write an LC-3 assembly language program to read and store
in memory a character string (length <= 20) until the
newline
character (ASCII decimal 10) is typed and then
display the string forwards using the trap PUTS.
Sample execution
:(user input underlined)
Please enter your name: John Doe (bold italized= user input)
You entered: John Doe
My code so far------
.ORIG x3000 LEA R0,PROMPT1 ; Displays first prompt. PUTS LEA R2, memSpace LOOP GETC PUTC ADD R3, R0, #-10 BRz DONE ;OUT STR R0, R2, #0 ADD R2, R2, #1 BRnzp LOOP
DONE LD R0,CRLF ; Executes new line. OUT ; Writes char
LEA R0,PROMPT2 ; Displays second prompt.
PUTS
LDR R5,R2, #4 ADD R0,R0,R5 OUT HALT
;************ Data area******************************* PROMPT1 .STRINGZ "Please enter your name: " PROMPT2 .STRINGZ "You entered: "
memSpace .BLKW 20 CHAR .BLKW 20
CRLF .FILL #10 .END
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started