# Z-80 Instructions: Part C.

 Mnemonic SymbolicOperation Flags OP-Code No. ofBytes No. ofM Cycles No. ofT Cycles Comments C Z P/V S N H 76 543 210 EX DE,HL DE ↔ HL ' • • • • • • 01 101 011 1 1 4 EX AF,AF' AF ↔ AF' • • • • • • 00 001 000 1 1 4 EXX BC ↔ BC ' DE ↔ DE ' HL ↔ HL ' • • • • • • 11 011 001 1 1 4 Register bank and auxiliary register bank exchange EX (SP),HL H ↔ (SP+1)L ↔ (SP) • • • • • • 11 100 011 1 5 19 EX (SP),IX IXH ↔ (SP+1)IXL ↔ (SP) • • • • • • 11 011 101 11 100 011 2 6 23 EX (SP),IY IYH ↔ (SP+1)IYL ↔ (SP) • • • • • • 11 111 101 11 100 011 2 6 23 LDI (DE) ← (HL) DE ← DE + 1 HL ← HL + 1 BC ← BC - 1 • • ①↕ • 0 0 11 101 10110 100 000 2 4 16 Load (HL) into (DE),increment the pointers anddecrement the byte counter (BC) LDIR (DE) ← (HL) DE ← DE + 1 HL ← HL + 1 BC ← BC - 1 Repeat until BC = 0 • • 0 • 0 0 11 101 10110 110 000 22 54 2116 If BC ≠ 0If BC = 0 LDD (DE) ← (HL) DE ← DE - 1 HL ← HL - 1 BC ← BC - 1 • • ①↕ • 0 0 11 101 10110 101 000 2 4 16 LDDR (DE) ← (HL) DE ← DE - 1 HL ← HL - 1 BC ← BC - 1 Repeat until BC = 0 • • 0 • 0 0 11 101 10110 111 000 22 54 2116 If BC ≠ 0If BC = 0 CPI A - (HL) DE ← DE + 1 HL ← HL + 1 BC ← BC - 1 • ②↕ ①↕ ↕ 1 ↕ 11 101 10110 100 001 2 4 16 CPIR A - (HL) DE ← DE + 1 HL ← HL + 1 BC ← BC - 1 Repeat until A = (HL) or BC = 0 • ②↕ ①↕ ↕ 1 ↕ 11 101 10110 110 001 2 2 5 4 21 16 If BC ≠ 0 and     A ≠ (HL)If BC = 0 or    A = (HL) CPD A - (HL) DE ← DE - 1 HL ← HL - 1 BC ← BC - 1 • ②↕ ①↕ ↕ 1 ↕ 11 101 10110 101 001 2 4 16 CPDR (DE) ← (HL) DE ← DE - 1 HL ← HL - 1 BC ← BC - 1 Repeat until A = (HL) or BC = 0 • ②↕ ①↕ ↕ 1 ↕ 11 101 10110 111 001 2 2 5 4 21 16 If BC ≠ 0 and       A ≠ (HL)If BC = 0 or      A = (HL)

 Notes: ①  P/V flag is 0 if the result of BC-1 = 0, otherwise P/V =1 ②  Z flag is 1 if A = (HL), otherwise Z = 0 Flag Notation: • = flag not affected, 0 = flag reset, 1 = flag set, X = flag is unknown, ↕ = flag is affected according to the result of the operation.