Sunday, July 26, 2020

An Intel 8080 Assembler and Online Simulator

While going through Charles Petzold's "Code" book again, I was looking for an easy-to-use online assembler and simulator for the classic Intel 8080 CPU, but couldn't find anything that fit my needs exactly. There are some well-done tools out there, but they seem to be more geared to running game ROMs and earge programs on an emulator; my need was different - I just wanted something to play with, to practice 8080 assembly programming.

So I ended up rolling my own, and the js-8080-sim project was born. The project has three main parts:

  • An assembler for the 8080: translating assembly language code into 8080 machine code. I wrote a custom assembler for this.
  • A CPU simulator: simulating 8080 machine code. For this purpose I cloned the maly/8080js project into my repository and tweaked it a little bit.
  • A simple web UI for writing 8080 assembly code, running it and observing the results (as changed values in memory and registers). I wrote a basic UI in JS:
js 8080 web UI screenshot

If you want to play with the simulator, a live version is available online at https://eliben.org/js8080

The UI is purely client-side; it makes no requests and just uses your browser as a GUI. It does use the browser's local storage to save the last program you ran.

Issues and PRs on Github welcome!

On JavaScript and frameworks

Using JS for a project like this is very natural, because ultimately what I'm interested in is having a convenient web UI to play with the simulator. When I do this, I almost always end up writing vanilla HTML+CSS+JS, avoiding frameworks. I don't write JS often, so whenever I get to work on a new project, the framework do juor has typically changed from the last time, and I just don't have the time to keep track. Vanilla HTML+CSS+JS has much better longevity, IMHO, although it does mean somewhat more manual work (e.g. to keep the UI in sync with the application state).

The only framework I was tempted to use is Bootstrap for the CSS and layout, but eventually decided against it in the interest of simplicity.

We're fortunate to have much more stable and usable JS and web APIs in 2020 compared to just a few years ago. For the simulator I've been using the ES6 version of JS, which is widely supported today and offers many niceties.




from Hacker News https://ift.tt/30P5OBQ

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.