http://www.piclist.com/techref/microchip/math/radix/index.htm
Modified by:JMN-EFP-786 jamesnewton@efplus.com
preview-to: http://www.piclist.com/techref/microchip/math/radix/b2b-4b2d-ba.htm
4bit to BCD 2 digits from Bob Ammerman
http://www.piclist.com/techref/microchip/math/radix/b2b-4b2d-ba.htm
Modified by:JMN-EFP-786
replace-to:
4bit to BCD 2 digits from Bob Ammerman
4bit to BCD 2 digits
from Bob Ammerman
WARNING: Untested code
Input:
W is a binary number in the range 0..29
Output:
W is a BCD number in the range 0x00..0x29
; W is 0..29
addlw .256-.20 ; C will be set if number was >= 20
skpnc
addlw .6 ; ...adjust for 20..29
addlw -(.256-.20) ; Back to original value
addlw .256-.10 ; C will be set if number was >= 10
skpnc
addlw .6 ; ...adjust for 10..29
addlw -(.256-.10) ; Back to original value
http://www.piclist.com/techref/microchip/math/radix/b2b-4b2d-ba.htm
Modified by:JMN-EFP-786
replace-to:
PIC Microcontroller Radix Math Method - 4bit to BCD 2
4bit to BCD 2 digits
from Bob Ammerman
WARNING: Untested code
Input:
W is a binary number in the range 0..29
Output:
W is a BCD number in the range 0x00..0x29
; W is 0..29
addlw .256-.20 ; C will be set if number was >= 20
skpnc
addlw .6 ; ...adjust for 20..29
addlw -(.256-.20) ; Back to original value
addlw .256-.10 ; C will be set if number was >= 10
skpnc
addlw .6 ; ...adjust for 10..29
addlw -(.256-.10) ; Back to original value
http://www.piclist.com/techref/microchip/math/radix/index.htm
Modified by:JMN-EFP-786
replace-to:
PIC Microcontoller Radix Math Methods
-
ASCII
-
BCD
-
Binary
-
to BCD
-
to ASCII
-
4bit to ASCII HEX 2 digits by
Scott Dattalo
-
8bit to ASCII HEX 2 digits by
Scott Dattalo
-
16bit to ASCII
Decimal 5 digits with
leading zero suppression and fixed decimal point from Dontronics and
Scott Edwards
-
16bit to ASCII Decimal 5 digits in 1 temp register,
76 instructions, ~500 executed by James Newton
(Parallax menomics see
Macros
for using Parallax instructions with MPASM also
Prlx.asm)
-
16bit to ASCII Decimal 5 digits in 0 temp registers,
42 instructions, ~266 executed by Rich Leggit tweaked by
Scott Dattalo.and bugfix by Dmitry Kiryashov
and Nikolai Golovchenko
-
16bit to ASCII Decimal 5 digits in 0 temp registers,
68 instructions, ~220 executed by
Nikolai Golovchenko
-
16bit to ASCII Decimal 3 digits (999) in 0 temp
registers, 34 instructions, ~87 executed by
Nikolai Golovchenko
-
16bit to ASCII Decimal 3 digits (999) in 0 temp
registers, 59 instructions, ~60 executed by
Nikolai Golovchenko
-
24bit signed to ASCII Decimal 8/9 digit
decimal with point and minus sign (if negative) by Tony Kübek
-
32bit to BCD packed and ASCII Decimal 10 digits
from Ron Kreymborg and Mike Keitz
See also:
http://www.piclist.com/techref/microchip/math/radix/index.htm
Modified by:JMN-EFP-786
replace-to:
PIC Microcontoller Radix Math Methods
-
ASCII
-
BCD
-
Binary
-
to BCD
-
to ASCII
-
4bit to ASCII HEX 2 digits by
Scott Dattalo
-
8bit to ASCII HEX 2 digits by
Scott Dattalo
-
16bit to ASCII
Decimal 5 digits with
leading zero suppression and fixed decimal point from Dontronics and
Scott Edwards
-
16bit to ASCII Decimal 5 digits in 1 temp register,
76 instructions, ~500 executed by James Newton
(Parallax menomics see
Macros
for using Parallax instructions with MPASM also
Prlx.asm)
-
16bit to ASCII Decimal 5 digits in 0 temp registers,
42 instructions, ~266 executed by Rich Leggit tweaked by
Scott Dattalo.and bugfix by Dmitry Kiryashov
and Nikolai Golovchenko
-
16bit to ASCII Decimal 5 digits in 0 temp registers,
68 instructions, ~220 executed by
Nikolai Golovchenko
-
16bit to ASCII Decimal 3 digits (999) in 0 temp
registers, 34 instructions, ~87 executed by
Nikolai Golovchenko
-
16bit to ASCII Decimal 3 digits (999) in 0 temp
registers, 59 instructions, ~60 executed by
Nikolai Golovchenko
-
24bit signed to ASCII Decimal 8/9 digit
decimal with point and minus sign (if negative) by Tony Kübek
-
32bit to BCD packed and ASCII Decimal 10 digits
from Ron Kreymborg and Mike Keitz
See also: