To compile assembly code for the NES's 6502 processor, you'll need the
cc65 toolchain. That will provide the ca65 compiler and ld65
linker used by these scripts.
On Mac you can install cc65 using Homebrew:
$ brew install cc65
Save the Super Mario Bros. ROM that you've extracted from your cartridge to
original.nes.
Extract the iNES header from the ROM to a file.
$ python3 extract_hdr.py original.nes && mv original.hdr smb.hdr
Wrote 16 bytes to original.hdr
Extract the CHR-ROM data from the original ROM to a file.
$ python3 extract_chr.py original.nes && mv original.chr smb.chr
PRG-ROM: 2 bank(s) (32768 bytes)
CHR-ROM: 1 bank(s) (8192 bytes)
Wrote 8192 bytes to original.chr
The original "Comprehensive Super Mario Bros. Disassembly" uses older directives that cc65 can't process.
Retrieve the .asm file from
https://gist.github.com/1wErt3r/4048722
and save it as smbdis_original.asm.
Then run this script to re-write it with directives cc65 can handle.
$ ./update_asm.sh smbdis_original.asm > smbdis.asm
If this isn't your first time compiling, remove any previous ROM you've generated.
$ rm smb.nes
Finally, run this script to compile everything into a playable ROM.
$ ./build.sh
Now you can try your new ROM in an emulator!
$ /Applications/Mesen.app/Contents/MacOS/Mesen smb.nes &