ON 20071207@6:10:01 PM at page:
http://www.piclist.com/microchip/math/radix/b2bp-32b10d.htm#39423.7142476852
James Newton[JMN-EFP-786] Published and replied to post 39423.7142476852 by btjlynch
|Insert 'See 8 bit to BCD (half packed) and then just seperate out the nibbles by making a copy, then anding one with 0F and the other with F0 followed by a nibble swap.' at: ''
btjlynch@gmail.com asks: "
How do you convert an 8 bit unsigned binary number into a BCD number ?
Brent"
|Delete 'P-' before: '' but after: 'dic_cosmin@yahoo.com "
Sa te fut in cur Mike pentru treaba asta: "r=dec"
Translate this for yourself, it is in Romanian language"
This one does not care if the A-F is upper or lower case:|Delete 'P-' before: '' but after: '
hex2bin ; expects '0'-'9','A'-'F','a'-'f' in W
btfsc WREG,6 ; not all PICs can do this...
addlw 9 ; that's A-F (0x4? or 0x6?)
andlw 0x0F ; we need only the low nibble
return
Yes, that's 3 instructions + the return :-)
Tamas