L bytetohex
				# number in A
                                # address of high nybble in DI, 2 added
      push B
	= A to B
	AND 0xf0 to B
	downshift 4 to B
	= @  $digit B to B
	= byte B to @ DI

	1+ DI
	AND 0xf to A
        = @  $digit A to B
	= byte A to @  DI
	1+ DI
      pull B
return


L bytetobinary
				# number in A
                              # address of high nybble in DI, 8 added
				# coded mostly to avoid interior labels,
				# which happens to unroll loops.
      push B
	maskbyte A

	= A to B
	downshift 7 to B
	= byte @ $digit B to B
	= byte B to @ DI
	1+ DI

        = A to B
        downshift 6 to B
 	AND 1 to B
        = byte @ $digit B to B
        = byte B to @ DI
	1+ DI

        = A to B
        downshift 5 to B
 	AND 1 to B
        = byte @ $digit B to B
        = byte B to @  DI
	1+ DI

        = A to B
        downshift 4 to B
 	AND 1 to B
        = byte @ $digit B to B
        = byte B to @  DI
	1+ DI

        = A to B
        downshift 3 to B
 	AND 1 to B
        = byte @ $digit B to B
        = byte B to @  DI
	1+ DI

        = A to B
        downshift 2 to B
 	AND 1 to B
        = byte @ $digit B to B
        = byte B to @  DI
	1+ DI

        = A to B
        downshift 1 to B
 	AND 1 to B
        = byte @ $digit B to B
        = byte B to @  DI	
	1+ DI

        = A to B
        #downshift 0
 	AND 1 to B
        = byte @ $digit B to B
        = byte B to @  DI
	1+ DI

      pull B
return


# digit is in global/soft/text


# The lookup is probably slower in this slow-RAM era, but always simpler.
# reuseable too.

#L hexbyte
# binary byte to ASCII hex dual. a-f are lowercase, Ha3sm standard.
# this one doesn't use @ $digit
#
#				# number in A, ! A  ! B
#				# address of high nybble in DI, not changed
#	= A to B
#	downshift 4 to B
#	AND 0xf to B		# high nybble numeric value
#	-test 0xa to B
#	when sign		notletterH
#		+ 39 to B		# asc a - asc 0 - 10
#L notletterH
#	+ 0x30 to B
#	= B byte to @ DI
#	AND 0xf to A
#	-test 0xa to A
#	when sign	notletterL
#		+ 39 to A		# ascA-asc0-10
#L notletterL
#	+ 0x30 to A
#       =  A byte to  @ 1 DI
#						return
#
# a is 0x61 ASCII 
# 0 is 0x30
#
