# Tiny8: An Educational 8-bit CPU Simulator with Interactive Visualization

This repository profile is provided by osrepos.com, an open source repository discovery platform.

Source: osrepos.com
Repository profile: https://osrepos.com/repo/sql-hkr-tiny8
Generated for open source discovery and AI-assisted research.

Tiny8 is a lightweight and educational 8-bit CPU simulator written in Python. It offers an interactive terminal debugger and graphical animation to visualize program execution, making it ideal for learning computer architecture and assembly programming.

GitHub: https://github.com/sql-hkr/tiny8
OSRepos URL: https://osrepos.com/repo/sql-hkr-tiny8

## Summary

Tiny8 is a lightweight and educational 8-bit CPU simulator written in Python. It offers an interactive terminal debugger and graphical animation to visualize program execution, making it ideal for learning computer architecture and assembly programming.

## Topics

- 8-bit-computer
- assembler
- visualization
- Python
- cpu-simulator
- computer-architecture
- education
- debugger

## Repository Information

Last analyzed by OSRepos: Fri Jun 19 2026 00:43:47 GMT+0100 (Western European Summer Time)
Detail views: 2
GitHub clicks: 1

## Safety Notice

OSRepos shares public repositories for knowledge and discovery only. Review source code, dependencies, licenses, and security implications before running or installing anything.

## Content

## Introduction

Tiny8 is a powerful and educational 8-bit CPU simulator, meticulously crafted in Python. Designed to demystify computer architecture, it provides a hands-on environment for exploring assembly programming and real-time visualization of CPU operations. Inspired by AVR architecture, Tiny8 features a robust 8-bit CPU with 32 general-purpose registers, a comprehensive instruction set, and advanced debugging tools, all without heavy dependencies.

Key features include an interactive terminal debugger with Vim-style navigation, change highlighting, and advanced search capabilities. For visual learners and educators, Tiny8 can generate high-quality GIF/MP4 animations of program execution, illustrating register evolution, memory access patterns, and flag changes. This makes it an excellent tool for understanding how programs interact with hardware at a fundamental level.

![Animated bubble sort visualization](https://github.com/user-attachments/assets/ffbcb2c4-2c3a-469f-b7b7-e6e86eb374da)
*Real-time visualization of a bubble sort algorithm executing on Tiny8*

## Installation

Getting started with Tiny8 is straightforward. You can install it directly using pip:

bash
pip install tiny8


## Examples

Tiny8 comes with a variety of examples to help you understand its capabilities. Let's look at a simple Fibonacci sequence calculator.

First, create an assembly file, `fibonacci.asm`:

asm
; 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          ; F(0) = 0
    ldi r17, 1          ; F(1) = 1
    ldi r18, 9          ; Counter: 9 more iterations to reach F(10)

loop:
    add r16, r17        ; F(n) = F(n-1) + F(n-2)
    mov r19, r16        ; Save result temporarily
    mov r16, r17        ; Shift: previous = current
    mov r17, r19        ; Shift: current = new result
    dec r18             ; Decrement counter
    brne loop           ; Continue if counter != 0

done:
    jmp done            ; Infinite loop at end


Then, run it using the Tiny8 CLI. You can either use the interactive debugger or generate an animation:

bash
tiny8 fibonacci.asm # Interactive debugger
tiny8 fibonacci.asm -m ani -o fibonacci.gif # Generate animation


Tiny8 also provides a Python API for integrating the simulator into your own scripts:

python
from tiny8 import CPU, assemble_file

asm = assemble_file("fibonacci.asm")
cpu = CPU()
cpu.load_program(asm)
cpu.run(max_steps=1000)

print(f"Result: R17 = {cpu.read_reg(17)}")  # Final Fibonacci number


## Why Use Tiny8?

Tiny8 serves various audiences with its unique blend of simplicity and power:

*   **For Students**: It offers an unparalleled opportunity to write assembly code and observe immediate, visual feedback. Students can understand precisely how each instruction impacts the CPU state, free from high-level abstractions.
*   **For Educators**: Tiny8 facilitates interactive demonstrations, simplifies the creation of assembly programming assignments, and allows for the generation of engaging animations for lectures and teaching materials.
*   **For Hobbyists**: It provides a platform for rapid algorithm prototyping at the hardware level. With minimal overhead and an extensible, readable Python codebase, hobbyists can experiment with low-level programming concepts efficiently.

## Links

For more detailed information, documentation, and community engagement, please refer to the official resources:

*   **Official Documentation**: [sql-hkr.github.io/tiny8](https://sql-hkr.github.io/tiny8/)
*   **GitHub Repository**: [sql-hkr/tiny8](https://github.com/sql-hkr/tiny8)
*   **Issues**: [GitHub Issues](https://github.com/sql-hkr/tiny8/issues)
*   **Discussions**: [GitHub Discussions](https://github.com/sql-hkr/tiny8/discussions)