What the eZ80 is
The eZ80 runs Z80 programs and adds a 24-bit address space (16 MiB), 24-bit registers, a hardware multiplier and a set of new instructions. It is found in the Agon Light and the TI-84 Plus CE. The Z80 instructions are as on the Z80 page; this page lists only what differs.
ADL mode and Z80 mode
The processor is in one of two modes, held in the ADL bit. In ADL mode addresses and the 16-bit registers
BC DE HL IX IY SP are 24 bits wide; a 16-bit number in an instruction (nn) becomes 24 bits, and the stack holds three bytes per pushed pair.
In Z80 mode they are 16 bits and the address is completed from the MBASE register. A program switches between the modes with jumps, calls and returns that carry a suffix
(STMIX and RSMIX set and clear the separate MADL flag), so the bytes alone do not say which mode a piece of code runs in.
This matters because the length of an instruction depends on the mode. LD HL,nn is 3 bytes in Z80 mode and 4 in ADL mode.
The explorer cannot tell, so its eZ80 disassembly has an option, Mode, with the choices ADL mode and Z80 mode. It decodes
every byte as an instruction start, so you can see how the code reads in each mode.
| Instruction | Z80 mode | ADL mode |
|---|---|---|
LD rr,nn, LD IX,nn | 3 (4) bytes | 4 (5) bytes |
LD HL,(nn), LD (nn),HL, LD A,(nn), LD (nn),A | 3 bytes | 4 bytes |
LD rr,(nn), LD (nn),rr (ED) | 4 bytes | 5 bytes |
JP nn, JP cc,nn, CALL nn, CALL cc,nn | 3 bytes | 4 bytes |
| all others | as on the Z80 (relative jumps stay one byte) | |
Suffix opcodes
Four opcodes that do nothing on a Z80 (LD B,B, LD C,C, LD D,D, LD E,E) are on the eZ80 prefixes that override the mode for
one instruction. The first letter is the size of the instruction’s own addressing (the stack and pointer width), the second the size of the
immediate address or data:
| Opcode | Suffix | Meaning | Immediate |
|---|---|---|---|
40 | .SIS | Short instruction, short immediate | 16 bits |
49 | .LIS | Long instruction, short immediate | 16 bits |
52 | .SIL | Short instruction, long immediate | 24 bits |
5B | .LIL | Long instruction, long immediate | 24 bits |
The suffix and the instruction after it are one instruction: the viewer writes it as ld.lil hl,$123456. A short instruction jumps within the MBASE segment:
the viewer shows the 24-bit immediate as written and takes the low 16 bits as the target. The Agon core agrees on the length of every suffixed instruction tried; for a
CALL.SIL it goes to the full 24-bit address, where JP.SIL uses the low 16 bits.
Added instructions
All are in the ED page (some in DD and FD). The eZ80 gives the Z80’s repeated ED opcodes new meanings, so the
Z80’s “undocumented duplicates” of NEG, RETN and IM do not all exist on the eZ80.
| Mnemonic | Encoding (ED unless noted) | Bytes | What it does |
|---|---|---|---|
MLT | 4C BC · 5C DE · 6C HL · 7C SP | 2 | Multiply the high and low bytes of the pair; the 16-bit product replaces the pair. |
TST | A,r: 04 0C 14 1C 24 2C 3C (B C D E H L A) · A,(HL): 34 · A,n: 64 | 2–3 | AND with A without storing the result; sets S Z P, H set, N and C cleared. |
TSTIO | 74 n | 3 | AND n with the port addressed by C, without storing. |
IN0 | r,(n): 00 08 10 18 20 28 38 (B C D E H L A) | 3 | Read the port with an 8-bit address n. |
OUT0 | (n),r: 01 09 11 19 21 29 39 | 3 | Write the port with an 8-bit address n. |
LEA | rr,IX+d: 02 BC · 12 DE · 22 HL · 32 IX · 55 IYrr,IY+d: 03 BC · 13 DE · 23 HL · 33 IY · 54 IX | 3 | Load the address IX+d or IY+d into a register pair, without reading memory. |
PEA | 65 IX+d · 66 IY+d | 3 | Push the address IX+d or IY+d. |
LD | BC,(HL) 07 · DE,(HL) 17 · HL,(HL) 27 · IX,(HL) 37 · IY,(HL) 31(HL),BC 0F · DE 1F · HL 2F · IX 3F · IY 3EMB,A 6D · A,MB 6E · I,HL C7 · HL,I D7without ED: DD/FD 07 17 27 31 37 (LD rr,(IX+d), with IX or IY in 31 and 37) and 0F 1F 2F 3E 3F (LD (IX+d),rr) | 2–3 | Load and store a 24-bit pair through HL or IX+d or IY+d; set or read the memory base register. |
STMIX | 7D | 2 | Select mixed-memory mode (the MADL flag). |
RSMIX | 7E | 2 | Leave mixed-memory mode. |
SLP | 76 | 2 | Sleep until an interrupt. |
INIM, INIMR, INDM, INDMR | 82 92 8A 9A | 2 | Block input instructions of the eZ80 (the exact operation is in UM0077). |
INI2, INI2R, IND2, IND2R | 84 94 8C 9C | 2 | Block input instructions of the eZ80 (UM0077). |
OTIM, OTIMR, OTDM, OTDMR | 83 93 8B 9B | 2 | Block output instructions of the eZ80 (UM0077). |
OUTI2, OTI2R, OUTD2, OTD2R | A4 B4 AC BC | 2 | Block output instructions of the eZ80 (UM0077). |
INIRX, INDRX, OTIRX, OTDRX | C2 CA C3 CB | 2 | Repeating block I/O instructions of the eZ80 (UM0077). |
Every instruction’s mnemonics are cross-checked in the assembler test list of GNU binutils (see sources); the encodings above were checked by running them on the Agon core.
What the real core says
Each opcode sequence, in both modes and behind each suffix, was run on the eZ80 core of the Agon Light emulator (5,228 combinations of opcode sequence and mode). The length agrees with the decoder for 5,201 of the 5,204 documented sequences. Differences found:
TSTIO n: the manual gives three bytes (ED 74 n); the core takes two.- The core also runs
ED 0A 0B 1A 1B 2A 2B 3A 3Bas three-byteLEAs (the same as02 03 12 13 22 23 32 33). The manual lists only one encoding of each; the viewer follows the manual and shows these as two-byte no-ops. CALL.SILgoes to the full 24-bit address in the core, whereJP.SILuses the low 16 bits.- In the undocumented
DD CB d opregister copies the core applies the prefix to H and L (it writes IXH or IXL). - A
DDorFDbefore a suffix opcode is taken by the core as one prefixed instruction; the viewer shows theDDalone.
Sources
- eZ80 CPU User Manual (UM0077) – Zilog
- ez80_adl_all.s – GNU binutils assembler test, the list of eZ80 mnemonics
- TSTIO n – eZ80 user manual page
Not described
- Cycle counts: the explorer does not show them for the eZ80.
- The undocumented Z80 opcodes on the eZ80 (IXH and IXL, SLL, the DDCB register copies, ED duplicates): they are decoded as on the Z80 and marked undocumented, but whether the eZ80 hardware runs them is not checked.
- The encodings of the block I/O additions come from memory of the manual and the Agon core only; they have not been re-read against the printed table.
- Following the mode through the program (the viewer does not track
STMIX,RSMIXor suffixed calls: you choose the mode).