Tiny-4 is a bite-sized 8-bit CPU built for chaos, and nostalgia! With only 256 bytes of RAM and the intellectual capacity of a person watching paint dry, it's perfect for doing crimes (in machine language), teaching people, or moving onto harder things! (time to move to the SFC/SNES now!!!)
Programs are compiled into .t4c
files — demons of ones and zeroes that whisper rituals to a CPU that cannot even subtract 2. Execution is fast, fearless, and absolutely guaranteed to HALT eventually. (Don't quote me on this.)
RAM: 256 bytes (It'll run DOOM with the Tiny-4 Expansion Pak!)
Registers: A (Accumulator), PC (Program Counter) (More planned) (Not a joke)
Instruction Length: 2 bytes (opcode and operand action!)
Word Size: 8-bit (small but spicy)
Fulfillment: Maybe not...
Address Range | Purpose |
---|---|
0x00–0x07 | Reserved for sacred bytes (file metadata) |
0x08–0xEF | Your playground. This portion of memory is General Use RAM. |
0xF0–0xFF | Reserved / I/O / Divine Intervention |
Opcode | Mnemonic | Format | Description |
---|---|---|---|
0x01 | LOAD | 01 XX | Summon a byte from memory address XX into A |
0x02 | STORE | 02 XX | Calcify A's value into memory address XX |
0x03 | ADD | 03 XX | Absorb byte from address XX into A like it's EXP |
0x04 | SUB | 04 XX | Vaporise byte from address XX into A like it's chalk |
0x05 | CMP | 05 XX | Compare value in reg A with XX, sets the zero flag. |
0x08 | JMP | 08 XX | Dragoon jump to address XX. |
0x09 | JZ | 09 XX | Dragoon jump to address XX, if A is zero |
0x0A | JNZ | 0A XX | Dragoon jump to address XX, if A isn't zero |
0x0B | CALL | 0B XX | Carefully store the next instruction at address $F0, then jump to address XX |
0x0C | RET | 0C XX | Forcefully set the PC to the instruction stored at address $F0 |
0x0D | OUT | 0D XX | Output the data within the byte XX |
0xFF | HALT | FF 00 | Power nap for your CPU. Execution ends. |
The Tiny-4 CPU is a virtual CPU designed with simplicity in mind. At its core, it fetches 2-byte instructions from memory (opcode + operand), decodes them, and executes the logic in a minimal loop.
Example disassembly output:
00: LOAD $50
02: STORE $30
04: ADD $04
06: HALT
This means:
step()
and loops through the program using run()
..bin
or a test program, attaches the 8-byte Tiny-4 header, and produces a .t4c
file. The header contains magic bytes, version, start address, entry point, program size, and a reserved padding byte..t4c
file, checks for the T4C
magic, then steps through the instructions 2 bytes at a time and prints a readable disassembly like ADD $04
.This tiny toolchain allows you to write bytecode, compile it, emulate it, and reverse-engineer it — all while giggling like a gremlin.
Tiny-4 draws inspiration from two iconic bytecode systems: CHIP-8 and Game Boy Assembly. While vastly more limited, Tiny-4 takes cues from their structure, instruction style, and design philosophy — distilling them down into something extremely lean and educational.
Feature | Tiny-4 | CHIP-8 | Game Boy ASM |
---|---|---|---|
Instruction Size | 2 bytes (opcode + operand) | 2 bytes (single 16-bit opcode) | 1–3 bytes (variable) |
Memory Size | 256 bytes | 4 KB (starts at 0x200) | Up to 64 KB |
Registers | 1 (A) | 16 (V0–VF) | AF, BC, DE, HL, SP, PC + flags |
Stack Support | No | Yes | Yes |
Graphics / Display | No | Yes (64×32 bitmap) | Yes (tile/sprite-based) |
Timer / Sound | No | Delay & Sound Timers | Full APU & Timers |
Instruction Count | 4 | ~35 | ~500+ |
Where CHIP-8 encourages visual creativity and the Game Boy invites full-blown hardware mastery, Tiny-4 is a sandbox for bytecode exploration. It's designed to be as dumb as possible, on purpose. It doesn’t try to be useful — it tries to be understandable. Every instruction is visible, every byte matters, and there's no magic under the hood.
In short: Tiny-4 is what you’d get if a Game Boy and CHIP-8 had a baby… and then left it in a single byte-wide crib with no supervision.
JMP
, JZ
, JNZ
, CALL
, RET
, OUT
Codename: THE BIG JMP - i consider it a big $08 to working on v0.3 :DDD
LOAD
, STORE
, ADD
, HALT
, NOP
Codename: ADD $03 - because i did not implement any other opcodes :DDD