Jump to content
IGNORED

Loading an address with a variable offset


Karl G

Recommended Posts

If I want to create a pointer to data in a table with a variable offset into the data, what is the syntax? Here is what doesn't work:

 

    lda #<enemy_bitmaps_1,y
    sta EnemyPtr
    lda #>enemy_bitmaps_1,y
    sta EnemyPtr+1

I have confirmed via the Stella debugger that I am loading the correct offset into Y, but it is not pulling the correct data when I try to use the pointer. What am I doing wrong here?

 

Link to comment
Share on other sites

LDA - Immediate and Absolute,Y are two distinct address modes, they can't be used at the same time. In a better compiler that would cause a compile time error, or at least a warning, but with dasm the Absolute,Y mode appears to have priority.

 

I suspect what you're after is covered in step 14 - add animation of my tutorial, though I used Absolute,X instead of Absolute,Y (either will work).

 

post-3056-0-51833900-1546980735.png

  • Like 1
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...