Foundations

Welcome to LC-3

Introduction to the LC-3 architecture and why we learn assembly.

What is the LC-3?

The LC-3 (Little Computer 3) is a simplified computer architecture designed for teaching. Despite its simplicity, it has all the essential features of real processors — registers, memory, an ALU, and a full instruction set.

Learning LC-3 assembly gives you a deep understanding of how computers actually execute programs. Every high-level language — Python, JavaScript, C — eventually becomes machine instructions like these.

Architecture Overview

The LC-3 has:

  • Memory: 65,536 locations (2^16), each storing a 16-bit value
  • 8 General-Purpose Registers: R0 through R7, each 16 bits wide
  • Program Counter (PC): Points to the next instruction to execute
  • Condition Codes: Three flags — N (negative), Z (zero), P (positive) — set by most instructions
  • 15 Instructions: That's it. Everything a computer does comes from just 15 operations.
  • Every LC-3 instruction is exactly 16 bits. The top 4 bits specify the opcode (which instruction), and the remaining 12 bits encode the operands.

    The Instruction Categories

    LC-3 instructions fall into three groups:

  • Operate: ADD, AND, NOT — arithmetic and logic on registers
  • Data Movement: LD, LDI, LDR, LEA, ST, STI, STR — move data between registers and memory
  • Control: BR, JMP, JSR, JSRR, RET, TRAP — change the flow of execution
  • Your First Program

    Here's the simplest LC-3 program — it halts immediately:

    .ORIG x3000    ; Program starts at address x3000
    HALT           ; Stop execution
    .END           ; End of source

    Every program starts with .ORIG (the starting memory address) and ends with .END. The HALT instruction (actually TRAP x25) tells the computer to stop.

    Quiz

    How many general-purpose registers does the LC-3 have?