RosettaCodeData/Task/Character-codes/Z80-Assembly/character-codes-2.z80

20 lines
485 B
Z80 Assembly

ShowHex:
push af
and %11110000
rrca
rrca
rrca
rrca
call PrintHexChar
pop af
and %00001111
;call PrintHexChar (execution flows into it naturally)
PrintHexChar:
or a ;Clear Carry Flag
daa
add a,&F0
adc a,&40 ;this sequence of instructions converts a single hex digit to ASCII.
jp PrintChar ;this is whatever routine prints to the screen on your system.
; It must end in a "ret" and it must take the accumulator as its argument.