-
-
Save ddevault/af620b797927a82318b6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; Writes A to X,Y in hex | |
print_hex: | |
SET PUSH, A | |
SET PUSH, X | |
SET PUSH, Y | |
MUL Y, 32 | |
ADD X, Y | |
ADD X, 0x8000 ; Screen is mapped to 0x8000 | |
.loop: | |
SET Y, A | |
AND Y, 0xF000 | |
SHR Y, 12 ; Shift the most significant nibble to the least significant position | |
IFL Y, 10 | |
ADD Y, '0' | |
IFL Y, 16 | |
ADD Y, 'A' | |
BOR Y, 0xF000 ; OR the character with 0xF000 to set the color | |
SET [X], Y | |
ADD X, 1 | |
SHL A, 4 ; Shift out the printed nibble | |
IFE A, 0 | |
SET PC, .return | |
SET PC, .loop | |
.return: | |
SET Y, POP | |
SET X, POP | |
SET A, POP | |
SET PC, POP |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment