A simulation of a simple 8-bit CPU implemented entirely in Microsoft Excel β no macros or code required!
This project emulates a basic processor with registers, RAM, a program counter, status flags, and a custom instruction set. Users write assembly-like programs in one sheet, and the CPU executes them cycle-by-cycle, updating registers, flags, and memory visibly across workbook sheets.
Perfect for learning computer architecture, assembly programming, and how CPUs work under the hood.
- 8-Bit Architecture: Modulo-256 arithmetic (unsigned bytes 0β255).
- Registers: Four general-purpose 8-bit registers (AX, BX, CX, DX).
- Memory: Byte-addressable RAM (editable table).
- Program Counter (PC): Automatically advances through instructions.
- Status Flags: ZF (Zero), CF (Carry), SF (Sign) β updated on ADD/SUB.
- Instruction Set: Custom mnemonics with opcodes and operands (full manual included).
- Cycle-by-Cycle Execution: View state changes row-by-row in the CPU sheet.
- Halt Support: HLT instruction stops execution.
- Pure Spreadsheet: All logic via Excel formulas β transparent and modifiable.
cpu8bit.xlsx # Main emulator workbook (PROGRAM, CPU, RAM sheets)
Excel_CPU_Instruction_Set_Manual.docx # Full instruction set reference (mnemonics, opcodes, syntax)
Excel_CPU_Programs.docx # Three example programs with explanations
This Excel-based emulator faithfully recreates the fundamental principles of a von Neumann architecture CPU at the simplest possible level, making abstract computer science concepts tangible through everyday spreadsheet formulas.
Modern computers follow the von Neumann model:
- Single shared memory for both instructions (code) and data.
- Sequential execution: Instructions fetched from memory, decoded, and executed one after another.
- Central Processing Unit (CPU) containing:
- Registers (fast internal storage)
- Arithmetic Logic Unit (ALU) for computations
- Control Unit managing the fetch-decode-execute cycle
In this emulator:
- PROGRAM sheet = Code memory (instructions)
- RAM sheet = Data memory
- CPU sheet = Control unit + registers + ALU + execution log
Every CPU operates in an endless loop known as the instruction cycle:
- Fetch: Read the instruction at the current Program Counter (PC).
- Decode: Interpret the opcode and identify operands.
- Execute: Perform the operation (move data, add, subtract, etc.).
- Update PC: Usually increment to next instruction (or jump if branching).
- Update flags: Set Zero/Carry/Sign based on result.
The CPU sheet logs one row per cycle, showing exactly how this process unfolds β completely transparent because every step is a visible Excel formula.
All values are 8-bit unsigned integers (0β255):
- Arithmetic wraps around at 256 (modulo 256).
- Two's complement interpretation for signed numbers:
- 0β127 β positive
- 128β255 β negative (e.g., 255 = -1, 254 = -2)
- Flags reflect this:
- ZF (Zero Flag): Set when result = 0
- CF (Carry Flag): Set on unsigned overflow (carry out of bit 7)
- SF (Sign Flag): Mirrors bit 7 (1 = "negative" in two's complement)
- Four general-purpose registers (AX, BX, CX, DX): 8-bit each, used for temporary storage and arithmetic.
- Program Counter (PC): Points to current instruction address.
- RAM: 256 bytes (though only a subset shown), directly editable.
- Separation of code and data: Instructions live in PROGRAM sheet; data in RAM β classic Harvard vs. von Neumann distinction illustrated (this is pure von Neumann).
The emulator uses a custom minimal ISA designed for clarity:
- Fixed-format instructions (mnemonic + up to two operands).
- Operations include:
MOV reg, value/MOV reg, regβ data transferADD reg, value/ADD reg, regβ addition with carrySUB reg, value/SUB reg, regβ subtraction with borrowHLTβ halt execution
No branching yet β execution is strictly linear β which highlights how even simple sequential machines can perform meaningful computation.
It serves as a bridge between theoretical computer science and real hardware
An outstanding platform for teaching computer organization, assembly language, and the essence of computation! π₯οΈ
Download and open code/cpu8bit.xlsx in Microsoft Excel (or compatible like Google Sheets/LibreOffice).
- Go to the PROGRAM sheet.
- Enter instructions row-by-row (columns: ADDR, MNEM, OP1, OP2, etc.).
- Refer to
docs/Excel_CPU_Instruction_Set_Manual.docxfor valid mnemonics (e.g., MOV, ADD, SUB, HLT).
- The CPU sheet automatically processes instructions starting from PC=0.
- Each row shows the state after executing one instruction.
- Scroll down to step through cycles.
- Check registers, flags, and RAM updates in real-time.
Open docs/Excel_CPU_Programs.docx for three ready-to-try programs (e.g., addition loops, data moves).
Tip: Modify formulas directly in Excel to extend the CPU (add new instructions, jumps, etc.)!