{"name":"Tiny8: An Educational 8-bit CPU Simulator with Interactive Visualization","description":"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","url":"https://osrepos.com/repo/sql-hkr-tiny8","source":"osrepos.com","sourceDescription":"This repository profile is provided by osrepos.com, an open source repository discovery platform.","repositoryProfile":"https://osrepos.com/repo/sql-hkr-tiny8","generatedFor":"open source discovery and AI-assisted research","markdown":"https://osrepos.com/repo/sql-hkr-tiny8.md","json":"https://osrepos.com/repo/sql-hkr-tiny8.json","topics":["8-bit-computer","assembler","visualization","Python","cpu-simulator","computer-architecture","education","debugger"],"keywords":["8-bit-computer","assembler","visualization","Python","cpu-simulator","computer-architecture","education","debugger"],"stars":null,"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.","content":"## Introduction\n\nTiny8 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.\n\nKey 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.\n\n![Animated bubble sort visualization](https://github.com/user-attachments/assets/ffbcb2c4-2c3a-469f-b7b7-e6e86eb374da)\n*Real-time visualization of a bubble sort algorithm executing on Tiny8*\n\n## Installation\n\nGetting started with Tiny8 is straightforward. You can install it directly using pip:\n\nbash\npip install tiny8\n\n\n## Examples\n\nTiny8 comes with a variety of examples to help you understand its capabilities. Let's look at a simple Fibonacci sequence calculator.\n\nFirst, create an assembly file, `fibonacci.asm`:\n\nasm\n; Fibonacci Sequence Calculator\n; Calculates the 10th Fibonacci number (F(10) = 55)\n; F(0) = 0, F(1) = 1, F(n) = F(n-1) + F(n-2)\n;\n; Results stored in registers:\n; R16 and R17 hold the two most recent Fibonacci numbers\n\n    ldi r16, 0          ; F(0) = 0\n    ldi r17, 1          ; F(1) = 1\n    ldi r18, 9          ; Counter: 9 more iterations to reach F(10)\n\nloop:\n    add r16, r17        ; F(n) = F(n-1) + F(n-2)\n    mov r19, r16        ; Save result temporarily\n    mov r16, r17        ; Shift: previous = current\n    mov r17, r19        ; Shift: current = new result\n    dec r18             ; Decrement counter\n    brne loop           ; Continue if counter != 0\n\ndone:\n    jmp done            ; Infinite loop at end\n\n\nThen, run it using the Tiny8 CLI. You can either use the interactive debugger or generate an animation:\n\nbash\ntiny8 fibonacci.asm # Interactive debugger\ntiny8 fibonacci.asm -m ani -o fibonacci.gif # Generate animation\n\n\nTiny8 also provides a Python API for integrating the simulator into your own scripts:\n\npython\nfrom tiny8 import CPU, assemble_file\n\nasm = assemble_file(\"fibonacci.asm\")\ncpu = CPU()\ncpu.load_program(asm)\ncpu.run(max_steps=1000)\n\nprint(f\"Result: R17 = {cpu.read_reg(17)}\")  # Final Fibonacci number\n\n\n## Why Use Tiny8?\n\nTiny8 serves various audiences with its unique blend of simplicity and power:\n\n*   **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.\n*   **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.\n*   **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.\n\n## Links\n\nFor more detailed information, documentation, and community engagement, please refer to the official resources:\n\n*   **Official Documentation**: [sql-hkr.github.io/tiny8](https://sql-hkr.github.io/tiny8/)\n*   **GitHub Repository**: [sql-hkr/tiny8](https://github.com/sql-hkr/tiny8)\n*   **Issues**: [GitHub Issues](https://github.com/sql-hkr/tiny8/issues)\n*   **Discussions**: [GitHub Discussions](https://github.com/sql-hkr/tiny8/discussions)","metrics":{"detailViews":2,"githubClicks":1},"dates":{"published":null,"modified":"2026-06-18T23:43:47.000Z"}}