The memory view of the dot matrix arcade doesn’t update in real time and that just won’t do. It can be quite useful to see memory values change while the program is running and I’m sure I can make that happen. While I’m at it, I have some ideas for other features, too.
How many gates does it take to store one bit of memory? Two if you want to keep it simple, eleven if you want to do it right. Wait, that’s not funny. I guess it wasn’t a joke.
The dot matrix arcade is an 8-bit machine running at 2 MHz, because any faster would render it unusable. It has 256 bytes of memory and that’s for code and data combined. That’s not enough to do anything useful, but it’s plenty to do something interesting.
When I first discovered assembly language, it felt like the computer was exposed to me at its most fundamental level and now I could understand how it really works. All those elaborate structures of a high-level programming languages distilled into the most basic instructions. But then I thought: “Hold on, how does the computer execute that instruction?” I had to go deeper, and that’s where logic gates come in.
Even though an 8-bit computer is called an 8-bit computer because it works with 8-bit numbers, it’s not strictly necessary to make all numbers 8-bit. For example, it’s certainly reasonable to use a larger number for memory addresses, otherwise you’d be limited to only 256 bytes of memory. However, I’m not a reasonable man, so 256 bytes is all you get.
My 8-bit machine is dumping its output to the console at the moment. This isn’t much of a problem for the type of person who believes using a command line debugger is a marvelous experience, but I’m not targeting such mythical creatures with this project, so I’ll need to do some proper text rendering.
Initializing OpenGL on macOS wouldn’t be too hard, if only someone took the time to document it. Actually, that’s not fair. There are a few articles out there that describe how to do it, it’s just that they all start with: so, you open Xcode…
At this point, I’m not too worried about adding new instructions to my 8-bit machine; that’s going to be the easy part. I need a better user interface, though, and that means worrying about rendering. In particular, text rendering.
Even I don’t enjoy the low level so much that I want to remember which numbers represent which instructions, so I started writing an assembler for my 8-bit machine. Assembly code is pretty close to machine code; just in a more readable format. Here’s my little demo program in machine code.
If implementing a virtual machine sounds daunting to you, then this post is going to be a treat. Seriously, it isn’t hard at all. All we need is a struct, an enum, and a switch.
Oh, the excitement of starting a new project! There’s promise, there’s ideas, there’s no reason to believe this will succeed, but who cares?! Still, I should contain myself. Yes, be methodical, orderly, and... Screw that, I want to write some code! No no, first come up with a plan. Oh, alright then.