NES Hello World

The program below is written for xa65, a 6502/R65C02/65816 cross-assembler. It should be portable to other 6502 assemblers with minor tweaks. (The xa65 website is down as of the time of writing, but the program can be found in many places on the web, or from your friendly neighborhood Linux distro's package system.)

Some Notes

The $200X addresses used below are magic registers which control the NES's video memory. See NES PPU for details on their function, and for some brief info on how images are stored in the NES. (It's complicated.)

This program eschews the normal method of storing graphics in ROM (called CHR-ROMs) in favor of copying the graphics from PRG-ROM into CHR-RAM. There is not really a good reason for this, except you have to deal with fewer bank files.

hello.nes

To get the above code to work in an emulator, just assembling it isn't quite enough. You need to wrap it with a header that gives the emulator a little more information about your program. This is beyond the scope of this writeup.

Here is the assembled ROM, gzipped and base64 encoded. Save this into hello.b64 and run base64 -d hello.b64 | gunzip > hello.nes, then use your favorite NES emulator.