How to produce double digits numbers LC3

214 Views Asked by At

Having trouble printing any number past 10 in my LC3 program to multiply 2 input numbers to get a area. It works for any numbers below 10 so I know my multiplication is right. The problem is it produces weird symbols or nonsense anywhere higher then 10. So confused why. Here is my code:

.ORIG x3000

AND R3, R3, #0

AND R4, R4, #0

LD R5, INVERSE_ASCII_OFFSET

LD R6, DECIMAL_OFFSET

;---------------------

;receiving length

LEA R0, PROMPT1 ;load the address of the 'PROMPT1' message string

PUTS ;Prints PROMPT1

GETC ;get length

ADD R1, R0, #0

ADD R1, R1, R5

;receving width

LEA R0, PROMPT2 ;load the address of the 'PROMPT2' message string

PUTS ;Prints PROMPT2

GETC ;get width

ADD R2, R0, #0

ADD R2, R2, R5

;----------------------

;MULTIPLICATION to find AREA

ADD R4, R2, #0

FINDAREA:

               ADD R3, R3, R1

               ADD R4, R4, #-1

               BRp FINDAREA

LEA R0, PROMPT3

PUTS

ADD R0, R3, R6

OUT

HALT

PROMPT1 .STRINGZ "ENTER LENGTH OF THE RECTANGLE:"

PROMPT2 .STRINGZ "ENTER WIDTH OF THE RECTANGLE:"

PROMPT3 .STRINGZ "AREA OF THE RECTANGLE:"

INVERSE_ASCII_OFFSET .fill xFFD0

DECIMAL_OFFSET .fill #48

.END```
0

There are 0 best solutions below