Jump to content

Photo

Loading an address with a variable offset


2 replies to this topic

#1 Karl G OFFLINE  

Karl G

    Dragonstomper

  • 818 posts

Posted Tue Jan 8, 2019 1:47 PM

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?

 



#2 SpiceWare OFFLINE  

SpiceWare

    Draconian

  • 12,748 posts
  • Medieval Mayhem
  • Location:Planet Houston

Posted Tue Jan 8, 2019 3:00 PM

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).

 

Screen Shot 2019-01-08 at 2.50.57 PM.png


  • Karl G likes this

#3 Karl G OFFLINE  

Karl G

    Dragonstomper

  • Topic Starter
  • 818 posts

Posted Tue Jan 8, 2019 5:12 PM

 

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).

 

 

It was indeed!  Thank you muchly.  :-)






0 user(s) are browsing this forum

0 members, 0 guests, 0 anonymous users