Mano Compiler

A sample of resulting assembly code.

Mano Compiler was a project I did for two courses, Computer Organization and Theory of Computation. It is a proof-of-concept compiler that converts a simple high-level language into the 25-instruction assembly dialect accepted by the Mano Machine. The result can then be assembled and executed on a simulator.

The language supports integer, array and string data types, functions, and textual output of any variable. Being a proof of concept, it also has some flaws, including sharing of local variables (but not arguments) between instances of the same function during recursion and lack of support for reading input.

The compiler is written in Python 2 and does not use anything outside the standard library. It is portable to any platform that supports Python, and can be used to generate large amounts of assembly code to test new implementations of the machine or its simulator.

Although it has little practical use, it may have educational value as an example of a very simple compiler that covers the whole path from reading plain text source code to emitting final assembly code in about 1K lines of code.


The compiler is invoked from the command line and passed the name of the file containing the source code to be compiled, and optionally the name of the output file. The -O flag can be used to produce optimized code.

Once compiled, the code can be run using a simulator. However, due to the lack of linking, the runtime library used by the compiler (included in the distribution) has to be loaded manually. In manosim.exe, the whole sequence of assembling, loading and running a compiled program looks like this:

* source lib
[Some assembly information, including identifier list.]
* source compiled_filename
[Some more assembly information.]
* go
[Output of the program goes here.]




There are several simulators for the Mano machine, although each has its own problems: