Tiny8 Exposed: The 8-Bit CPU Simulator Every Developer Needs
What if you could peer inside a processor and watch every electron dance? What if understanding assembly language wasn't a semester-long slog through dry textbooks, but an interactive, visual experience that makes computer architecture click in minutes?
Here's the brutal truth: most developers graduate without ever truly understanding how CPUs work. We write Python, JavaScript, or Rust and trust the compiler to handle the magic. But when performance matters, when embedded systems call, or when you simply want to master the machine—you hit a wall. Traditional CPU simulators are clunky, outdated, or locked behind university firewalls. Online emulators lack the tactile feedback of real debugging. And physical hardware? Expensive, fragile, and impossible to visualize at scale.
Enter Tiny8. This lightweight, open-source Python toolkit shatters every barrier to learning computer architecture. With its AVR-inspired 8-bit CPU, 32 registers, 60+ instructions, and jaw-dropping real-time visualizations, Tiny8 transforms abstract concepts into concrete, observable reality. Whether you're a student struggling with assembly, an educator crafting the perfect lecture, or a hobbyist building your own CPU empire, Tiny8 delivers an experience that feels less like studying and more like hacking the Matrix. Ready to see what you've been missing?
What is Tiny8?
Tiny8 is an educational 8-bit CPU simulator written in Python by developer sql-hkr, designed to make computer architecture tangible, interactive, and genuinely fun. Built with zero heavy dependencies, it strips away the complexity that buries learners in traditional architecture courses while preserving the complete fidelity of a real processor's behavior.
The project emerged from a simple, powerful insight: we learn best when we see. Reading about register transfers in a textbook is forgettable. Watching registers light up as your bubble sort algorithm executes? That knowledge sticks forever. Tiny8 bridges the gap between theory and practice by providing not just a functional CPU emulator, but a complete visualization ecosystem—interactive terminal debugging, animated GIF generation, and clean Python APIs that let you script, test, and extend the simulator programmatically.
Tiny8 is trending now because it arrives at a perfect storm of need. The resurgence of embedded systems, RISC-V curiosity, and retrocomputing enthusiasm has developers hungry for low-level knowledge. Simultaneously, the Python ecosystem has matured enough to support performant simulation without C extensions or complex build chains. Tiny8 rides this wave with PyPI distribution, comprehensive CI/CD, and documentation that respects your time. With over 60 instructions, a 2KB unified address space, and Vim-style navigation in its debugger, it punches far above its weight class.
The architecture draws direct inspiration from AVR microcontrollers—the same chips powering Arduino boards millions of developers already own. This isn't accidental. By mirroring a real, commercially successful ISA, Tiny8 ensures skills transfer directly to physical hardware. When you've mastered Tiny8's ldi, add, and brne instructions, you're already speaking the language of actual embedded systems.
Key Features That Make Tiny8 Irresistible
🎯 Interactive Terminal Debugger with Vim-Style Controls
Tiny8's crown jewel is its terminal-based visual debugger that feels like using a modern IDE for assembly code. Navigate execution with h/l for backward/forward stepping, w/b for jumping ±10 steps, and 0/$ for instant first/last step access. The change highlighting system illuminates exactly which registers, flags, and memory locations mutated at each step—no more squinting at hex dumps trying to spot differences.
The search capabilities are genuinely powerful: jump to specific steps (:123), search for instructions (:/ldi), track register evolution (:r10), or hunt for specific values (:r10=42). Marks and bookmarks (ma, 'a) let you flag critical execution points and teleport between them instantly. For large programs, vertical memory scrolling keeps everything navigable.
🎬 Cinematic Animation Generation
This is where Tiny8 becomes viral-worthy. The animation mode renders program execution as high-quality GIF or MP4 videos, visualizing register states, memory access patterns, and flag changes over time. Imagine demonstrating a sorting algorithm to your class with a beautiful, auto-generated animation showing memory cells rearranging in real-time. Or documenting your custom algorithm with a shareable, loopable visualization that makes Medium articles and GitHub READMEs shine.
The rendering engine is optimized for clarity: configurable FPS, adjustable update intervals, and plot-every-N-steps controls let you balance detail against file size. At 60 FPS with 100-step plot intervals, even lengthy programs become smooth, comprehensible visual narratives.
🏗️ Complete 8-Bit Architecture Fidelity
Tiny8 doesn't cut corners on architectural accuracy:
- 32 general-purpose registers (R0-R31) with full 8-bit width
- 8-bit ALU supporting arithmetic, logical, and bit manipulation operations
- Status register (SREG) with 8 condition flags: I, T, H, S, V, N, Z, C
- 2KB address space for unified memory and I/O operations
- Hardware stack with dedicated 16-bit stack pointer
- 62 AVR-inspired instructions covering data transfer, arithmetic, logic, control flow, and bit operations
📚 Educational Engineering Excellence
Every design decision prioritizes learning. The Python implementation is deliberately clean and readable—no obfuscated optimizations, no cryptic bit-twiddling. Comprehensive examples cover Fibonacci generation, bubble sort, factorial calculation, array maximum finding, prime checking, and GCD computation. Step-by-step execution traces make debugging intuitive, and the full API documentation at sql-hkr.github.io/tiny8 leaves no gaps.
Use Cases Where Tiny8 Absolutely Dominates
1. University Computer Architecture Courses
Professors can finally ditch antiquated simulators that require Windows XP compatibility modes. Tiny8 runs on any Python-capable system, generates lecture-ready animations automatically, and lets students submit .asm files that execute identically for grading. The visual debugger replaces hours of office hours with self-paced exploration.
2. Self-Taught Embedded Systems Preparation
Before dropping $50 on Arduino shields and sensors, master the instruction set in simulation. Tiny8's AVR compatibility means your assembly knowledge transfers directly to Atmega chips. Debug algorithms faster than hardware flashing cycles allow, then deploy with confidence.
3. Technical Interview Deep Dives
When interviewers ask "how well do you understand computers at the hardware level?"—show them your Tiny8 visualization portfolio. Explain cache-oblivious algorithms by demonstrating memory access patterns. Discuss compiler optimizations by stepping through generated assembly equivalents.
4. Retrocomputing and Demoscene Projects
Build period-accurate effects and algorithms constrained by authentic 8-bit limitations. The 2KB address space and 32-register constraint force creative solutions that translate beautifully to actual vintage hardware or modern fantasy consoles.
5. Algorithm Visualization and Research Communication
Publish papers and blog posts with embedded animations showing exactly how your novel sorting variant or memory-optimized structure behaves at the hardware level. The MP4 export integrates seamlessly with modern web platforms.
Step-by-Step Installation & Setup Guide
Getting Tiny8 running takes under 60 seconds. Here's the complete process:
Prerequisites
Tiny8 requires Python 3.7+ and pip. Verify your installation:
python --version # Should show 3.7 or higher
pip --version
Installation via PyPI
pip install tiny8
This installs the core simulator, assembler, CLI tools, and visualization dependencies. No separate compiler chains, no platform-specific binaries, no dependency hell.
Verification
tiny8 --version # Should display current version
Windows-Specific Note
The interactive CLI debugger requires either WSL (Windows Subsystem for Linux) or the windows-curses package:
pip install windows-curses
Animation generation works natively on all platforms.
Your First Project Directory
mkdir tiny8-projects
cd tiny8-projects
Create your first assembly file using any text editor. Tiny8 uses standard .asm extension with intuitive syntax.
Running Modes
| Command | Purpose |
|---|---|
tiny8 program.asm |
Launch interactive debugger |
tiny8 program.asm -m ani -o out.gif |
Generate animation |
tiny8 program.asm --max-steps 50000 |
Extend execution limit |
Memory Range Configuration
For programs using specific memory regions (like the bubble sort example):
tiny8 bubblesort.asm -ms 0x60 -me 0x80 # Watch memory 0x60-0x80
The -ms (memory start) and -me (memory end) flags accept decimal or hexadecimal (0x prefix) addresses.
REAL Code Examples from the Repository
Let's dissect actual code from Tiny8's README, explaining each pattern with the depth you need to master it.
Example 1: Fibonacci Sequence Calculator
This is Tiny8's flagship introductory program—clean, comprehensible, and demonstrating core register operations:
; Fibonacci Sequence Calculator
; Calculates the 10th Fibonacci number (F(10) = 55)
; F(0) = 0, F(1) = 1, F(n) = F(n-1) + F(n-2)
;
; Results stored in registers:
; R16 and R17 hold the two most recent Fibonacci numbers
ldi r16, 0 ; Load immediate: F(0) = 0 into R16
ldi r17, 1 ; Load immediate: F(1) = 1 into R17
ldi r18, 9 ; Counter: 9 iterations to reach F(10)
loop:
add r16, r17 ; R16 = R16 + R17 (calculate next Fibonacci)
mov r19, r16 ; Temporary save: R19 holds new value
mov r16, r17 ; Shift: R16 becomes previous value
mov r17, r19 ; Shift: R17 becomes new current value
dec r18 ; Decrement iteration counter
brne loop ; Branch if not equal (Z-flag clear): loop again
done:
jmp done ; Infinite loop: halt execution
Deep Dive: This reveals Tiny8's register-transfer-level thinking. Notice the three-register shuffle (R16, R17, R19)—a pattern you'll see in virtually every iterative algorithm. The brne instruction checks the Z (zero) flag set by dec. When R18 hits zero, Z becomes 1, the branch falls through, and we halt. This is exactly how real AVR processors operate.
Example 2: Python API Integration
Tiny8 isn't just a standalone tool—it embeds cleanly into Python workflows:
from tiny8 import CPU, assemble_file # Import core simulator classes
# Step 1: Parse assembly source into machine code
asm = assemble_file("fibonacci.asm")
# Step 2: Instantiate fresh CPU with default state
cpu = CPU()
# Step 3: Load assembled program into memory
cpu.load_program(asm)
# Step 4: Execute with safety limit (prevents infinite loops)
cpu.run(max_steps=1000)
# Step 5: Inspect final register state
print(f"Result: R17 = {cpu.read_reg(17)}") # R17 holds F(10) = 55
Why This Matters: The API enables test-driven assembly development. Write pytest cases verifying register outputs for edge cases. Build CI pipelines that validate your embedded algorithms before hardware deployment. The CPU class exposes read_reg(), read_ram(), write_ram(), and step-level control for complete programmatic inspection.
Example 3: Bubble Sort with Memory Visualization
Tiny8's most visually impressive example demonstrates memory operations:
# Interactive: watch memory cells swap in real-time
tiny8 examples/bubblesort.asm -ms 0x60 -me 0x80
# Generate shareable animation
tiny8 examples/bubblesort.asm -m ani -o sort.gif -ms 0x60 -me 0x80
The Python verification equivalent:
from tiny8 import CPU, assemble_file
cpu = CPU()
cpu.load_program(assemble_file("examples/bubblesort.asm"))
cpu.run() # Execute until halt or max steps
# Read sorted range from RAM: addresses 0x60 through 0x7F
sorted_data = [cpu.read_ram(i) for i in range(0x60, 0x80)]
print("Sorted:", sorted_data)
Critical Insight: The -ms 0x60 -me 0x80 flags configure memory display windows. Tiny8's visualizer only renders your region of interest, keeping animations focused and file sizes manageable. This is essential for algorithms with large memory footprints where full-RAM visualization would be overwhelming.
Example 4: Animation Configuration for Presentations
tiny8 algorithm.asm \
-m ani \ # Animation mode
-o demo.gif \ # Output filename
-f 30 \ # 30 FPS for smoother playback
-pe 50 \ # Plot every 50 steps (faster render)
--max-steps 10000 # Extended execution limit
Pro Tip: The -pe (plot-every) parameter is your secret weapon. For algorithms with thousands of steps, plotting every single state creates enormous files. Setting -pe 100 or higher produces smooth, compact animations perfect for Twitter, GitHub, or conference presentations.
Advanced Usage & Best Practices
Mastering the Search Commands
The : command mode transforms debugging efficiency. Beyond basic navigation:
:r10=42— Conditional breakpoints without modifying code. Find exactly when a register hits a target value.:fZ— Track flag evolution. Essential for understanding when your arithmetic overflows or hits zero.:@0x100— Program counter jumps. Navigate directly to specific addresses when debugging jumps and calls.
Memory Display Optimization
Toggle between r (all registers vs. changed-only) and M (all memory vs. non-zero only) to reduce visual noise. For I/O-heavy programs, non-zero memory filtering keeps you focused on active regions.
Scripting Complex Test Scenarios
from tiny8 import CPU, assemble_file
def test_factorial(n, expected):
cpu = CPU()
# Load program, set input register, run, assert output
# Build comprehensive test suites for your assembly libraries
Performance Tuning Animations
For batch generation, increase -pe dramatically and reduce FPS. For educational clarity, keep -pe low and FPS high. The sweet spot for social media sharing: -f 30 -pe 100.
Comparison with Alternatives
| Feature | Tiny8 | Logisim | MARS (MIPS) | QEMU | Physical Arduino |
|---|---|---|---|---|---|
| Installation | pip install |
Java + GUI | Java + config | Complex build | Hardware + IDE |
| Visualization | Built-in GIF/MP4/CLI | Circuit-level | Basic text | None | Serial monitor |
| ISA | AVR-inspired (transferable) | Custom/abstract | MIPS only | Target-dependent | AVR native |
| Python API | ✅ Native | ❌ | ❌ | Limited | ❌ |
| Zero dependencies | ✅ | ❌ Java | ❌ Java | ❌ Many | ❌ Toolchain |
| Animation export | ✅ GIF/MP4/PNG | ❌ | ❌ | ❌ | ❌ |
| Vim-style debugging | ✅ | ❌ | ❌ | ❌ | ❌ |
| Educational focus | ✅ Designed for | Moderate | Academic | Production | Hobbyist |
Tiny8 wins when you need immediate productivity, beautiful shareable output, and skills that transfer to real embedded systems. Logisim excels for digital logic education but lacks CPU execution visualization. MARS traps you in MIPS-land with limited modern tooling. QEMU is overkill for learning. Physical hardware is irreplaceable for final validation but punishingly slow for iterative development.
Frequently Asked Questions
Q: Does Tiny8 run actual AVR binary code? A: No—Tiny8 uses an AVR-inspired instruction set with compatible mnemonics and semantics, but it's a simulator for learning, not a cycle-accurate emulator. Your assembly knowledge transfers directly, but you can't flash Tiny8 programs to Arduino boards without reassembly.
Q: Can I extend Tiny8 with custom instructions?
A: Absolutely! The clean Python implementation in the src/tiny8 directory makes instruction additions straightforward. See CONTRIBUTING.md for architecture guidelines.
Q: How large can my programs be?
A: Tiny8 supports 64KB address space with 2KB default RAM. The --max-steps parameter defaults to 15,000 but is configurable for longer executions.
Q: Is Tiny8 suitable for production embedded development? A: No—it's explicitly educational. Use it to prototype algorithms, understand architectures, and generate teaching materials. Deploy to actual AVR-GCC for production code.
Q: Why 8-bit in a 64-bit world? A: 8-bit architectures strip away complexity that obscures fundamentals. When you understand how Tiny8's limited registers and flags manage computation, scaling to 32-bit or 64-bit becomes trivial. The constraints also force elegant algorithmic thinking.
Q: Can I contribute examples or documentation? A: Yes! The repository actively welcomes contributions. Popular needs include additional example programs, visualization enhancements, and translated documentation.
Q: Does animation generation require external tools?
A: No—Tiny8 bundles all rendering dependencies. The -m ani mode generates complete GIF/MP4 files without ImageMagick, FFmpeg, or other external installations.
Conclusion: Your Gateway to Hardware Mastery Starts Now
Tiny8 isn't just another educational tool—it's a paradigm shift in how we learn computer architecture. By combining authentic AVR-inspired semantics with stunning visualizations, zero-friction installation, and a Python API that rewards automation, sql-hkr has created something genuinely special.
I've evaluated dozens of CPU simulators over years of technical writing. Most are abandoned academic projects with Java 6 dependencies. Others are so abstract they teach nothing transferable. Tiny8 occupies the rare sweet spot: real enough to matter, simple enough to master, beautiful enough to share.
The embedded systems revolution isn't slowing down. IoT devices, robotics, and custom hardware surround us. Developers who understand the metal beneath their abstractions will architect better systems, debug nastier bugs, and seize opportunities that framework-specialists cannot touch.
Stop letting computer architecture intimidate you. Install Tiny8 today, run the Fibonacci example, generate your first animation, and feel that electric moment when abstract concepts crystallize into visible, controllable reality. The repository awaits at github.com/sql-hkr/tiny8—star it, fork it, break it, master it. Your future self—the one confidently optimizing cache lines and debugging ISR routines—will thank you.
What will you build first? A visualized sorting algorithm? A custom instruction extension? Share your Tiny8 creations and join the growing community of developers who finally see the machine clearly.