http://learn.cemetech.net/index.php?title=Z80:Opcodes:CPIR&feed=atom&action=historyZ80:Opcodes:CPIR - Revision history2024-03-29T09:43:59ZRevision history for this page on the wikiMediaWiki 1.34.0http://learn.cemetech.net/index.php?title=Z80:Opcodes:CPIR&diff=291&oldid=prevMaintenance script: Initial automated import2016-02-05T22:21:26Z<p>Initial automated import</p>
<p><b>New page</b></p><div><!-- Short summary of instruction --><br />
Repeats [[Z80:Opcodes:CPI|CPI]] until either:<br />
* BC=0<br />
* A=HL<br />
<br />
== Syntax ==<br />
<br />
<!-- Syntax for this instruction --><br />
<br />
No operands.<br />
<br />
CPIR<br />
<br />
== Effects ==<br />
<br />
<!-- What the instruction does to flags --><br />
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.<br />
<br />
== Uses ==<br />
<br />
If you want to find the first occurrence of 124 in the valid memory space:<br />
<br />
<br />
LD HL,0000h<br />
LD BC,0000h<br />
LD A,124<br />
CPIR<br />
<br />
<br />
Note if you used [[Z80:Opcodes:CPDR|CPDR]] it would find the last occurrence of 124 in the valid memory space.<br />
<br />
== T-States ==<br />
<br />
{| class="wikitable"<br />
| BC ≠ 0 and A ≠ (HL) || 21 <br />
|-<br />
| BC = 0 or A = (HL) || 16 <br />
|}<br />
<br />
== See Also ==<br />
<br />
<!-- Other instructions that are related to this one --><br />
[[Z80:Opcodes:BIT|BIT]],[[Z80:Opcodes:CALL|CALL]],[[Z80:Opcodes:CP|CP]],[[Z80:Opcodes:CPD|CPD]],[[Z80:Opcodes:CPDR|CPDR]],[[Z80:Opcodes:CPI|CPI]],[[Z80:Opcodes:JP|JP]],[[Z80:Opcodes:JR|JR]]<br />
<br />
{{lowercase}}<br />
[[Category:Z80 Assembly]]<br />
[[Category:Z80 Heaven]]<br />
[[Category:Z80 Opcodes]]</div>Maintenance script