I may be going about this the wrong way, so sorry if it is wrong, I'm coming to 6502 after 32 years (when I was 8 years old !)
I want to pass a pointer to some data, either
data2 to a sub routine, which I can then access in the subroutine via
lda data1, y or
lda data2, y. Something like this, although of course it's not right:
// send in data1 or data2 to subroutine... e.g. push onto the stack maybe? jsr function rts function: ... lda ***, y // how can I replace *** with data1 or data2 here, sent in from the main program? sta memlocation, y rts data1: .byte 45, 50, 75, 50, 105, 50, 135, 50, 165, 50, 195, 50, 225, 50, 255, 50 data2: .byte 45, 100, 75, 100, 105, 100, 135, 100, 165, 100, 195, 100, 225, 100, 255, 100
Could indirect addressing work somehow? I'm a bit confused about this, but maybe I'm trying to achieve this the wrong way.
Although I do own a C64, I'm currently developing on Kubuntu Linux using Visual Studio Code with Kick Assembler, the VCS Kick Ass extensions, and VICE64 (all free !)
I just got 72 sprites on screen at once :-) but I'm trying to optimise my routines.
Thanks to the answer I used a global parameter, and have reduced my code footprint significantly: