Skip to content

Instantly share code, notes, and snippets.

@r-moeritz
Last active May 2, 2020 17:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save r-moeritz/c0d689879c7e156e79964926b9a06cf1 to your computer and use it in GitHub Desktop.
Save r-moeritz/c0d689879c7e156e79964926b9a06cf1 to your computer and use it in GitHub Desktop.
Determine program start address and print it (in decimal)
; findprgadr.s
;
; find and print program address
; works by calling into a rom routine, causing the sp to be saved.
*= $c0f7
linprt = $bdcd
findadr sei ; stop irqs from touching the stack
jsr $f5ae ; rts
tsx
.byte $bd,$ff,$00 ; lda $00ff,x (force abs. x addr. mode)
ldy $0100,x ; high-byte
cli
fixadr sec ; subtract 3 to fix return address
sbc #3
tax ; put low-byte in x
tya ; put high-byte in acc.
sbc #0
printadr jsr linprt
quit rts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment