-- -------------------------------------------------- -- Bin2Bcd3(var bcd2..bcd0 , bin1..bin0) -- converts BIN number in bin1 .. bin0 -- to BCD out bcd2 .. bcd0 -- -- bcd2:msd, bcd1:isd, bcd0:lsd, bin1:msb, bin0:lsb -- -------------------------------------------------- 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 procedure bin2bcd3 (byte out bcd2,byte out bcd1,byte out bcd0, Byte in bin1 ,Byte in bin0) is bcd2 = 0 bcd1 = 0 bcd0 = 0 for 16 loop -- all (16) bits of bin0..bin2 AdjBcd(bcd0) AdjBcd(bcd1) AdjBcd(bcd2) Assembler rlf bin0,f rlf bin1,f rlf bcd0,f rlf bcd1,f rlf bcd2,f End Assembler End loop End procedure