The Brookshear Machine Model is a model of a simple computer with several GP-Registers and a small fixed-width instruction set. It is freqeuntly used by CS courses around the globe to teach students the basics of Computer Architecture. An example of this instruction set (which is not compatible with the implementation in this Repo though) can be found here. A compatible Brookshear machine can be found here: Github IO
An Assembler translates Assembly Code to raw bytes (Machine Language). My Python implementation follows the following instruction set.
All values are handled in two's complement representation unless stated differently.
OpCode | Operands | Description | Assembler Notation |
---|---|---|---|
1 | RXY | Load Byte from Addr. XY into Reg. R | LOAD R, XY |
2 | RXY | Load value XY into Reg. R | LOADI R, XY |
3 | RXY | Store content of Reg. R into Addr. XY | STORE XY, R |
4 | 0RS | Move content of Reg. R into Reg. S | MOVE S, R |
5 | RST | Add contents of Reg. S and Reg. T and store result in Reg. R | ADD R, S, T |
6 | RST | Add contents of Reg. S and Reg. T and store result in Reg. R (values in IEEE 754 8-bit FP format) | ADD-FLOAT R, S, T |
7 | RST | OR contents of Reg. S and Reg. T and store result in Reg. R | OR R, S ,T |
8 | RST | AND contents of Reg. S and Reg. T and store result in Reg. R | AND R, S, T |
9 | RST | XOR contents of Reg. S and Reg. T and store result in Reg. R | XOR R, S, T |
0xA | R0X | Rotate content of Reg. R to the right by X places | ROTATE-RIGHT R, X |
0xB | RXY | JUMP to Addr. XY if content of Reg. R equals content of Reg. 0 | JUMP XY, R |
0xC | 000 | Halt program execution | HALT |
- A comment begins with a semicolon ';' and includes all of the remaining line
Currently, the assembler doesn't support labels.