z80:Opcodes:CPIR

From Learn @ Cemetech
Jump to navigationJump to search
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

Repeats CPI until either:

  • BC=0
  • A=HL

Syntax

No operands.

   CPIR

Effects

The carry is preserved, N is set and all the other flags are affected as defined. P/V denotes the overflowing of BC, while the Z flag is set if A=(HL) before HL is decreased.

Uses

If you want to find the first occurrence of 124 in the valid memory space:


   LD HL,0000h
   LD BC,0000h
   LD A,124
   CPIR


Note if you used CPDR it would find the last occurrence of 124 in the valid memory space.

T-States

BC ≠ 0 and A ≠ (HL) 21
BC = 0 or A = (HL) 16

See Also

BIT,CALL,CP,CPD,CPDR,CPI,JP,JR