Created
May 7, 2016 06:50
-
-
Save niconii/3d03445ba8c6346cf23a5844160ab647 to your computer and use it in GitHub Desktop.
Accessing byte at offset from stack pointer on 6502
This file contains hidden or 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
tsx ; transfer stack pointer to X register | |
stx scratch ; store X in RAM | |
ldx #$01 ; load 0x01 into X | |
stx scratch+1 ; store X in RAM | |
ldx offset ; load offset into X | |
lda (scratch,x) ; perform an indirect load from *(scratch + X) into A | |
1+2+2+2+2+2 bytes = 11 bytes | |
2+3+2+3+3+6 cycles = 19 cycles | |
; clobbers two of the 6502's three general-purpose registers |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment