Jump to content
Sign in to follow this  
Karl G

Loading an address with a variable offset

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?


Share this post

Link to post
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).


[attachment=613753:Screen Shot 2019-01-08 at 2.50.57 PM.png]

Share this post

Link to post
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.

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.

Sign in to follow this  

  • Create New...