Back to the ’74 with a 8080 emulator – part 1
Back to the ’74 with a 8080 emulator – part 1

Back to the ’74 with a 8080 emulator – part 1

2019, Sep 24    

I decided to take a walk down memory lane, precisely back to ’74. I named my horse 8080, like the planet .

Well, actually it’s not a horse but an emulator, my first emulator ever 🙂

It all started when I saw this article on Scott Hanselmann’s blog, about this very smart guy who’s trying to emulate a PSX with C# and .NET.

I never wrote an emulator before and honestly, I had no clue how these things work. A PSX might be a little out of my league right now so I started digging a bit, looking for something very simple.

Apparently, the Intel 8080 is the perfect learning platform.

the Intel 8080 processor, image courtesy of Wikipedia<figcaption>the Intel 8080 processor, image courtesy of Wikipedia</figcaption></figure>

The 8080 architecture is relatively simple, 8-bit for basically everything, running at 2MHz.

It had a widespread use since its early days, but in 1978 it became the pivot of one of the first arcade, Space Invaders!

I guess everyone knows Space Invaders, so probably no introduction is needed.

On GitHub there’s a lot of 8080 emulators, mainly in C, but there’s also something in C# or Rust as well.

I’m coding mainly in C# these days, and honestly for my first tentative, I didn’t wanted to move to another programming language. My goal was to get a decent understanding of how emulators are coded. Also, bringing back from the ol’ college days binary/hex math and bitwise operations is always a good idea.

Obviously I didn’t wanted to just clone an existing emulator. So I started looking online for references about the 8080 and Space Invaders in general and eventually I found this website.It’s full of resources and complete tutorials about the 8080 emulation. It helped a lot .

So after a week of tinkering and debugging, I managed to write an initial prototype. As of now is not rendering anything, just processing the first 45k instructions and displaying the CPU state.

How am I testing it? Well, internet is full of crazy people. Apparently someone wrote another 8080 in javascript, but this is more like a debugging tool. I used this one to assert that I was implementing the OPs correctly and the CPU was always in the right state.

All the code is available as usual on Github. I’m not focusing on clean code right now. And (dear God forgive me) I’m not doing TDD.

I’ll make sure to refactor it once I get to see some real results on the screen, for now I just want to make sure all the 50 Space Invaders ops are implemented correctly.

Next step is to render something 🙂

Did you like this post? Then