Assembler (Z80)
The assembly language of the Zilog Z80, a July 1976 microprocessor that ran 8080 machine code under a redesigned mnemonic set and powered the TRS-80, the ZX Spectrum, CP/M business machines and the Sega Master System.
Created by Zilog, Inc. (Z80 designed by Federico Faggin and Masatoshi Shima; assembly mnemonics by Zilog engineering staff)
Assembler (Z80) is the assembly language of the Zilog Z80, an 8-bit NMOS microprocessor that Zilog introduced in July 1976. The Z80 ran the same machine code as Intel’s 8080, but Zilog gave it a new instruction set on top: a second set of general-purpose registers for fast context switching, two 16-bit index registers (IX and IY), block transfer and search instructions, three interrupt modes, and a dedicated 7-bit DRAM refresh counter that let designers drop external refresh logic. Because Intel held copyright on its 8080 mnemonics, Zilog wrote an entirely new, more systematic set of assembly mnemonics for the combined instruction set. That language, not Intel’s, became the assembly dialect of the TRS-80, the ZX Spectrum, CP/M business machines, MSX computers and a long line of arcade and console hardware, making it one of the most widely used assembly languages of the 8-bit era.
History and Origins
From the 8080 to the Z80
Federico Faggin had led the design of Intel’s 4004 and 8080 before leaving Intel on Halloween 1974 to found Zilog with Ralph Ungermann. Masatoshi Shima, who had done the detailed logic and circuit design of the 8080 under Faggin, joined Zilog soon after as chief engineer. The company set out to build a processor that would run existing 8080 software while fixing complaints from 8080 system designers: the need for extra chips to generate memory refresh, a limited interrupt scheme, and only one set of working registers.
First working Z80 samples were delivered in March 1976, and Zilog formally introduced the part that July, in 2.5 MHz (Z80) and 4 MHz (Z80A) versions. The chip ran existing 8080 machine code unchanged, so 8080 software such as CP/M and Microsoft’s 8080 BASIC could run on Z80 hardware without modification.
A new mnemonic set for the same opcodes
Although the Z80 executed 8080 binaries, Zilog did not reuse Intel’s assembly notation. Its Z80 Assembly Language Programming Manual, copyrighted in 1977 and issued in a January 1978 edition, introduces a mnemonic scheme built around a small number of general-purpose opcodes rather than Intel’s approach of encoding the addressing mode into the opcode name. The manual states the design goal directly: the language was “designed to minimize the number of different opcodes corresponding to the set of basic machine operations and to provide for a consistent description of instruction operands,” with “special emphasis on mnemonic value and readability.” Where the 8080 used separate opcodes such as MOV, MVI, LDA and LXI for different combinations of register, immediate and memory operands, the Z80 language uses a single LD mnemonic for all data movement, distinguishing the operation only by its operands. Reportedly, Intel’s copyright claim over its own mnemonics was a practical reason for Zilog to design new ones rather than reuse them, and Zilog’s own data catalogs from the period explicitly disclaim that the 8080 mnemonics are Intel’s.
Design of the Language
Registers
Z80 assembly exposes considerably more register state than 8080 assembly. In addition to the accumulator (A) and flags, and the B, C, D, E, H and L general-purpose registers, the Z80 has:
- A shadow (alternate) register set — A’, F’, B’, C’, D’, E’, H’, L’ — swapped in with the
EXXandEX AF,AF'instructions, used for fast interrupt handling or context switching without saving registers to memory. - Two 16-bit index registers, IX and IY, used for indexed addressing such as
LD A,(IX+6). - Dedicated interrupt-related registers: I (interrupt vector) and R (memory refresh counter).
Mnemonic scheme
The table below shows how Z80 assembly restates common 8080 operations with a smaller, more regular set of mnemonics:
| Operation | 8080 (Intel) | Z80 (Zilog) |
|---|---|---|
| Move register to register | MOV A,B | LD A,B |
| Load immediate | MVI A,5 | LD A,5 |
| Load register pair immediate | LXI H,1234H | LD HL,1234H |
| Load from memory via HL | MOV A,M | LD A,(HL) |
| Add register pair | DAD D | ADD HL,DE |
| Conditional jump | JNZ LOOP | JP NZ,LOOP |
| Decrement and jump if nonzero | (no direct equivalent) | DJNZ LOOP |
LD alone replaces the 8080’s MOV, MVI, LDA, STA, LXI, LHLD and SHLD; the destination and source are read from the operand syntax instead of the mnemonic. Parenthesizing an operand, as in LD A,(HL) or LD (1200H),A, indicates “the memory location addressed by,” a convention used consistently across the instruction set. DJNZ — decrement B and jump if the result is nonzero — is a Z80 addition with no 8080 equivalent, aimed squarely at loop counters.
Statement syntax
Zilog’s manual defines the same four-field statement layout as most contemporary assemblers — label, operation, operand and comment — with its own conventions:
- Labels are followed by a colon when they appear alone on a line before an instruction.
- Numeric literals take a trailing letter for their base:
Hfor hexadecimal,OorQfor octal,Bfor binary, and decimal by default. - Comments are introduced with a semicolon.
- Assembler commands (pseudo-ops) include
ORG,EQU,DEFB/DB,DEFW/DW,DEFS/DS,MACRO/ENDM,IF/ENDIFandEND, covering location-counter control, symbol definition, data storage, macros and conditional assembly.
Code Examples
The excerpt below is a simple Z80 loop, written in the mnemonic style documented in Zilog’s manual, that fills a block of memory with a byte value:
| |
DJNZ folds the decrement-and-branch into a single instruction, something 8080 assembly needs two separate opcodes (DCR B and JNZ) to express.
Under CP/M, calling BDOS function 9 to print a $-terminated string looks like this in Z80 mnemonics:
| |
The same routine assembles to the same bytes as the 8080 version shown for CP/M’s BDOS interface, since CP/M’s calling convention did not depend on which mnemonic dialect produced the machine code.
Evolution
Undocumented behavior
Beyond its documented instruction set, the Z80’s IX and IY index registers can each be addressed as two independent 8-bit halves (informally called IXH/IXL and IYH/IYL) through undocumented opcodes. Zilog never officially documented this capability, but hobbyist and later professional Z80 programmers discovered and made use of it, and modern cross assemblers commonly support these undocumented forms as an option.
Later Zilog cores
Zilog extended the Z80 architecture rather than replacing its assembly language outright:
- The Z180, a CMOS redesign with on-chip peripherals, was built to be software-compatible with the Z80 so that existing Z80 assembly code and binaries could run on it unchanged.
- The Z280, a 16-bit implementation of the architecture, shipped in 1987.
- The eZ80, introduced in 2001, is a fully pipelined core that remains instruction-set compatible with the Z80 while extending addressing to a 24-bit linear space, and is still used in embedded microcontrollers.
A widely imitated, never-copied core
Several chip designers built processors clearly influenced by the Z80 without being drop-in compatible with it. Nintendo’s Game Boy, for example, uses a Sharp custom CPU (commonly called the Game Boy CPU or SM83) that combines elements of the 8080 and Z80 instruction sets and register model but is not opcode-compatible with either; Game Boy programmers write in a Z80-like but distinct assembly dialect for that reason.
Current Relevance
The original Z80 part stayed in continuous production for 48 years, with Zilog (by then a Littelfuse subsidiary) discontinuing new orders in June 2024. Its assembly language remains active in several communities today:
- Retrocomputing and emulation. ZX Spectrum, TRS-80, MSX, Amstrad CPC and CP/M emulators all execute genuine Z80 code, and writing a Z80 emulator remains a common exercise in learning CPU emulation.
- Calculator programming. Texas Instruments’ Z80-based graphing calculators, including the TI-83 and TI-83 Plus families, support a long-running hobbyist scene that writes native Z80 assembly programs and games.
- Demoscene and homebrew development. Programmers still write new ZX Spectrum, MSX and Game Boy-adjacent homebrew software in Z80 or Z80-family assembly, often using modern cross assemblers that also support the chip’s undocumented instructions.
- Embedded use. Zilog’s eZ80 descendants keep the Z80 instruction set in production for embedded control applications even after the original part’s retirement.
Why It Matters
The Z80 took an established instruction set — the Intel 8080’s — and wrapped it in a new, more regular assembly language while extending the underlying hardware with faster interrupts, a second register set and index addressing. That combination of binary compatibility with 8080 software and low system cost made it the CPU of choice for a huge share of 8-bit personal computers, arcade boards and early game consoles. Because so much of that software was written directly in assembly for performance, Z80 mnemonics were the first programming language many 1980s programmers ever used professionally, and the LD-based, operand-driven style Zilog introduced influenced how later assembly languages, including its own Z180, Z280 and eZ80 descendants, presented data movement.
Timeline
Notable Uses & Legacy
TRS-80 (Tandy/Radio Shack)
The 1977 TRS-80 Model I used a 1.77 MHz Z80 and shipped with a BASIC interpreter in ROM. Owners who went beyond BASIC wrote Z80 assembly directly, using Radio Shack's Editor/Assembler package or third-party tools, to get at hardware the interpreter did not expose.
CP/M business microcomputers (Digital Research)
CP/M ran on both 8080 and Z80 hardware, and machines such as the Osborne 1 and Kaypro II used the Z80's extra instructions and interrupt modes while remaining binary-compatible with 8080-only CP/M software. Vendors wrote Z80-specific BIOS layers in Z80 assembly to support their hardware.
Sinclair ZX Spectrum
Sinclair's 1982 ZX Spectrum used a Z80A and became the dominant home computer of 1980s Britain. Commercial games were routinely written in Z80 assembly, or in BASIC with assembly-coded routines for graphics and sound, to get playable performance from the machine's limited clock speed.
Sega Master System and Game Gear
Sega's Master System (1985) used a Z80 as its main processor, and its 1990 Game Gear handheld reused the same core. Game programmers wrote the systems' game code directly in Z80 assembly to fit cartridge size and timing constraints.
MSX standard home computers
The MSX standard, backed by Microsoft and ASCII Corporation and adopted by manufacturers including Sony, Panasonic and Toshiba, specified a Z80A CPU. MSX BASIC programs called out to Z80 assembly routines, and MSX games were commonly written in assembly for speed.
Texas Instruments graphing calculators
TI's Z80-based calculators, including the TI-83 and TI-83 Plus series, expose the Z80 to users directly: a long-running hobbyist community writes Z80 assembly programs and games that run natively on the calculator hardware.