1989 · Nintendo and Sharp
Game Boy CPU
The Game Boy ran on four AA batteries for over a day of play, and that set the rules for its brain: a modest 8-bit Sharp core, a few kilobytes of RAM, and a whole console’s worth of hardware packed onto one chip around it.
| Made by | Nintendo; CPU chip manufactured by Sharp |
|---|---|
| Released | 1989 |
| CPU core | Sharp SM83, inside the DMG-CPU system-on-chip (often called the LR35902) |
| Clock | 4.194304 MHz (222 Hz) |
| Data width | 8 bits, with a 16-bit address space (64 KB) |
| Registers | A, F, B, C, D, E, H, L (8-bit), SP and PC (16-bit) |
| Memory | 8 KB work RAM, 8 KB video RAM, 127 bytes of fast high RAM |
| Screen | 160 × 144 pixels, 4 shades |
Why it was built
Nintendo’s Game Boy, developed by Gunpei Yokoi’s team, was designed to be cheap, tough and frugal with power. A color screen and a fast processor would have drained the batteries in a few hours. Instead the Game Boy used a reflective monochrome LCD and a single custom chip from Sharp that holds the CPU, the graphics hardware, the sound hardware, timers and a small boot ROM. Nintendo labels it DMG-CPU; many references call it the LR35902. The processor core inside is a Sharp design now usually identified as the SM83.
A Z80 cousin, not a Z80
The SM83 is often described as a Z80, and Game Boy assembly does look a lot like Z80 code. The truth is in between. Its register set and many opcodes follow the Intel 8080. It borrows some Z80 favorites, such as relative jumps and the prefixed bit instructions. But it leaves out the Z80’s shadow registers, the IX and IY index registers and the separate I/O instructions, and it adds a few ideas of its own.
| Register | Job |
|---|---|
A | Accumulator |
F | Flags: zero, subtract, half-carry, carry |
BC, DE, HL | General purpose; usable as 8-bit or 16-bit pairs, HL as the main memory pointer |
SP, PC | Stack pointer and program counter |
Game Boy-specific additions include LDH, which reaches the top 256 bytes of memory with a one-byte address, loads that increment or decrement HL in the same step, SWAP to exchange the two halves of a byte, and STOP to drop into a very low power state.
How the hardware fits together
Everything the CPU talks to appears somewhere in its 64 KB address space. There are no I/O instructions; the buttons, the screen, the sound and the timers are all controlled by reading and writing special addresses near the top of memory.
| Addresses | What lives there |
|---|---|
0000–7FFF | Cartridge ROM (bigger games swap in banks) |
8000–9FFF | Video RAM: tiles and background maps |
A000–BFFF | Optional RAM on the cartridge, often battery-backed for saves |
C000–DFFF | Work RAM |
FE00–FE9F | Sprite attribute table (40 sprites) |
FF00–FF7F | I/O registers: joypad, serial link, timer, sound, LCD |
FF80–FFFE | High RAM |
The screen is built from 8×8 tiles rather than individual pixels: a scrolling background, a window layer on top, and up to 40 sprites. The picture processor draws it line by line, and the CPU gets interrupts at moments like the start of vertical blank, when it is safe to update video memory. Sound comes from four channels: two square waves, a programmable wave channel and noise.
The clock runs at 222 Hz, about 4.19 MHz, but memory is accessed once every four clock ticks, so the simplest instructions take four ticks each. Read more about how a clock paces a machine.
Legacy
The Game Boy and its successor the Game Boy Color, which reused the same CPU at up to double speed, sold over 118 million units together. Tetris was the pack-in game in many regions and became a phenomenon. Today the hardware is one of the most thoroughly documented consoles, thanks to years of community research, and a lively homebrew scene still writes new games for it with free tools.
The Game Boy CPU in NANDSIM
The museum Game Boy is rebuilt from about 30,000 NAND gates: the SM83 CPU, the picture processor, timer, joypad and cartridge mapper. It plays the homebrew game Libbet and the Magic Floor and draws the dmg-acid2 test picture pixel-exact, with an on-screen joypad and its registers and memory open while it runs.