CPIR¶
- CPIR
- Compare and Increment with Repeat
- Description
- Performs
cpiuntil eitherA=(HL)orBC= 0.cp a,(hl) inc hl dec bc jr nz,-7 ret po jr -10
- Uses
- Finding a certain letter in a string (or other similar tasks)
- Results
Register/Flag 16-bit (non-ADL) 24-bit (ADL) SflagSet if result is negative; else reset ZflagSet if A=(HL); else resetHflagSet if borrow from bit 4; else reset P/VflagSet if BC≠ 0 after the operation; else resetNflagSet CflagNot affected - Allowed Instructions
Instruction Opcode CC (ADL/non-ADL) CC (.S) CC (.L) cpir $ED, $B9 2F + (Iterations)*(1R + 2) - 1whereIterationsis the number of iterations ofcpibefore eitherA=(HL)orBC= 03F + (Iterations)*(1R + 2) - 1 3F + (Iterations)*(1R + 2) - 1 - Notes
- Interrupts can be triggered while this instruction is in progress (unless they are disabled using
DI, of course).
- Interrupts can be triggered while this instruction is in progress (unless they are disabled using
- See Also
- CP, CPD, CPDR, CPI, LDIR