ON 20021128@4:15:31 PM at page: http://www.sxlist.com/techref/scenix/lib/math/radix/index_sx.htm JMN-EFP-786 James Newton added 'archive reference http://www.piclist.org/techref/postbot.asp?by=time&id=piclist/2001/01/29/165144a PICList post "Code Challenge: Range check and convert Hex to Binary"' ON 20021129@11:04:16 AM at page: http://www.sxlist.com/techref/scenix/lib/math/radix/index_sx.htm JMN-EFP-786 James Newton added 'Says http://www.sxlist.com/techref/scenix/lib/math/radix/b2a-4b1ah-jn.htm 4 bit to ASCII Hex' ON 20021129@11:04:54 AM at page: http://www.sxlist.com/techref/scenix/lib/math/radix/b2a-4b1ah-jn.htm JMN-EFP-786 James Newton added 'Code:
4bit-ASCIIHex:		;***** UNTESTED!!!
	mov temp, w		;save the value
	mov w, #-09
	add w, temp		;compare temp with 9
	mov w, #'A'		;assume it will be more (no change to compare flags)
	snc			;if it was less
	 mov w, #'0'		;correct the offset
	add w, temp		;add the offset to the value
	ret
See:
http://www.sxlist.com/lib/flow/compcon_sx.htm in the "X < Y" section "fr < n" subsection for an explination of how the comparison works. For 8 bits you have to call that twice:

8bit-ASCIIHex:		;***** UNTESTED!!!
	mov w, <>byte		;w is byte with upper and lower nibbles reversed
	and w, #15		;mask off the upper (was lower) 4 bits
	call 4bit-ASCIIHex	;convert that nibble to ASCII Hex
	call Output		;and send it off to where ever
	mov w, byte		;now get the actual value
	and w, #15		;mask off the upper (really) 4 bits
	call 4bit-ASCIIHex	;convert this nibble to ASCII Hex
	call Output		;and send it off.
' ON 20021129@11:06:58 AM at page: http://www.sxlist.com/techref/scenix/lib/math/radix/b2a-4b1ah-jn.htm JMN-EFP-786 James Newton edited the page ON 20021129@11:09:20 AM at page: http://www.sxlist.com/techref/scenix/lib/math/radix/b2a-4b1ah-jn.htm JMN-EFP-786 James Newton edited the page ON 20021129@11:09:49 AM at page: http://www.sxlist.com/techref/scenix/lib/math/radix/b2a-4b1ah-jn.htm JMN-EFP-786 James Newton edited the page ON 20021129@11:11:38 AM at page: http://www.sxlist.com/techref/scenix/lib/math/radix/index_sx.htm JMN-EFP-786 James Newton edited the page