Tiny-4 Virtual CPU

Tiny-4 CPU Reference Sheet

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.)

Why I Made This CPU

Specs at a Glance

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...

Memory Map

Address RangePurpose
0x00–0x07Reserved for sacred bytes (file metadata)
0x08–0xEFYour playground. This portion of memory is General Use RAM.
0xF0–0xFFReserved / I/O / Divine Intervention

Instruction Set

OpcodeMnemonicFormatDescription
0x01LOAD01 XXSummon a byte from memory address XX into A
0x02STORE02 XXCalcify A's value into memory address XX
0x03ADD03 XXAbsorb byte from address XX into A like it's EXP
0x04SUB04 XXVaporise byte from address XX into A like it's chalk
0x05CMP05 XXCompare value in reg A with XX, sets the zero flag.
0x08JMP08 XXDragoon jump to address XX.
0x09JZ09 XXDragoon jump to address XX, if A is zero
0x0AJNZ0A XXDragoon jump to address XX, if A isn't zero
0x0BCALL0B XXCarefully store the next instruction at address $F0, then jump to address XX
0x0CRET0C XXForcefully set the PC to the instruction stored at address $F0
0x0DOUT0D XXOutput the data within the byte XX
0xFFHALTFF 00Power nap for your CPU. Execution ends.

How It Works (Internals)

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:

Scripts Explained

This tiny toolchain allows you to write bytecode, compile it, emulate it, and reverse-engineer it — all while giggling like a gremlin.

What It's Based On

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.

Architecture Comparison

FeatureTiny-4CHIP-8Game Boy ASM
Instruction Size2 bytes (opcode + operand)2 bytes (single 16-bit opcode)1–3 bytes (variable)
Memory Size256 bytes4 KB (starts at 0x200)Up to 64 KB
Registers1 (A)16 (V0–VF)AF, BC, DE, HL, SP, PC + flags
Stack SupportNoYesYes
Graphics / DisplayNoYes (64×32 bitmap)Yes (tile/sprite-based)
Timer / SoundNoDelay & Sound TimersFull APU & Timers
Instruction Count4~35~500+

Philosophical Differences

Developer Intent

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.

Updates

v0.2 - "THE BIG JMP" (May 2025)

Codename: THE BIG JMP - i consider it a big $08 to working on v0.3 :DDD

v0.1 – "ADD $03" (May 2025)

Codename: ADD $03 - because i did not implement any other opcodes :DDD