Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 

Repository files navigation

LC-3 VIRTUAL MACHINE

A simple lc-3 vm made by following the blog (https://www.jmeiners.com/lc3-vm/) by Justin Meiners and Ryan Pendleton.

GETTING STARTED

Dependencies
Electricity and an OS installed (preferably Linux idk about Windows)

HOW IT WORKS

[Image: LC-3 Instruction Format - gh.png]

This project implements the CPU execution loop (Fetch, Decode, Execute). It includes:
* 64KB Memory Array: Simulating the 16-bit address space of the LC-3.
* 10 CPU Registers: 8 general-purpose registers (R0-R7), a Program Counter (PC), and a Condition Flags register (COND).
* Complete Instruction Set: Implements all core LC-3 opcodes (ADD, AND, JMP, BR, LD, LDI, LDR, ST, STI, STR, etc.).
* Memory-Mapped I/O: Simulates keyboard status and data registers for handling asynchronous terminal input.
* Trap Routines: Simulates basic OS-level system calls for console I/O and program halting.

A NOTE ON THE ASSEMBLER

This repository contains the Virtual Machine (the processor), not an assembler. 

Because of this, the VM does not read human-readable assembly text (e.g., ADD R0, R0, 1). Instead, it executes raw 16-bit binary instructions directly from memory. To run programs on this VM, you must pass pre-assembled .obj files containing the compiled machine code, which the VM will load into its virtual memory array starting at the origin address (usually 0x3000).

BUILDING AND RUNNING

Compile the VM using any standard C compiler (like GCC):

    gcc -O3 lc3.c -o lc3-vm

Run the VM by passing an assembled LC-3 object file as an argument:

    ./lc3-vm path/to/program.obj

AUTHORS
Me, i guess?

ACKNOWLEDGMENTS
I followed them, so credit goes to them (i copied the whole thing but ok T-T)

Ryan Pendleton (https://github.com/rpendleton)
Justin Meiners (https://github.com/justinmeiners)

About

My first virtual machine, made by following the instructions on the blog Write your Own Virtual Machine by Justin Meiners.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages