10

I've read that the usual way to execute code on the N64 is to use DMA to copy it from ROM into RAM, and then run from RAM.

However, it seems that the contents of the ROM are directly visible to the CPU (e.g. from address 0x9000_0000). Is it possible to run code directly from ROM (as was standard on the NES and Super NES) by jumping into this region of the address space?

If so, why did games generally copy code into RAM before running it?

1
  • 3
    I'm not sure about the specifics of the N64 architecture, but often RAM is quite a bit faster for the CPU to access than ROM. Oct 30 '19 at 23:24
7

Is it possible to run code directly from ROM [...] by jumping into this region of the address space?

Game Code can of course be run from ROM. And most games will do so.

If so, why did games generally copy code into RAM before running it?

Generally sounds a bit too much here. In fact, as game cartridges range from 4 MiB to 64 MiB (and more), the existing 4.5 MiB RAM couldn't hold not even the smallest games. Even more so as most of the RAM was used for video anyway.

The N64 is very much a streaming architecture with emphasis on continuous high speed access. The MIPS CPU, as well as the video processors, did benefit from the RDRAM feature of fast read for consecutive data (burst access). As a result, RAM was, when it came to continous access about twice as fast as ROM. A peak rate of 562,5 MiB/s could be reached when reading RDRAM while ROM access, due its 'classic' structure, only yielded with 264 MiB/s about half the rate (*1).

Games did foremost copy graphics data (textures etc.) into RAM to allow best possible rendering. After than, time critical routines were as well moved to improve speed - were needed.


*1 - Yes, 264 is half of 562,5, as the RAM was 9 (!) bit wide :))

6
  • 2
    I don't know if this is accurate. Zelda, for example, is known to copy code to RAM before executing it.
    – user253751
    Nov 1 '19 at 12:36
  • 2
    I'm afraid it's entirely wrong. Actually, most N64 games seem to copy code and artifacts via DMA into RAM and execute from there. Cartridge access speed is way too slow to effectively run from there.
    – tofro
    yesterday
  • Standard Nintendo bootcode (which is practically used for the majority of games) simply copies the first MB of memory from the cartridge to RAM and executes there. Granted, there are exceptions (but mainly used for copy protection).
    – tofro
    yesterday
  • @tofro Huh? Are you saying code can't run from ROM? Or that they never were executed from ROM? Or that entire games were loaded into RAM at once? Or that most stuff loaded into RAM are not assets (graphics, level data, sounds, etc)? What exactly is it you want to mark as wrong?
    – Raffzahn
    yesterday
  • The programming manual mentions in ch. 9: “The CPU executes application code directly from the DRAM…” The cartridge connects through the peripheral interface (PI). Ch. 8 mentions about PI: “This read-write interface connects to the ROM cartridge and other mass storage devices. It supports DMA as well as I/O Read/Write to ROM addresses.” … (continued)
    – WimC
    11 hours ago
1

It may be theoretically possible, but impractical.

The N64 cartridge interface time-multiplexes data and address on the same 16 pins. You send the first 16 bits of the address, then send the last 16 bits of the address, then receive the 16-bit result. The whole process takes around 1 µs. That translates to 1 MHz. The N64 CPU runs at 93 MHz. So this means cutting the CPU speed to 1% its normal speed while executing from the cartridge.

New contributor
Ed Halferty is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.