Writing a compiler for a fake assembly language


General Overview

As a quick note this post is just a mind dump so I dont ramble to people I know too much.

So ive been working on a programming game for a while now called SandeeeOs. In this game I wanted the focus on programming to be open to people who are advanced programmers and those who dont even know what a pointer is. So I decided on writing a vm to run a fake assembly language. I wanted Sandeee to stand out among all the other assembly programming games, so I had the crazy idea to allow strings to be pushed on to the stack as if they were numbers.

How though

So the base VM is a structure containing the following:

  • A stack
  • A return stack
  • A list of assembly operations
  • Some other values for misc operations

Running files

managing strings

Strings are an annoying structure to deal with, I had to decide on a system for embeding them into the executable files, I decided on null terminated strings (though I may switch to storing length).

Instruction format

You will also run into the issue of differentiating instructions that take in 1 value, no value or a string, this was a tough problem to get over. I decided the top 2 bits of each instruction will determine the data associated with it. For example if they are 0 in binary, then there is no value, and the assembler will assume the next instruction is 1 byte ahead.

This resulted in the following binary format:

But this problaby makes no sense, so I will follow up next week with a self hosted assembler.

Get SandEEE OS

The Operating System will be available in 264 days.

Leave a comment

Log in with itch.io to leave a comment.