ArticleslgStudy

science

Z80 instruction set

Z80 instruction set is a science topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand Z80 instruction set rather than just read about it. In short: The Zilog Z80 is an 8-bit microprocessor introduced in 1976. The instruction set was designed to be upward binary compatible with the Intel 8080.

Z80 instruction set — main illustration
Z80 instruction set — illustration

Key takeaways

  • Z80 instruction set belongs to science; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect Z80 instruction set to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of Z80 instruction set from memory before moving on to harder problems.

Reference excerpt

The Zilog Z80 is an 8-bit microprocessor introduced in 1976. The instruction set was designed to be upward binary compatible with the Intel 8080. Intel 8080 instructions are one to three bytes long whereas the Z80 requires up to four bytes per instruction. Zilog continued to expand the instruction set of the Z80 with several successors including the Z180, Z280, and Z380. The latest iteration, the eZ80, was introduced in 2001 and was available for purchase as of 2025. The instruction set also appears on non-Zilog CPUs such as the Hitachi HD64180, Mitsui R800, and the Eastern Bloc U880.

Instruction set The Z80 uses 252 out of the available 256 codes as single byte opcodes (the "root instructions"), most of which are inherited from the 8080. The four remaining codes are used extensively as opcode prefixes: CB and ED enable extra instructions, and DD or FD select IX or IY respectively in place of HL. This scheme gives the Z80 a large number of permutations of instructions and registers. Zilog categorizes these into 158 different "instruction types", 78 of which are the same as those of the Intel 8080. This allows operation of all 8080 programs on a Z80. The Zilog documentation further groups instructions into categories. Most are from the 8080, others are entirely new like the block and bit instructions, and other 8080 instructions with more versatile addressing modes, like the 16-bit loads, I/O, rotates/shifts, and relative jumps. The categories are:

Load and exchange Block transfer and search Arithmetic and logical Rotate and shift Bit manipulation (set, reset, test) Jump, call, and return Input/output CPU control

Encoding order To expand on the 8080 instruction set, Z80 instructions may require a IX/IY override, an opcode prefix, or both. Any one instruction may contain up to four components. The components of the instruction are assembled in the following order:

Root instructions

The root opcodes include all the 8080 opcodes. The Z80 adds eight new one-byte instructions, two opcode prefixes, and the IX and IY overrides. Colored rows indicate new Z80 instructions.

Instructions prefixed with ED The ED-prefixed opcodes are a catch-all of new Z80 instructions that could not be encoded in one byte. This group encompasses only 60 of 256 available opcodes.

Instructions prefixed with CB

The CB-prefixed opcodes cover shifts and rotates plus the bit test, clear, and set instructions. All of these instructions can be used with any register or memory. The (HL) form of these instructions can be combined with an IX or IY opcode prefix to operate on (IX+d) or (IY+d). This group encompasses 248 of 256 available opcodes.

IX and IY overrides Two opcode prefixes expand the number of Z80 addressing modes to access the new IX and IY index registers:

Prefix DD changes HL to IX or (HL) to (IX+displacement) Prefix FD changes HL to IY or (HL) to (IY+displacement) The index registers, IX and IY, were intended as flexible 16-bit pointers, enhancing the ability to manipulate memory, stack frames, and data structures. Officially, they were treated as 16-bit only. In reality, they were implemented as a pair of 8-bit registers in the same fashion as the HL register, which is accessible either as 16 bits or separately as the high and low registers. The binary opcodes were identical, but preceded by a new opcode prefix.

Undocumented uses of IX/IY Zilog published the opcodes and related mnemonics for the intended functions, but did not document the fact that every opcode that allowed manipulation of the HL register was equally valid for the 8-bit halves of the IX and IY registers. For example, opcode 26h followed by an immediate byte value forms the instruction LD H,n. It will load the n immediate value into the H register. Preceding this two-byte instruction with the IX register's opcode prefix, DD, would instead result in the most significant 8 bits of the IX register being loaded with that same value. A notable exception to this would be instructions similar to LD H,(IX+d) which make use of both the HL and IX or IY registers in the same instruction. In this case the DD prefix is only applied to the (IX+d) portion of the instruction. Accessing the IX/IY halves can speed some operations. To load DE into IX using official instructions, one could use PUSH DE and POP IX, taking 25 cycles. Using the half-load feature, the same could be coded as LD IXL,E and LD IXH,D, saving 9 cycles but taking an extra byte. The IX and IY halves can also hold operands for 8-bit arithmetic, logical, and compare instructions, sparing the regular 8-bit registers for other use. Any IX/IY half can be incremented or decremented or loaded to or from any 8-bit register except H or L.

Instruction synonyms The Z80 expands the 8080 instruction set and makes it more orthogonal. A byproduct of this is there are certain instruction functions that map to two different instruction encodings. In a few cases there is an 8080 instruction coding that is smaller and faster than the orthogonal Z80 encoding. Some examples:

The Z80 introduced orthogonal versions of LD RP,(nn) and LD (nn),RP instructions where RP can be any register pair or SP. The Z80 assembler substitutes the 8080 version of LD HL,(nn) and LD (nn),HL to save a byte and four clocks. RL A, RR A, RLC A, RRC A, and SLA A instructions are part of the Z80 CB-prefixed rotates. The 8080 RLA, RRA, RLCA, RRCA, and ADD A,A instructions are a byte smaller and twice as fast. The Z80 introduced a two-byte unconditional jump, JR. Although larger, the three-byte 8080 JP is two clocks faster. The Z80 added two-byte conditional jumps: JR NZ, JR Z, JR NC, and JR C as alternates to the 8080 three byte conditional jumps: JP NZ, JP Z, JP NC, and JP C. Although the two-byte forms are two clocks slower when taken, they are three clocks faster when not taken. The Z80 DJNZ instruction is half the size of the 8080 equivalent instructions and one clock faster.

References

Illustrations

Z80 instruction set: Zilog Z80 CPU. 1976 date code.
Zilog Z80 CPU. 1976 date code.
Z80 instruction set: Shift and rotate instructions. SLL is an undefined instruction.
Shift and rotate instructions. SLL is an undefined instruction.

Worked examples

Example 1 — a first encounter with Z80 instruction set

Start with the simplest possible case. Write down what Z80 instruction set claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In science, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to Z80 instruction set before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about Z80 instruction set ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of Z80 instruction set

In research
Z80 instruction set appears in science research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses Z80 instruction set in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
Z80 instruction set is common in secondary-school and first-year university syllabi. It links to neighbouring topics Instruction set architectures, so understanding it makes those chapters shorter.
In everyday life
Look for Z80 instruction set outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.
Ask Teacher Smith questions about this articleOpens your AI tutor with a question about “Z80 instruction set” →

How to study Z80 instruction set in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what Z80 instruction set means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain Z80 instruction set out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is Z80 instruction set in simple terms?

The Zilog Z80 is an 8-bit microprocessor introduced in 1976. The instruction set was designed to be upward binary compatible with the Intel 8080.

Why does Z80 instruction set matter?

Because it connects several science ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study Z80 instruction set?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on Z80 instruction set.

Tags

  • Instruction set architectures

Keep exploring