What addressing mode should I use here?

Are you new to 6502, NES, or even programming in general? Post any of your questions here. Remember - the only dumb question is the question that remains unasked.

Moderator: Moderators

Post Reply
User avatar
SusiKette
Posts: 110
Joined: Fri Mar 16, 2018 1:52 pm
Location: Finland

What addressing mode should I use here?

Post by SusiKette » Sat Apr 14, 2018 3:18 am

I want to buffer different kinds of data in RAM ready for the NMI to update. I want to use the same subroutine to buffer all data and use variables to tell the subroutine where to buffer the data and how many bytes. So I need to store the address of the data table to RAM in order to read from it, but what addressing mode gets the actual address in ROM rather than what is stored at that location?

User avatar
tokumaru
Posts: 11859
Joined: Sat Feb 12, 2005 9:43 pm
Location: Rio de Janeiro - Brazil

Re: What addressing mode should I use here?

Post by tokumaru » Sat Apr 14, 2018 7:18 am

I don't know if this is what you're looking for, but to get the address of some data instead of the data itself, you can use lda #<Label and lda #>Label to get the low and high bytes of the address, respectively. NESASM, as usual, does it differently, using LOW() and HIGH() instead of < and > I think.

This is not an addressing mode though, since these ultimately become simple immediate loads for the 6502, this is just a feature that assemblers have that makes our job easier.

To use that address later, you can get those 2 bytes and create a pointer in Zero Page, and access the data using lda (Pointer), y ([] instead of () in NESASM, obviously).

User avatar
SusiKette
Posts: 110
Joined: Fri Mar 16, 2018 1:52 pm
Location: Finland

Re: What addressing mode should I use here?

Post by SusiKette » Sun Apr 15, 2018 1:07 am

That's exactly what I was looking for, thanks :)

Post Reply