These are my project notes for NORCAL: a C compiler that targets the NES, with its 6502-like CPU.
January 15, 2019
I am setting up my toolchain: compiler, simulator, test harness.
January 17, 2019
For running automated tests, I've put together a very simple "headless" NES simulator. I took an open source 6502 CPU simulator and configured its memory map to match the NES. To specify the program, you give the sim a standard iNES file, just like any other NES emulator. This won't work for testing any graphical or special-purpose hardware -- only the CPU, RAM, and ROM. This should be enough to test all compiler features.
January 18, 2019
These are my priorities for the compiler:
Obviously, they will often conflict.
January 22, 2019
Parsing isn't interesting, but I need to be able to parse source code in order to run automated tests. For now, to allow me to use a very simple (and quick to implement) parser, programs will be written in a simple S-expression syntax. Hopefully I can get this parser working in just a couple days so that I can move onto code generation.
January 23, 2019
As I hoped, the simple parser was easy to implement. I've moved on to generating code for loading and storing values through pointers. For example:
*0x6000 = 123; *0x6000 = *0x6000;
Simple, untyped assignment expressions.
These kind of expressions won't work once the compiler starts enforcing C's type system, but for now they are useful test cases.
February 4, 2019
It didn't take long for me to get tired of the temporary syntax, and it didn't extend well to handling blocks and function declarations. I've now written a lexer and parser that will parse legitimate C grammar.
If you have comments, questions, or suggestions regarding this topic, please email me at email@example.com!