Inspiration

I was inspired by the Pico-8 project. The idea of a lightweight virtual console that users could plug-and-play code into under creative restraints has always been interesting to me, and I wanted to see how I could extend it. I also wanted practice in writing simple interpreters/assemblers, and brushing up on my C and 8080 assembly seemed like a great way to do that.

What it does

The Program Known As BASM consists of two parts; the previewer, which features custom syntax highlighting, checking for code correctness, and error linting, and the BASM engine, which parses, compiles, and interprets user code.

Under the hood, the BASM virtual processor has an architecture similar to the NES, albeit heavily simplified. Users are given a few kilobytes of memory to work with, and a lightweight graphics engine lets them create and animate simple sprites. The language itself is closely modeled after 8080 assembly, with the advantage of being able to abstract in software the more frustrating parts of working with decades-old processors.

How we built it

The Program Known As BASM is a hodgepodge of an entirely bespoke UI and text rendering framework written with SDL2 and an equally customized interpreter, principally powered by pointer mayhem and pretending the memory leaks aren't real.

Challenges we ran into

It turns out writing an assembler in less than two days is very hard for someone with little experience, particularly when I spent half that time writing GUI code! I'm much more used to Python and TypeScript, so the shift to C, a language I'm less familiar with, and embracing the archaisms and quirks that come with it was a welcome challenge, but a challenge nonetheless. Memory management was a consistent issue, as was passing data to and from the multifarious parts of the application.

Accomplishments that we're proud of

I've learned more about writing GUI projects from scratch in the past 36 hours than I ever have in my years of various projects before. I feel a lot more comfortable working closer to memory in C and with writing simple parsers, and I'd love to explore programming language development even further in the future.

I'm personally very proud of the syntax highlighting -- that's all custom, and it wasn't easy! There's a lot of strange hacks under the hood to make it all come together.

What we learned

C is a difficult language! The actual assembly was the least complicated part of this project, contrary to expectation.

What's next for BASM

I didn't implement as many of the features as I wanted to (the assembler remains maybe 70% finished), but this project really interests me, and I want to work on it even further! The most obvious next step is getting some nicer graphics in there, and maybe even allowing for live editing from within the application.

Built With

  • asm
  • c
  • sdl2
Share this project:

Updates