Cli emulator for the micro computer 2i used in the computer science hardware course at Leipzig University.
Register: Eingaberegister: Aktuelles Mikroprogramm:
R0: 00000010 FC: 00000101 doc/examples/multiply.2i
R1: 00001100 FD: 00001100
R2: 00100100 FE: 00000000 Nächster Befehl (00110):
R3: 00000000 FF: 00000000 00 01000 | 00 | 000 1111 01 | 01 0100 | 0
R4: 00000000 ~ R0 = R0 + FF; JMP 01000
R5: 00000000 Ausgaberegister:
R6: 00000000 FE: 00111100 Flag (Register) | Interrupt: A/010, B/111
R7: 00000000 FF: 00000000 C: 0 (0), N: 0 (0), Z: 0 (0) | INT: 0, 0
The project can be built using cargo
. You can also use one of the binaries
provided for convenience.
cargo build --release
Note that you need at least rust 1.15.0. Use rustup
on windows or if the
packages of your distribution are too old.
You can specify the filename of the program you want to load as a parameter on the command line:
./2i-emulator doc/examples/answer.2i
Or use the built-in load
command:
./2i-emulator
> load doc/examples/answer.2i
You can also generate LaTeX documents for your 2i
-programs:
./2i-emulator latex --autor "Erika Mustermann" answer.2i multiply.2i
See ./2i-emulator --help
for more details.
The following example (answer.2i
) calculates the number 42
and writes it
to the output register FE
.
# The answer to everything: (FE) = 42
00000: 00 00001 | 00 | 000 0101 01 | 01 1100 0
00001: 11 00010 | 00 | 000 0000 01 | 00 0100 0
00010: 00 00001 | 00 | 000 0000 01 | 00 0101 0
00011: 00 00100 | 00 | 000 0000 01 | 00 1000 0
00100: 00 00101 | 00 | 000 0000 01 | 00 1000 0
00101: 00 00110 | 00 | 001 1110 01 | 01 1100 0
00110: 00 00000 | 11 | 001 0000 00 | 00 1100 0
Any character but 0
, 1
and :
is ignored inside commands and can be used
for formatting. Every command can optionally be prefixed with its address
followed by :
. These must be strictly nondecreasing. Commands without an
explicit address are assinged the next one. An empty line and everything after
#
is ignored.
The doc folder contains a german documentation of the micro computer and its
instructions. The api documentation of the emulator can be generated using
cargo doc
.
This program by Klemens Schölhorn is licenced under the terms of the GPLv3.