can you please fic the error I am getting in the LC3 simulator: Oh no! You've got an error in your assembly code: at line 11: while parsing the offset for a LEA: the offset 'PROMPT' is not a valid numeric literal, but I can't find it in the symbol table either; did you misspell a label name? .ORIG x3000 ; Define constants BLANK .FILL x0020 ; Blank character GETC .FILL x20B0 ; GETC trap code PUTS .FILL x22A0 ; PUTS trap code HALT .FILL x25C0 ; HALT trap code ; Define variables ARRAY .BLKW #20 ; Array to store user inputs N .FILL #0 ; Size of the array COUNT .FILL #0 ; Loop counter INPUT .FILL #0 ; User input ; Prompt message PROMPT .STRINGZ "Enter a number (0 to 9): " ; Start of program LD R0, N ; Load the size of the array into R0 ADD R0, R0, #-1 ; Subtract 1 from the size to use as a loop counter ADD R0, R0, R0 ; Multiply the loop counter by 2 (each entry is 2 bytes) LOOP LEA R1, PROMPT ; Load the address of the prompt message into R1 PUTS ; Display the prompt message TRAP GETC ; Get a character from the user OUT ; Echo the character AND R2, R2, #0 ; Clear R2 (will store the converted number) ADD R2, R2, R0 ; Convert ASCII digit to a number ADD R2, R2, #-48 ; Subtract x0030 from the ASCII digit LDR R3, ARRAY ; Load the address of the array into R3 STR R2, R3, #0 ; Store the user input into the next available memory location of the array ADD R3, R3, #2 ; Increment the array pointer by 2 bytes ADD R0, R0, #-1 ; Decrement the loop counter BRp LOOP ; If the loop counter is positive, continue looping HALT ; Halt the program ; End of program .END
can you please fic the error I am getting in the LC3 simulator:
Oh no! You've got an error in your assembly code:
- at line 11: while parsing the offset for a LEA: the offset 'PROMPT' is not a valid numeric literal, but I can't find it in the symbol table either; did you misspell a label name?
.ORIG x3000
; Define constants BLANK .FILL x0020 ; Blank character GETC .FILL x20B0 ; GETC trap code PUTS .FILL x22A0 ; PUTS trap code HALT .FILL x25C0 ; HALT trap code
; Define variables ARRAY .BLKW #20 ; Array to store user inputs N .FILL #0 ; Size of the array COUNT .FILL #0 ; Loop counter INPUT .FILL #0 ; User input
; Prompt message PROMPT .STRINGZ "Enter a number (0 to 9): "
; Start of
LOOP LEA R1, PROMPT ; Load the address of the prompt message into R1
PUTS ; Display the prompt message
TRAP GETC ; Get a character from the user
OUT ; Echo the character
AND R2, R2, #0 ; Clear R2 (will store the converted number)
ADD R2, R2, R0 ; Convert ASCII digit to a number
ADD R2, R2, #-48 ; Subtract x0030 from the ASCII digit
LDR R3, ARRAY ; Load the address of the array into R3
STR R2, R3, #0 ; Store the user input into the next available memory location of the array
ADD R3, R3, #2 ; Increment the array pointer by 2 bytes
ADD R0, R0, #-1 ; Decrement the loop counter
BRp LOOP ; If the loop counter is positive, continue looping
HALT ; Halt the program
; End of program
.END
Step by step
Solved in 3 steps