Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

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 :D
I know the theoretical things, my problem is at writing asm code.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top