In order to install this, either download the binaries from the GitHub page or have Go installed and run the following command:
go get github.com/thee-engineer/mu0
After either installing or compiling the program:
mu0 build source.s source.o # This will compile the given source to a binary
mu0 run source.o # Execute the binary
Nothing special other then Go is required to build both the compiler and VM.
git clone git@github.com:thee-engineer/mu0.git
cd mu0
go build mu0.go
mu0
is both a VM for the MU0 Micro Processor (single
accumulator register, PC register and no SP originally or any other capabilities).
mu0
also acts as a compiler for the small assembly instruction set (4 bit). The compiler
has extra instructions and compiler directives defined, and some aliases for ARM ASM.
Code | Mnemonic | Use | Description |
---|---|---|---|
0000 | LDA | LDA S | Load the value S into the ACC |
0001 | STA | STA S | Store the value from ACC into S |
0010 | ADD | ADD S | Add S to ACC (ACC = ACC + S ) |
0011 | SUB | SUB S | Sub S from ACC (ACC = ACC - S ) |
0100 | JMP | JMP S | Set the PC to the value of S |
0101 | JGE | JGE S | Set the PC to the value of S if ACC >= 0 |
0110 | JNE | JNE S | Set the PC to the value of S if ACC != 0 |
0111 | STP | STP S | Stop the program from running. S will be the exit code |
1000 | BRK | BRK | Pause the program execution, action must be taken |
1001 | SLP | SLP S | VM level implementation of sleep to avoid idle-spin, sleep S ms |
1010 | JML | JML S | Set the PC to the value of S but save the PC+1 to LR |
1011 | RET | RET S | Set the PC to the value of LR and set the LR to S |
The boards provided by the University of Manchester (which inspired me to make this program) look like this: