# Into Emulators: Implementing a chip8 virtual machine
I've recently decided I'd try and learn more about low-level programming through implementing emulators.
I thought of starting with the Gameboy, but quickly realized that would be a bit too big a jump for my taste. For context, when I started this, I still hadn't had a proper first year at college yet; all my CS and programming skills/knowledge were self-taught (and still are, mostly), and I have found it very hard to learn about CPU internals, Assembly, and other Computer Engineering concepts in that way. Now, halfway through my first year, I've already assimilated what was missing for the Gameboy project through my first Computer Architecture class, and that could possibly be my next project.
But I digress. Chip8, back then (a few months ago...), seemed like a much more realistic "architecture" to try and emulate; the Gameboy having a separate processor for graphics was already enough to scare me off a bit. Looking back, that was a bit of an over-reaction, but chip8's simplicity is undeniable. 35 opcodes, a hex keyboard for input, a 64x32 monochrome display; it was a lot easier to wrap my head around it and start implementing it. So I did. Well, I am. I'm trying to.
## The actual project
[chippy] is completely written in C, just like my other projects so far, and it uses [raylib] for windowing. As of the time I'm writing this, it can't actually emulate jack shit. All it can do is read one single instruction: a MOV, represented in hex as 0x6XNN, where X is the register to MOV the data into and NN is the data (a constant, not another register nor a location in memory). I've implemented a barebones CPU (basically just its registers), a simple stack, RAM and ROM, and a few utility functions for initializing and managing those peripherals. There's also a tiny window for visualizing the registers and stack:

That's genuinely kind of it so far, I haven't had time to work on it at all with uni actually getting interesting and challenging. I plan on finishing this project over the reading week though, during which I'll document it all in here.
next post: [Into Assemblers]
# ~/posts/into_emulators.md