diff options
-rw-r--r-- | charmap.asm | 3 | ||||
-rw-r--r-- | home/print_hex.asm | 38 |
2 files changed, 41 insertions, 0 deletions
diff --git a/charmap.asm b/charmap.asm index 228bb6b..575a8eb 100644 --- a/charmap.asm +++ b/charmap.asm @@ -116,6 +116,9 @@ charmap "▲", $61 charmap "☎", $62 + charmap "A", $60 + charmap "B", $61 + charmap "C", $62 charmap "D", $63 charmap "E", $64 charmap "F", $65 diff --git a/home/print_hex.asm b/home/print_hex.asm new file mode 100644 index 0000000..3f50467 --- /dev/null +++ b/home/print_hex.asm @@ -0,0 +1,38 @@ +INCLUDE "constants.asm" + +SECTION "Print Hexadecimal functions", ROM0[$3597] + +PrintHexBytes: ; 3597 (0:3597) +.loop + push bc + call PrintHexByte + pop bc + dec c + jr nz, .loop + ret + +PrintHexByte:: ; 35a0 (0:35a0) + ld a, [de] + swap a + and $0f + call PrintHexDigit + ld [hli], a + ld a, [de] + and $0f + call PrintHexDigit + ld [hli], a + inc de + ret + +PrintHexDigit: ; 35b2 (0:35b2) + ld bc, .hexDigitTable + add c + ld c, a + ld a, $00 + adc b + ld b, a + ld a, [bc] + ret + +.hexDigitTable: + db "0123456789ABCDEF" |