it has stuff like
-- determine the next digit and display it
if n_tot >=10 then
digit = byte(data / c1_000_000_000)
data = data % c1_000_000_000
_write_digit(device, digit, n2==9)
end if
if n_tot >=9 then
digit = byte(data / c100_000_000)
data = data % c10_000_000
_write_digit(device, digit, n2==8)
end if
if n_tot >=8 then
digit = byte(data / c10_000_000)
data = data % c10_000_000
_write_digit(device, digit, n2==7)
end if
if n_tot >=7 then
digit = byte(data / c1_000_000)
data = data % c1_000_000
_write_digit(device, digit, n2==6)
end if
etc...
It *Should* be based on this
This is Binary to unpacked BCD, but simply adding "0" to each digit
makes it a string....
It can be extended to DWORD or any number of bytes
-- Convert unsigned binary to unpacked BCD in string order.
-- Private
Procedure AdjBcd (Byte in out digit) is
Var byte temp
var bit hc at temp : 3
var bit fc at temp : 7
temp = digit + 3
if hc then digit = temp end if
temp = digit + 0x30
if fc then digit = temp end if
End procedure
-- Public
procedure WordToBCD5 (word in binw, byte out bcd[5]) is
var byte bin[2] at binw
bcd[4] = 0
bcd[2] = 0
bcd[0] = 0
for 16 loop -- all (16) bits of bin0..bin2
AdjBcd (bcd[4])
AdjBcd (bcd[2])
AdjBcd (bcd[0])
Assembler
rlf bin[0],f
rlf bin[1],f
rlf bcd[4],f
rlf bcd[2],f
rlf bcd[0],f
End Assembler
End loop
-- now unpack
bcd[3] = bcd[4]
bcd[4] = bcd[4] & 15
bcd[3] = bcd[3] / 16 -- compiler always does this by shifts
bcd[1] = bcd[2]
bcd[2] = bcd[2] & 15
bcd[1] = bcd[1] / 16 -- compiler always does this by shifts
End procedure
--
You received this message because you are subscribed to the Google Groups
"jallib" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/jallib?hl=en.