Here is the source code for the Micro-1 Processor and assembler:
Note: Assembler.java is extra credit and Console.java is given.
Note: Some students may replace Console.java by a GUI.
Note: Some students may incorporate an assembler into Console.java
My assembler is handy since solutions can be written in Micro-1 assembly language, then automatically translated into Micro-1 machine language.
Here's how to translate a file called demo.a1 containing Micro-1 assembly language instructions followed by data into a file called demo.m1 containing Micro-1 assembly language instructions followed by data:
java Assembler demo.a1 demo.m1
Now type the command:
-> load demo.m1
to the console's prompt.
Students were to submit three demo programs written in Micro-1 machine language (or assembly language if an assembler was included.)
Here is my version of the second demo program, which computes 2^N where N is any int stored in memory:
pow.a1 stores 5 in memory location 0x14:
cell[0x14] = 0x5
(Note: this is contrary to instructions that required some value to be stored in cell[100].)
After stepping through the program note that:
cell[0x15] = 0x20 = 32 = 2^5
As a second test I implemented a factorial program:
fact.a1 also stores 5 in memory location 0x14:
cell[0x14] = 0x5
After stepping through the program note that:
cell[0x15] = 0x78 = 120 = 5! = 5 * 4 * 3 * 2 * 1