Skip to content

Memory Banks

Michael Nix edited this page Apr 2, 2026 · 3 revisions

In order to run the game the NES needs both a CPU to run code and memory to hold the code and art assets. The memory is called RAM for random access memory. Random access means, that the CPU can read any part of the memory in any order, as opposed to older forms of memory like tapes, where you either read contiguous portions of memory or had to physically wind the tape forwards or backwards to access other regions.

This memory has to be fast, because both the code to execute and the graphics to draw on the screen have to be accessible and modifiable within one frame of game play. This makes RAM expensive and limits how much of it can be put into a consumer product, like the NES. That's why it has only 2KB of so called work RAM and 2KB of graphics RAM.

In theory that would mean, that games can only be (less than) 2KB in size, since the NES does not have a hard drive, like a computer would have. It does however have something similar, the cartridge the game comes on.

In case of SMB3, the NES is able to map two 2KB of the cartridge's read only memory, its ROM, into its own address space. That means the NES can access the data in those two 2KB areas, which we call memory banks, as if it was an extension of its own RAM.

Now the game could be 4KB in size, but that is still not enough. So the cartridge can do something clever. It can change which of its memory bank is visible to the NES. Depending on what part of the game the player is currently in, for example depending on the type of level that is currently played, the cartridge can show the NES the memory bank associated with that part only.

It's like a dictionary. If you try to find a word starting with "K" you only need the pages that have "K"-words on them, the rest is useless. So while the two pages full of "K"-words are visible to you if you open up the book, the rest of the pages, while still there and holding valuable information, are hidden from you.

This idea makes it necessary to put code and data, that will be used together, into the same memory banks, so they are visible to the NES at the same time, without having to switch back and forth all the time. We can see this in the ROM of SMB3, where all levels of the same Object Set will be in the same memory bank, next to the code that deals with the logic of assembling and updating the Level Objects of said object set.

The memory banks are also called PRG banks. If you looks at the Disassembly of SMB3, you can find the code divided into those PRG banks, each of which will be 2KB after being assembled into binary code.

Clone this wiki locally