Split two digit number in separate digits

Status
Not open for further replies.

Ooopscrash

Newbie level 3
Joined
May 10, 2015
Messages
3
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
18
Hi, how can I split a two digit number in separate digits in assembly?
For example, i got 00010111 which is 23, how can i split this numer to get 00000010 and 00000011? (2 and 3)
I'm using pic16f877a
 

Convert from Decimal to BCD and extract the LSB 4 bits and MSB 4 bits.
 

You are asking for an 8-bit binary number to be converted to two 4-bit BCD numbers.

Probably the easiest way is to count how many times you can subtract 0x0A (10 in decimal) from your number, this gives the first digit of your answer. The remainder after subtraction is the second digit of your answer.

Brian.
 

well, because i'm a newbie i was hoping for some piece of code
I know the theoretical things, my problem is at writing asm code.
 

Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…