This repository contains a simple implementation of the Little Computer 3. With its simple instruction set the VM is fairly straight-forward and the code speaks for itself.
There's a few examples of assembly projects in the /asm/
folder.
.ORIG x3000 ; Address of the first instruction
HELLO_STR .STRINGZ "Hello, World!" ; Define "Hello, World!" string
LEA R0, HELLO_STR ; Load address of HELLO_STR to R0
PUTs ; Print R0 to STDOUT
HALT ; Halt program
.END
To actually run the code, it has to be built into an .obj file. Those are included in the /obj/
folder.
- Better keyboard I/O
The VM doesn't automatically send the keyboard input from the syscall, it waits for the user to press enter.
- Logging
This section needs the biggest improvement. The only thing that should go into STDOUT is the actual print syscalls made by the programs. Everything else should be a debug log only available under a special flag.
Clone the repository
> git clone https://github.com/hum/lc3-vm
> cd lc3-vm
Build the binary
# or "make run" for the hello world example
> make build
Run the programs from /obj/
> ./bin/lc3_vm ./obj/2048.obj
If you wish to convert your own .asm
files into .obj
files then you can do so by downloading the codebase from here.
> cd lc3tools
> ./configure --installdir /path/to/loc/
> make
> make install
Now you will have ./lc3as
in your /path/to/loc/
which you can use to generate the .obj
files