| ??? 12/05/05 09:45 Read: times |
#104689 - thanks Responding to: ???'s previous message |
Thanks for the comments, Slobodan; I have much less of them...
Just one note, the constants I wrote in decimal (e.g. mov b,#100). The mess with unrolled multiply and add can be solved too, making it also more universal (for different length of packed BCD - BCD5 is quite common). Takes about 50% more time to execute.
BCD4Bin:
clr a
mov r2,a
mov r3,a
mov r4,a
mov r5,a
mov a,@r0
inc r0
call BCD1BinPlus
mov a,@r0
inc r0
call BCD1BinPlus
mov a,@r0
inc r0
call BCD1BinPlus
mov a,@r0
inc r0
; call BCD1BinPlus ;fallthrough
; ret
BCD1BinPlus: ;converts BCD in ACC into bin in ACC; uses no extra resources
xrl a,#0F0h
jbc acc.4,BCD1BX1
add a,#10
BCD1BX1:
jbc acc.5,BCD1BX2
add a,#20
BCD1BX2:
jbc acc.6,BCD1BX3
add a,#40
BCD1BX3:
jbc acc.7,BCD1BX4
add a,#80
BCD1BX4:
;multiplies r5..r2 by 100 and adds a
xch a,r2
mov b,#100
mul ab
add a,r2
mov r2,a
clr a
addc a,b
xch a,r3
mov b,#100
mul ab
add a,r3
mov r3,a
clr a
addc a,b
xch a,r4
mov b,#100
mul ab
add a,r4
mov r4,a
clr a
addc a,b
xch a,r5
mov b,#100
mul ab
add a,r5
mov r5,a
ret
Jan Waclawek |



