# Little Man Computer (LMC) Guide: Architecture & Assembly
> Learn computer science fundamentals with this guide to the Little Man Computer (LMC), covering Von Neumann architecture, instruction sets, and assembly.

Tags: little-man-computer, computer-architecture, assembly-programming, von-neumann, cpu-design, computer-science, lmc-tutorial
## Little Man Computer (LMC) Architecture Guide
* **Overview**: A simplified educational model created by Dr. Stuart Madnick (1965) to teach the Von Neumann architecture.

## Hardware Components
* **Memory (Mailboxes)**: 100 locations (00-99) storing 3-digit numbers (000-999).
* **Accumulator (ACC)**: The primary working register for calculations.
* **Program Counter (PC)**: Stores the address of the next instruction.
* **Instruction Register (IR)**: Holds the current instruction being executed.

## The Fetch-Decode-Execute Cycle
1. **Fetch**: Retrieve instruction from mailbox pointed to by PC; increment PC.
2. **Decode**: Interpret the operation and address in the IR.
3. **Execute**: Perform the specific task (e.g., ADD, SUB, STA).

## Instruction Set & Opcodes
* **ADD (1xx)**: Add value at address xx to ACC.
* **SUB (2xx)**: Subtract value at address xx from ACC.
* **STA (3xx)**: Store ACC into address xx.
* **LDA (5xx)**: Load value from address xx into ACC.
* **BRA (6xx)**: Branch always to address xx.
* **BRZ (7xx)**: Branch if ACC is zero.
* **BRP (8xx)**: Branch if ACC is zero or positive.
* **INP (901)**: Input value to ACC.
* **OUT (902)**: Output value from ACC.
* **HLT (000)**: Halt the program.

## Programming Examples
* **Addition**: Uses `INP`, `STA`, `ADD`, and `OUT` to sum two numbers.
* **Subtraction**: Uses `LDA` and `SUB` to find the difference between stored values.
* **Loops**: Implemented using `SUB 1`, `BRZ` (Branch if Zero) to exit, and `BRA` (Branch Always) to repeat.

## LMC vs. Real CPUs
* LMC uses a single accumulator, whereas modern CPUs have dozens of general-purpose registers.
* LMC memory is 100 3-digit slots compared to billions of bytes in modern systems.
* Both share the fundamental concepts of register-based logic and the instruction cycle.
---
This presentation was created with [Bobr AI](https://bobr.ai) — an AI presentation generator.