Binary to ASCII using logical operations

I am learning Computer Architecture from Introduction to Computing Systems (2nd Edition) and am stuck on this question.

What operations can be used to convert the binary representation of 3 into ASCII representation for 3? What about binary 4 to ASCII or any other digit?

The concepts I have learnt until now are Basic Logic gates and Bit Masking so I have to use them for conversion. Can someone help me understand what my approach should be?

By looking at a ASCII table you can see that the $$4$$ least significant bits of all characters between $$0$$ and $$9$$ correspond to the respective integer representations of the numbers between $$0$$ and $$9$$, while the 4 most significant bits are always $$0011$$ (leading zeroes are not shown in the table, so keep in mind you need to pad binary numbers to 8 bits).

If $$x$$ is the binary representation of a number between $$0$$ and $$9$$, you can then obtain the ASCII representation of the corresponding character as $$x \;| \;00110000,$$

where $$|$$ denotes a bitwise logical or and the second operand is in binary.

• Thank you so much, I understood this. The ASCII representation of the numbers was in seven bits and the mask was six bits. So in order to avoid confusion, I converted both to 8 bits. Can you please edit your answer so that another student who sees the answer doesn't get confused?
– Ray
Commented May 31, 2020 at 0:50
• I clarified my answer :) Commented May 31, 2020 at 2:10
• Thank you so much!
– Ray
Commented May 31, 2020 at 3:49