# ASCII Values from 8-digit binary Numbers

Discussion in 'OT Technology' started by JustJeff, Dec 4, 2007.

Joined:
Oct 30, 2006
Messages:
1,651
0
Location:
Long Island // Virginia Tech
Hey all! Thought there has to be at least 1 guy doing assembly here, so I decided to ask:

I'm trying to convert a hexadecimal 8-digit binary number (I.E. 0001 1110 = 2E)

How would I go about making 2E = 46 from hex to ascii? I will have 3 registers to express the value, since the max an 8 digit binary number can represent is 255.

So, I have

0001 1110, and I need to somehow figure out how to find out that this value is 46, represent that in two different nibbles, and add them to a register that has the default value 30. However, I do not know how to discover the 4 or the 6 for the value. As well, how can i add on top of that to get a hundreds place digit, so if the value is 120, how do I get the 1?

There has to be a systematic explanation, I just don't know how to approach it.

Oh, I'm using a PIC16F8X microcontroller.

2. ### skinjobActive Member

Joined:
Jan 6, 2001
Messages:
2,290
0
Location:
Aztlán
Divide by 10 and get the remainder. Take the quotient and repeat, etc.

Joined:
Oct 30, 2006
Messages:
1,651
0
Location:
Long Island // Virginia Tech
How would you go about dividing by 10 in assembly?

I can't even get the remainder in assembly... that's not a plausible explanation

4. ### skinjobActive Member

Joined:
Jan 6, 2001
Messages:
2,290
0
Location:
Aztlán
There should be instructions for division and obtaining a modulo. Probably div and mod. Go find a reference manual.

Joined:
Oct 30, 2006
Messages:
1,651