Close

Assembler

A project log for Instruction Set for ECM-16/TTL homebrew cpu

All the instructions laid out in systematic manner

pavelPavel 10/27/2022 at 13:280 Comments

Previously, when computer model was quite different from what it evolved into today, I wrote an assembler in C++ to be able to write somewhat complex programs (such as simple calculator able to perform additions, subtractions, multiplications and divisions on integers) that could be run on a model in simulator.

Now, I have built the model to a degree, when there are quite a few instructions are supported, but many are probably buggy. For the testing purposes, I need to have a machine code for lot of instructions, and crafting it by hand by perusing instruction descriptions and layouts is fairly time consuming process that is prone to errors (such a chore!). As I am debugging the memory access operations, as they are quite complex, with all the data shuffling between registers, buggy instructions are very much complicating the task.

So, to automate the task of converting mnemonics to actual machine instructions, I am started to write a new assembler, from scratch, now in Rust. For now it just reads in a single instruction and outputs the machine code for it. Here is an example of its work:

This assembler now can encode most of the instructions, exception for the moment are Pointer Arithmetic and Miscellaneous instruction groups.

The immediate plan is to add the instructions from these two last groups -- for now the current functionality might suffice, as the task is debug execution of single instructions.

EDIT (2022-11-06)

Slightly upgraded the assembler so that now it possible to enter multiple lines (a small program) and assemble them all at once by pressing Enter two times in row. 

Now it looks like this:

The lowermost part of output (starting with "v2.0 raw" line) is formatted so that when saved to file with .hex extension, it can be loaded into ROM component in simulation. 

The end goal is to create proper assembly code editor/assembler (windowed application), that will have current mnemonic decoder as its core.

Discussions