CHIP-8 was a virtual machine for microcomputers
CHIP-8 was first used for the COSMAC VIP microcomputer and later introduced in the popular HP-48 calculator. A revision named SCHIP was developed later, with extra instructions.
The CHIP-8 VM is one of the most recommended systems to implement to get started with emulators development.
- It is simple enough to be done over a few days.
- The architecture is extensively documented, and there are tutorials.
- Test ROMs do exist.
Architecture
- 4KB of memory, with 1-byte words.
- 16 general-purpose registers of 1 byte each, called
V0..VF
.- The last of these registers,
VF
is used for the carry flag.
- The last of these registers,
- 1 16-bit register named
I
that stores memory addresses. - 1 special 1-byte register named
ST
that is a timer for sound. - 1 special 1-byte register named
DT
that is a generic countdown timer. - A stack with capacity for 16 slots. This is used to handle calls to subroutines.
Memory addresses range from 0x000
to 0xFFF
, but the first range is reserved for the interpreter itself. CHIP-8 ROMS load from address 0x200
.
In addition to the CPU, there's also a 64×32
monochrome display and a synthesizer/buzzer that emits a tone when the ST
register is non-zero.
Opcodes
There are 35 opcodes in the standard CHIP-8 set, with extra instruction for SCHIP.
All opcodes are always 2-byte long in big endian.
See a table with all the opcodes and their variations/bugs accross versions of the interpreters.
Resources
- Cowgod's CHIP-8 technical reference
- Guide to making a CHIP-8 emulator
- Octo assembly language and tools for CHIP-8
- Github repository with Test ROMs
- My own implementation of an emulator for CHIP-8 in Rust + WebAssembly