How can I print a multiple-digit decimal number stored in a register in LC-3 assembly?

22 Views Asked by At

I have a program that should output a number in decimal notation. This is easy when there is only one digit, but I don't know how to handle the case where the number is greater than 10. I only need to print rational numbers.

Ive tried using the same instructions I would for printing a single-digit number (assume number to print is in R3, and there is an ascii offset in R6):

AND R0, R0, #0 ; clear R0
ADD R0, R0, R3 ; add R3
ADD R0, R0, R6 ; add ASCII offset
OUT

But this obviously doesn't work with numbers over 9.

0

There are 0 best solutions below