skilldrick/easy6502 — pull request #9 by wahajenius (2014-11-13 22:20:20+00:00)
Title: Added modified assembler with preprocessor facility and adapted Snake650...

Hello Nick,

Thanks for your inspiring tutorial, and especially the Snake6502 program! So far I hadn't really studied the 6502 yet, but I now have to concur: 6502 programming is a lot more fun than x86. And the virtual machine with assembler in JavaScript is an excellent playground. I'm now seriously contemplating to take a stab at Conway's Game of Life.

However, as I worked my way through the Snake6502 code, I found myself constantly referring back to the comments at the top in order to understand what went on. What a shame, I thought -- if you'd just replace all the repeated hardcoded values by symbolic constants, the code instantly becomes a lot more readable. All it needs is a little macro preprocessor.

So, I set to work, and I'm extremely happy with the result contained in this pull request. Symbols can be declared as "define someKey someValue". You can then use "{someKey}" in place of "someValue". Comments are stripped off from defines, so you can freely add comments as usual without causing surprising behaviour upon expansion.

I hope you like it!

Kind regards,

Willem Alexander Hajenius.