Jump to content
IGNORED

Indirect index pointer offset


Recommended Posts

Slight dilemma. If I'm using an indirect pointer with the Y index and I need to offset the pointer because the Y index isn't inline with the true pointer, then does the page value just wrap itself to do this or does the high byte need to be adjusted too. Technically, no page boundary  access would occur. 

Ex: data to be accessed is located on any arbitrary page of the 4k rom space starting at 00 to say 0B. This is 12 bytes worth. Likewise, the pointer in ram would have 00 be the start (or end) with whatever page the hi byte is as the 2 byte pointer. Providing the y index is exclusively set to index this data, everything would work as normal.

However, if the Y index is decrementing from 30,  then the pointer would need to be offset before hand so that the data reads correctly. It would stop before going below the pages 00 address so as not to access data across a page boundary.  So does the 2 byte pointer only need the low byte changed or both the high byte and low to compensate this? Sorry if the explanation is overly complicated. I don't want to incurr any extra cycles.

Link to comment
Share on other sites

8 hours ago, grafixbmp said:

... does the page value just wrap itself to do this or does the high byte need to be adjusted too.

Indexed addressing isn't confined to a page (it doesn't wrap around). You must necessarily change also the high byte, and you'll get a 1 cycle penality because of page crossing when the Y index is added to the base address.

 

e.g.

Suppose the data table is at the beginning of the rom ($f000-$f00b). If you access it using indirect,Y addressing, with Y ranging from 30 to 19 ($1e to $13), the pointer would need to point to address $efed.

 

To avoid the extra cycle, move the data table away from the beginning of the page so that you don't get page crossing. In the example above, make it start at least from address $f013, so the pointer points to the same page of the final address.

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