Skip to content

Instantly share code, notes, and snippets.

@adamv
Last active May 30, 2019 21:57
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save adamv/ade115b8e6f6c24e410c6c6010157872 to your computer and use it in GitHub Desktop.
Save adamv/ade115b8e6f6c24e410c6c6010157872 to your computer and use it in GitHub Desktop.
; Display the the byte in A as two hex digits at the current
; screen position
;
; Inputs:
; A byte to display
;
; Destroys A
display_hex:
pha
lsr
lsr
lsr
lsr
ora #$30 ; screen code for 0
cmp #58
bcc out3
sbc #57
out3:
jsr scr_output
pla
and #$0f
ora #$30 ; screen code for 0
cmp #58
bcc out4
sbc #57
out4:
jmp scr_output ; implicit rts
; Display the the byte in A as two hex digits at the current
; screen position
;
; Inputs:
; A byte to display
;
; Destroys A, X
display_hex:
pha
lsr
lsr
lsr
lsr
tax
lda hex_digits,x
jsr scr_output
pla
and #$0f
tax
lda hex_digits,x
jmp scr_output ; implicit rts
hex_digits: !scr "0123456789abcdef"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment