Instruction manual

00a7 e1 pop hl ;get string target address
00a8 77 ld (hl),a ;store second char of string
00a9 23 inc hl ;point to third location
00aa 3e 00 ld a,000h ;zero to terminate string
00ac 77 ld (hl),a ;store the zero
00ad c9 ret ;done
00ae ;
00ae ;Converts a single ASCII hex char to a nybble value
00ae ;Pass char in reg A. Letter numerals must be upper case.
00ae ;Return nybble value in low-order reg A with zeros in high-order nybble if no error.
00ae ;Return 0ffh in reg A if error (char not a valid hex numeral).
00ae ;Also uses b, c, and hl registers.
00ae 21 ee 00 hex_char_to_nybble: ld hl,hex_char_table
00b1 06 0f ld b,00fh ;no. of valid characters in table - 1.
00b3 0e 00 ld c,000h ;will be nybble value
00b5 be hex_to_nybble_loop: cp (hl) ;character match here?
00b6 ca c2 00 jp z,hex_to_nybble_ok ;match found, exit
00b9 05 dec b ;no match, check if at end of table
00ba fa c4 00 jp m,hex_to_nybble_err ;table limit exceded, exit with error
00bd 0c inc c ;still inside table, continue search
00be 23 inc hl
00bf c3 b5 00 jp hex_to_nybble_loop
00c2 79 hex_to_nybble_ok: ld a,c ;put nybble value in a
00c3 c9 ret
00c4 3e ff hex_to_nybble_err: ld a,0ffh ;error value
00c6 c9 ret
00c7 ;
00c7 ;Converts a hex character pair to a byte value
00c7 ;Called with location of high-order char in HL
00c7 ;If no error carry flag clear, returns with byte value in register A, and
00c7 ;HL pointing to next mem location after char pair.
00c7 ;If error (non-hex char) carry flag set, HL pointing to invalid char
00c7 7e hex_to_byte: ld a,(hl) ;location of character pair
00c8 e5 push hl ;store hl (hex_char_to_nybble uses it)
00c9 cd ae 00 call hex_char_to_nybble
00cc e1 pop hl ;ret. with nybble in A reg, or 0ffh if error
00cd fe ff cp 0ffh ;non-hex character?
00cf ca ec 00 jp z,hex_to_byte_err ;yes, exit with error
00d2 cb 27 sla a ;no, move low order nybble to high side
00d4 cb 27 sla a
49