BITMATH Introduction
Set, Reset, or Test a bit in the byte at HL.........SET_M, RES_M, TST_M
Logical AND, OR, XOR with (HL), result in (HL)....ANDM2M, ORM2M, XORM2M
Reverse the bit order in the byte at HL..........................MIRROR
Set bit n in A, reset others......................................EXP_A
Return LOG(A) in A, ignoring all but highest bit.................LOG2_A
Set up to 8 least significant bits in A, others reset.............MASK8
Set up to 16 least significant bits in BC, others reset..........MASK16
: 
BITMATH Introduction

This a collection of routines to manipulate the bits in a byte at HL,
and routines to perform certain binary pseudo-exponential operations
to create bit patterns for logical masking. Examples are:

	Input		Output		Function/Routine
	05h		00100000b		EXP_A
	001xxxxx	05h			LOG2_A
	05h		00111111b		MASK8
	0Bh		00001111 11111111	MASK16
	01011101	10111010		MIRROR

The MASKn functions are really [EXP(A+1) - 1], a function encountered
in Directory and DPB calculations. (EXP(n) = "raise 2 to power n")

LOG2_A is the inverse operation to MASK8, not a true binary LOG.
It ignores all but the highest order bit in (input).

The MIRROR function is used to convert bytes between low-bit-first
and high-bit-first for display convenience.
: 
Set, Reset, or Test a bit in the byte at HL

     Routines:			SET_M, RES_M, TST_M

     Function:			Set, Reset, or Test a bit 
				in the byte at HL

     Inputs:			A  = bit number (0-7)
				HL = address of the byte

     Outputs:			The bit is set, reset, or tested

     Registers Affected:  	AF,BC

	FLAGS:  if Z, c = a = 0, else NZ, c = a = 0ffh
NOTE: the z/nz returns are significant only for TST_M
: 
Logical AND, OR, XOR with (HL), result in (HL)

     Routine:			ANDM2M, ORM2M, XORM2M

     Function:			as above, and implied in names

     Inputs:			A = byte to combine with (HL)
				HL = address of memory operand

     Outputs:			byte in memory is modified

     Registers Affected:	AF

: 
Reverse the bit order in the byte at HL. (mirror image)


     Routine:			MIRROR

     Function:			Invert the order of the bits at (hl)
				by swapping bits 0-7,1-6,2-5,3-4

     Inputs:			HL = addr of byte to invert

     Outputs:			mirror image in (HL)

     Registers Affected:	AF
				all other registers preserved

: 
Set bit n in A, reset others.

     Routine:			EXP_A

     Function:			Set a single bit in reg A,
				reset all others.

     Inputs:			A = bit position to set (0-7)

     Outputs:			A = requested bit set, others 0

     Registers Affected:	all other registers preserved.
				flags are undefined

: 
Return LOG(A) in A, ignoring all but highest bit.

     Routine:			LOG2_A:

     Function:			Convert a byte to the ordinal number
				in binary corresponding to the bit 
				position of the highest bit set in 
				the byte. This is a special case of
				log n, where n= 0...7

     Inputs:			A = the byte to convert

     Outputs:			A contains the log of A (bit position)

     Registers Affected:	AF
				Other registers preserved
: 
Set up to 8 least significant bits in A, others reset.

     Routine:			MASK8

     Function:			Set n least significant bits in reg A.
				Remaining bits are reset.
				n is specified as a number, (0-7) which
				defines the highest bit set.

     Inputs:			A = highest bit to set (0-7)

     Outputs:			A = filled with 1's from position
				0 up through position specified

     Registers Affected:	AF

: 
Set up to 16 least significant bits in BC, others reset.

     Routine:			MASK16

     Function:			Set the n least significant bits in
				register pair BC according to the
				value n(0..15) in A.

     Inputs:			A = highest bit set position

     Outputs:			BC contains the mask

     Registers Affected:	BC is used
				A is not preserved

     Other Routines Called:	MASK8
