summaryrefslogtreecommitdiff
path: root/home/print_hex.asm
diff options
context:
space:
mode:
Diffstat (limited to 'home/print_hex.asm')
-rw-r--r--home/print_hex.asm38
1 files changed, 38 insertions, 0 deletions
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"