Play free

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.

3 min read · Updated

Made byNintendo; CPU chip manufactured by Sharp
Released1989
CPU coreSharp SM83, inside the DMG-CPU system-on-chip (often called the LR35902)
Clock4.194304 MHz (222 Hz)
Data width8 bits, with a 16-bit address space (64 KB)
RegistersA, F, B, C, D, E, H, L (8-bit), SP and PC (16-bit)
Memory8 KB work RAM, 8 KB video RAM, 127 bytes of fast high RAM
Screen160 × 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.

RegisterJob
AAccumulator
FFlags: zero, subtract, half-carry, carry
BC, DE, HLGeneral purpose; usable as 8-bit or 16-bit pairs, HL as the main memory pointer
SP, PCStack 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.

AddressesWhat lives there
0000–7FFFCartridge ROM (bigger games swap in banks)
8000–9FFFVideo RAM: tiles and background maps
A000–BFFFOptional RAM on the cartridge, often battery-backed for saves
C000–DFFFWork RAM
FE00–FE9FSprite attribute table (40 sprites)
FF00–FF7FI/O registers: joypad, serial link, timer, sound, LCD
FF80–FFFEHigh 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.

Play the Game Boy live