Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
12/19/00 13:03
Read: times


 
#7416 - RE: about 32bit hex to bcd convertion
Hi asghar,

following an example of the subtraction method for 16 bit.
It is faster than the division method, since the 8051 have no 16 bit or 32 bit division instruction.


;input: R7, R6 = 16 bit value 0 ... 65535
;output: R7, R6, R5, R4, R3 = digits
;cycle: 37 .. 220
;bytes: 44
;
hex2bcd:
mov a, r7
mov r3, a
mov a, r6
mov r7, #-1
?bcd1: inc r7
add a, #low(-10000)
xch a, r3
addc a, #high(-10000)
xch a, r3
jc ?bcd1
mov r6, #10
?bcd2: dec r6
add a, #low(1000)
xch a, r3
addc a, #high(1000)
xch a, r3
jnc ?bcd2
mov r5, #-1
inc r3
?bcd3: inc r5
add a, #low(-100)
jc ?bcd3
djnz r3, ?bcd3
mov r4, #10
?bcd4: dec r4
add a, #10
jnc ?bcd4
mov r3, a
ret


Peter


List of 8 messages in thread
TopicAuthorDate
about 32bit hex to bcd convertion            01/01/70 00:00      
RE: about 32bit hex to bcd convertion            01/01/70 00:00      
RE: about 32bit hex to bcd convertion            01/01/70 00:00      
RE: about 32bit hex to bcd convertion            01/01/70 00:00      
RE: about 32bit hex to bcd convertion            01/01/70 00:00      
RE: about 32bit hex to bcd convertion            01/01/70 00:00      
RE: about 32bit hex to bcd convertion            01/01/70 00:00      
RE: about 32bit hex to bcd convertion            01/01/70 00:00      

Back to Subject List