Jump to content



0

How to do something close to pointers?


1 reply to this topic

#1 CabaretVoltaire OFFLINE  

CabaretVoltaire

    Space Invader

  • 44 posts

Posted Thu Oct 13, 2005 3:40 PM

I have some code that I'd like to turn into a subroutine but can't work out how to do something similar to C pointers to make this possible..


My code at the minute alters the contents of some RAM addresses but is repeated several times for different RAM addresses..

I'd like to do something like

ldx [address of variable]
jsr MySubRoutine



Where the subroutine will can do something like:
stx temp
and then load/read from the original variable with
ld? #temp
st? #temp
right?


Thanks!

#2 vdub_bobby OFFLINE  

vdub_bobby

    Quadrunner

  • 5,831 posts
  • Boom bam.
  • Location:Seattle, WA

Posted Thu Oct 13, 2005 3:49 PM

CabaretVoltaire, on Thu Oct 13, 2005 2:40 PM, said:

I have some code that I'd like to turn into a subroutine but can't work out how to do something similar to C pointers to make this possible..


My code at the minute alters the contents of some RAM addresses but is repeated several times for different RAM addresses..

I'd like to do something like

ldx [address of variable]
jsr MySubRoutine



Where the subroutine will can do something like:
stx temp
and then load/read from the original variable with
ld? #temp
st? #temp
right?


Thanks!

View Post


I think you want to do something like this...
   ldx [address of variable]
   jsr Subroutine

;--------------

Subroutine
   lda $00,X
And then the accumulator will hold the contents of RAM.
I'm assuming (since this is in the 2600 forum) that your RAM location is a zero page location.




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users