lc4-disassembler
README.md

LC4 Disassembler

A C program that loads and disassembles LC4 object files, converting machine code back into human-readable assembly instructions.

Overview

This project implements an LC4 (Little Computer 4) disassembler that:

  • Loads LC4 object files (.obj) into memory using a linked list structure
  • Parses the binary machine code
  • Converts the machine code back into LC4 assembly language
  • Displays the disassembled output

Files

  • lc4.c - Main program entry point
  • lc4_loader.c/h - File parsing and memory loading functionality
  • lc4_memory.c/h - Dynamic memory management using linked lists
  • lc4_disassembler.c/h - Machine code to assembly conversion
  • obj_files_for_testing/ - Sample LC4 object files for testing

Building

make

This will compile all source files and create the lc4 executable.

Usage

./lc4 <object_file>.obj

Example:

./lc4 obj_files_for_testing/test1.obj

Testing

The obj_files_for_testing/ directory contains various test files:

  • Basic instruction tests (test1.obj, test2.obj, etc.)
  • Factorial implementations (dmem_fact_ec.obj)
  • Graphics/drawing programs (user_draw.obj)
  • String manipulation (user_string_ec.obj)

Cleaning

make clean    # Remove object files
make clobber  # Remove object files and executable