Entrypoint function, here the state of the VM is declared. Command line arguments are LC-3 bytecode files to run.
The main loop of the program is in main.
A header file to give name and structure to our VM.
- 11 registers are given names
- 3 states for the condition register
- Structure to contain the state of the VM
- memory, a stack
- reg, the virtual registers (also on the stack)
- 2 special registers
op.h defines opcodes, and exposes apply_op to perform an operation.
op.c has implementations of the operations as defined by the spec.
trap.h defines trapcodes, and exposes the ‘trap’ function to execute them.
trap.c has implementations of the trap procedures.
Most of this I copied from here, (Go read that if you want to build your own VM), however I made everything take a pointer to the vm_state structure.