Jump to content
IGNORED

How to do something close to pointers?


Recommended Posts

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!

Link to comment
Share on other sites

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!

947902[/snapback]

 

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.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...