News: 11 March 2016 - Forum Rules
Current Moderators - DarkSol, KingMike, MathOnNapkins, Azkadellia, Danke

Author Topic: Question about SNES RAM memory address vs ROM address  (Read 1409 times)

geoffreyloka

  • Newbie
  • *
  • Posts: 1
    • View Profile
Question about SNES RAM memory address vs ROM address
« on: June 15, 2020, 12:34:49 pm »
Hello,

Greetings community

If you are making an emulator, does the ROM's machine code reference it's own addresses? Does it refer to locations that it gets mapped to in SNES memory?

When manuals are talking about Direct Paging, absolute, long, etc addressing modes -- they are referring to the SNES's WRAM memory, is this correct? auto clicker

So when interpreting the machine code of a ROM, do you have to convert to SNES memory locations?
« Last Edit: June 17, 2020, 10:07:43 pm by geoffreyloka »

FAST6191

  • Hero Member
  • *****
  • Posts: 2813
    • View Profile
Re: Question about SNES RAM memory address vs ROM address
« Reply #1 on: June 16, 2020, 07:35:11 pm »
Nice overview of the various things seen on the SNES
https://en.wikibooks.org/wiki/Super_NES_Programming/SNES_memory_map

Mixture of both.

Generally a ROM will reference the location that the system would have the ROM appear in RAM after any fancy addressing/banks/pages/windows/whatever are taken care of.

Floppy disc, CD/dvd/optical and later in history the DS would have a read command that references the ROM addresses (give or take sectors, headers and the like), as well as usually a file system (though some homebrew devs will invent a file system on older devices).

You can however have calculated pointers where a game will have a base pointer and add data found in the ROM to the value to generate the final address. In some ways this can be a bit slower but does afford a few more options for some approaches; if you have taken programming far enough to learn about linked lists then that would be an example, imagine say jumping around in a text field and having to read off pointers when you could say take base pointer, multiply pointer length by pointer value I need and then add that value to the pointer and grab that new location.

WRAM is generally a section of memory rather than the whole memory system. I don't know what goes for games punting a section of code into WRAM and running from there offhand (was seen on the GBA and I presume it is possible but the esoterics of the SNES are not my thing).

Raeven0

  • Jr. Member
  • **
  • Posts: 27
    • View Profile
Re: Question about SNES RAM memory address vs ROM address
« Reply #2 on: June 16, 2020, 09:57:25 pm »
If you are making an emulator, does the ROM's machine code reference it's own addresses?
No.

Does it refer to locations that it gets mapped to in SNES memory?
Yes.

When manuals are talking about Direct Paging, absolute, long, etc addressing modes -- they are referring to the SNES's WRAM memory, is this correct?
No. A CPU instruction's addressing mode describes how it calculates a target address. Every instruction has an addressing mode.

So when interpreting the machine code of a ROM, do you have to convert to SNES memory locations?
Yes.

As a thought experiment, consider what the 65816 processor (and your emulator) should do if it encounters the perfectly legitimate instruction jsl $ffffff, i.e. the byte sequence 22 ff ff ff.

Gideon Zhi

  • IRC Staff
  • Hero Member
  • *****
  • Posts: 3525
    • View Profile
    • Aeon Genesis
Re: Question about SNES RAM memory address vs ROM address
« Reply #3 on: June 17, 2020, 01:08:46 pm »
If you are making an emulator, does the ROM's machine code reference it's own addresses? Does it refer to locations that it gets mapped to in SNES memory?

This. ROM, WRAM, VRAM, SRAM, stack, OAM, hardware registers, *everything* gets mapped somewhere within the SNES's address space and is referenced by its location within that address space.