Skip to content

Instantly share code, notes, and snippets.

@ddevault
Created November 2, 2012 05:40
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save ddevault/af620b797927a82318b6 to your computer and use it in GitHub Desktop.
; 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