You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
uv run tiny8 examples/bubblesort.asm --mode ani -o bubblesort.gif --mem-start 100 --mem-end 131 --plot-every 100 --fps 60
123
124
```
124
125
125
126
> [!IMPORTANT]
@@ -238,48 +239,48 @@ Example Output:
238
239
Below is a concise, categorized summary of the Tiny8 instruction set (mnemonics are case-insensitive). This is a quick reference — for implementation details see `src/tiny8/cpu.py`.
239
240
240
241
- Data transfer
241
-
- LDI Rd, K — load immediate into register
242
-
- MOV Rd, Rr — copy register
243
-
- LD Rd, Rr_addr — load from RAM at address in register
244
-
- ST Rr_addr, Rr — store register into RAM at address in register
245
-
- IN Rd, port — read byte from RAM/IO into register
246
-
- OUT port, Rr — write register to RAM/IO
247
-
- PUSH Rr / POP Rd — stack push/pop
242
+
- LDI Rd, K — load immediate into register
243
+
- MOV Rd, Rr — copy register
244
+
- LD Rd, Rr_addr — load from RAM at address in register
245
+
- ST Rr_addr, Rr — store register into RAM at address in register
246
+
- IN Rd, port — read byte from RAM/IO into register
247
+
- OUT port, Rr — write register to RAM/IO
248
+
- PUSH Rr / POP Rd — stack push/pop
248
249
249
250
- Arithmetic
250
-
- ADD Rd, Rr — add registers
251
-
- ADC Rd, Rr — add with carry
252
-
- SUB Rd, Rr / SUBI Rd, K — subtraction
253
-
- SBC Rd, Rr / SBCI Rd, K — subtract with carry/borrow
254
-
- INC Rd / DEC Rd — increment / decrement
255
-
- MUL Rd, Rr — 8x8 -> 16 multiply (low/high in Rd/Rd+1)
256
-
- DIV Rd, Rr — unsigned divide (quotient->Rd, remainder->Rd+1)
257
-
- NEG Rd — two's complement negate
258
-
- CLR Rd / SER Rd — clear or set register to all ones
251
+
- ADD Rd, Rr — add registers
252
+
- ADC Rd, Rr — add with carry
253
+
- SUB Rd, Rr / SUBI Rd, K — subtraction
254
+
- SBC Rd, Rr / SBCI Rd, K — subtract with carry/borrow
255
+
- INC Rd / DEC Rd — increment / decrement
256
+
- MUL Rd, Rr — 8x8 -> 16 multiply (low/high in Rd/Rd+1)
257
+
- DIV Rd, Rr — unsigned divide (quotient->Rd, remainder->Rd+1)
258
+
- NEG Rd — two's complement negate
259
+
- CLR Rd / SER Rd — clear or set register to all ones
259
260
260
261
- Logical and bit ops
261
-
- AND Rd, Rr / ANDI Rd, K — bitwise AND
262
-
- OR Rd, Rr / ORI Rd, K — bitwise OR
263
-
- EOR Rd, Rr / EORI Rd, K — exclusive OR
264
-
- COM Rd — one's complement
265
-
- SWAP Rd — swap nibbles
266
-
- TST Rd — test for zero or minus
267
-
- SBI/CBI / SBIS/SBIC / SBRS/SBRC — set/clear/test single bits and conditional skips
262
+
- AND Rd, Rr / ANDI Rd, K — bitwise AND
263
+
- OR Rd, Rr / ORI Rd, K — bitwise OR
264
+
- EOR Rd, Rr / EORI Rd, K — exclusive OR
265
+
- COM Rd — one's complement
266
+
- SWAP Rd — swap nibbles
267
+
- TST Rd — test for zero or minus
268
+
- SBI/CBI / SBIS/SBIC / SBRS/SBRC — set/clear/test single bits and conditional skips
268
269
269
270
- Shifts & rotates
270
-
- LSL Rd / LSR Rd — logical shift left/right
271
-
- ROL Rd / ROR Rd — rotate through carry
271
+
- LSL Rd / LSR Rd — logical shift left/right
272
+
- ROL Rd / ROR Rd — rotate through carry
272
273
273
274
- Word (16-bit) ops
274
-
- SBIW / ADIW — simplified word add/subtract helpers for register pairs
275
+
- SBIW / ADIW — simplified word add/subtract helpers for register pairs
- RET / RETI — return from subroutine / return from interrupt (sets I)
281
+
- BRNE / BREQ / BRCS / BRCC / BRGE / BRLT — conditional branches based on flags
282
+
- CP Rd, Rr / CPI Rd, K — compare (sets flags)
283
+
- CPSE Rd, Rr — compare and skip if equal
283
284
284
285
Use the assembler in `src/tiny8/assembler.py` (or `parse_asm`) to write programs — register operands are specified as R0..R31 and immediates accept decimal, $hex, 0x, or 0b binary notation.
Tiny8 includes a lightweight terminal-based visualizer that lets you step through a program's execution trace in your terminal. It shows the status register (SREG), the 32 general-purpose registers, and a compact view of a configurable memory range for each step.
74
+
75
+
Key points
76
+
~~~~~~~~~~
77
+
78
+
- The CLI visualizer expects the CPU to have a populated ``step_trace`` (run the CPU first with ``cpu.run(...)``).
79
+
- Controls are keyboard-driven (play/pause, step forward/back, jump, quit) and work in most POSIX terminals that support curses.
80
+
- For higher-fidelity animations (GIFs) and interactive matplotlib views, use the ``Visualizer`` class which requires ``matplotlib``.
81
+
82
+
Interactive controls
83
+
~~~~~~~~~~~~~~~~~~~~
84
+
85
+
.. code-block:: text
86
+
87
+
Space - toggle play/pause
88
+
l or > - next step
89
+
h or < - previous step
90
+
w - jump forward 10 steps
91
+
b - jump back 10 steps
92
+
0 - jump to first step
93
+
$ - jump to last step
94
+
q or ESC - quit
95
+
96
+
Programmatic usage
97
+
------------------
98
+
99
+
You can invoke the terminal visualizer directly from Python after running the CPU:
0 commit comments