LC3Tools Uden navn.asm 1 .ORIG X3000 2 readS LEA RO, prompt PUTS 234567 AND RO, RO, #0 ; Read first digit 8 GETC 9 OUT 10 11 12 13 14 15 16 17 18 19 20 21 22 23 LD R1, ASCII_OFFSET ADD RO, RO, R1 ADD RO, RO, #-48 ADD RO, RO, RO ; Read second digit GETC OUT LD R1, ASCII_OFFSET ADD R2, RO, R1 ADD R2, R2, #-48 ADD RO, RO, R2 RET 24 prompt .STRINGZ "Input a 2 25 ASCII_OFFSET .FILL XFFD0 ; Load effective address of prompt message ; Display prompt message ; Clear RO to store the result ; Read first digit ; Echo first digit ; Load ASCII offset to subtract from digit character ;Convert digit character to integer ; Convert ASCII digit to integer ; Shift to left to make room for second digit ; Read second digit ; Echo second digit ; Load ASCII offset to subtract from digit character ; Convert digit character to integer ;Convert ASCII digit to integer ; Combine first and second digit ; Return from function digit decimal number: " ; ASCII offset to convert digit character to integer 26 . END /Users/omar/Desktop/Uden navn.asm:13:21: error: cannot encode as 5-bit 2's complement number ADD RO, RO, #48 ^~~ /Users/omar/Desktop/Uden navn.asm:21:21: error: cannot encode as 5-bit 2's complement number ADD R2, R2, #48 ^~~
Could someone help me modify this code so it dosn't give me the errors it gives. I want a code that is modified so i just can take it, put it inside lc3 so that it works. would be really appreciated. (errors can be seen in the attached picture.
Here is also the code so you can easily modify it and send it back to me as text:
.ORIG x3000
readS LEA R0, prompt ; Load effective address of prompt message
PUTS ; Display prompt message
AND R0, R0, #0 ; Clear R0 to store the result
; Read first digit
GETC ; Read first digit
OUT ; Echo first digit
LD R1, ASCII_OFFSET ; Load ASCII offset to subtract from digit character
ADD R0, R0, R1 ; Convert digit character to integer
ADD R0, R0, #-48 ; Convert ASCII digit to integer
ADD R0, R0, R0 ; Shift to left to make room for second digit
; Read second digit
GETC ; Read second digit
OUT ; Echo second digit
LD R1, ASCII_OFFSET ; Load ASCII offset to subtract from digit character
ADD R2, R0, R1 ; Convert digit character to integer
ADD R2, R2, #-48 ; Convert ASCII digit to integer
ADD R0, R0, R2 ; Combine first and second digit
RET ; Return from function
prompt .STRINGZ "Input a 2 digit decimal number: "
ASCII_OFFSET .FILL xFFD0 ; ASCII offset to convert digit character to integer
.END
Step by step
Solved in 1 steps