gnupic: nibble<->hex conversions
Subject:
RE: nibble<->hex conversions
From:
"James Newton, webhost" ####@####.####
Date:
26 Sep 2002 16:45:00 -0000
Message-Id: <FOEOKOMCJKFMEAJJHIAFGEBCDFAA.jamesnewton@piclist.com>
http://www.piclist.com/techref/microchip/math/radix/ah2b-1d4b.htm
http://www.piclist.com/techref/microchip/math/radix/b2a-4b2a-sd.htm
The piclist.com site has most of this sort of stuff... Let us know if we are
missing anything.
---
James Newton, webhost piclist.com (former Admin #3)
####@####.#### 1-619-652-0593 fax:1-208-279-8767
PIC/PICList FAQ: http://www.piclist.com or .org
-----Original Message-----
From: Samuel Tardieu ####@####.####
Sent: Thursday, September 26, 2002 7:42 AM
To: ####@####.####
Subject: nibble<->hex conversions
In my Forth compiler for 16f87x (see http://www.rfc1149.net/devel/picforth),
I have a nibble>hex and hex>nibble conversion routines.
I would like to know if faster ones do exist. The goal of nibble>hex is to
convert a character (present in INDF) into the corresponding hexadecimal
value, stored at the same place. The character can be in the range 0-9, A-Z
or a-z. hex>nibble converts the value at INDF into the corresponding ASCII
character (0-9 and A-Z), result goes to the same place.
Here are my routines. I want to make them as fast as possible; only the
interface cannot change, except that the nibble or character to convert from
can come in W rather than INDF (but the result must be stored in INDF).
Also, I do not want to use more room, so using tables is not an option.
nibble>hex:
| movlw 0x30
| addwf 0x00,f
| movf 0x00,w
| addlw 0xC6
| andlw 0x80
| btfss 0x03,2
| return
| movlw 0x07
| addwf 0x00,f
| return
hex>nibble:
| bcf 0x00,5
| movlw 0xC9
| addwf 0x00,f
| btfss 0x00,7
| return
| movlw 0x27
| addwf 0x00,f
| return
Thanks in advance for your suggestions.
Sam
---------------------------------------------------------------------
To unsubscribe, e-mail: ####@####.####
For additional commands, e-mail: ####@####.####