nesdev.com
http://forums.nesdev.com/

What addressing mode should I use here?
http://forums.nesdev.com/viewtopic.php?f=10&t=17260
Page 1 of 1

Author:  SusiKette [ Sat Apr 14, 2018 3:18 am ]
Post subject:  What addressing mode should I use here?

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?

Author:  tokumaru [ Sat Apr 14, 2018 7:18 am ]
Post subject:  Re: What addressing mode should I use here?

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

Author:  SusiKette [ Sun Apr 15, 2018 1:07 am ]
Post subject:  Re: What addressing mode should I use here?

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

Page 1 of 1 All times are UTC - 7 hours
Powered by phpBB® Forum Software © phpBB Group
http://www.phpbb.com/