Skip to content

Instantly share code, notes, and snippets.

@gnacu
Last active March 9, 2017 21:58
Show Gist options
  • Save gnacu/c6b46b46367e02b00de9e2db961c5fb1 to your computer and use it in GitHub Desktop.
Save gnacu/c6b46b46367e02b00de9e2db961c5fb1 to your computer and use it in GitHub Desktop.
moveptr .macro
ldy #\1 ;Set ptr offset
lda (ptr),y ;Load lo ptr byte
pha
iny
lda (ptr),y ;Load hi ptr byte
sta ptr+1 ;Save hi ptr byte
pla
sta ptr ;Save lo ptr byte
.endm
writeptr .macro ;ptr,to,offset
ldy #\3
lda \1
sta (\2),y
iny
lda \1+1
sta (\2),y
.endm
saveptr .macro
lda \1
pha
lda \1+1
pha
.endm
fetchptr .macro
pla
sta \1+1
pla
sta \1 ;Save lo ptr byte
.endm
copyptr .macro ;copy ptr from,to
lda \1
sta \2
lda \1+1
sta \2+1
.endm
incptr .macro ;Increment a pointer
inc \1 ;Inc ptr lo byte
bne end
inc \1+1 ;Inc ptr hi byte
end
.endm
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment