Difference between revisions of "Z80 wait instructions"

From MSX Game Library

 
(39 intermediate revisions by the same user not shown)
Line 1: Line 1:
 +
Z80 instruction set that don't change registers value (except for F register):
 
{| class="wikitable"
 
{| class="wikitable"
! Inst. !! Wait<br/>CC !! Size<br/>(bytes) !! Flag modification
+
! Inst. !! T-S !! Bytes !! Flag modification
 
|-
 
|-
| <tt>NOP</tt>         ||  5 || 1 || None
+
| <tt>NOP</tt>                   ||  5 || 1 || None
 
|-
 
|-
| <tt>OR 0</tt>       ||  8 || 2 || C and N flags cleared, P/V detects parity, and rest are modified by definition.
+
| <tt>CP (HL)</tt>               ||  8 || 1 || C, S, and Z flags modified by definition. P/V detects overflow.
 
|-
 
|-
| <tt>NOP<br/>NOP</tt> || 10 || 2 || None
+
| <tt>NOP<br/>NOP</tt>           || 10 || 2 || None
 
|-
 
|-
| <tt>NOP<br/>OR 0</tt>|| 13 || 3 || C and N flags cleared, P/V detects parity, and rest are modified by definition.
+
| <tt>SCF<br/>RET NC</tt>         || 11 || 2 || Carry flag set, H and N cleared, rest are preserved.
 
|-
 
|-
| <tt>BIT 0,(HL)</tt> || 14 || 2 || Opposite of the bit #0 is written into the Z flag. C is preserved, N is reset, H is set, and S and P/V are undefined.
+
| <tt>JR $+2</tt>                || 13 || 2 || None
 +
|-
 +
| <tt>BIT 0,(HL)</tt>             || 14 || 2 || Opposite of the bit #0 is written into the Z flag. C is preserved, N is reset, H is set, and S and P/V are undefined.
 +
|-
 +
| <tt>NOP<br/>NOP<br/>NOP</tt>    || 15 || 3 || None
 +
|-
 +
| <tt>CP (HL)<BR/>CP (HL)</tt>    || 16 || 2 || C, S, and Z flags modified by definition. P/V detects overflow.
 +
|-
 +
| <tt>SCF<br/>RET NC<br/>RET NC</tt> || 17 || 3 || Carry flag set, H and N cleared, rest are preserved.
 +
|-
 +
| <tt>NOP<br/>JR $+2</tt>        || 18 || 3 || None
 +
|-
 +
| <tt>NOP<br/>BIT 0,(HL)</tt>    || 19 || 3 || Opposite of the bit #0 is written into the Z flag. C is preserved, N is reset, H is set, and S and P/V are undefined.
 +
|-
 +
| <tt>NOP<br/>NOP<br/>NOP<br/>NOP</tt> || 20 || 4 || None
 +
|-
 +
| <tt>CP (IY+0)</tt>              || 21 || 3 || C, S, and Z flags modified by definition. P/V detects overflow.
 +
|-
 +
| <tt>CP (HL)<br/>BIT 0,(HL)</tt> || 22 || 3 || C, S, and Z flags modified by definition. P/V detects overflow.<br/>Opposite of the bit #0 is written into the Z flag. C is preserved, N is reset, H is set, and S and P/V are undefined.
 +
|-
 +
| <tt>PUSH AF<br/>POP AF</tt>    || 23 || 2 || None
 +
|-
 +
| <tt>CP (HL)<BR/>CP (HL)<BR/>CP (HL)</tt> || 24 || 3 || C, S, and Z flags modified by definition. P/V detects overflow.
 +
|- style="background-color:lightgray;"
 +
| <tt>INC (HL)<br/>DEC (HL)</tt>  || 24 || 2 || Preserves C flag, N flag is reset, P/V detects overflow and rest are modified by definition.<br/>C flag preserved, P/V detects overflow and rest modified by definition.<br/>⚠️ Not interrupt safe
 +
|-
 +
| <tt>NOP<br/>NOP<br/>NOP<br/>NOP<br/>NOP</tt> || 25 || 5 || None
 +
|-
 +
| <tt>JR $+2<br/>JR $+2</tt>      || 26 || 4 || None
 +
|-
 +
| <tt>NOP<br/>CP (HL)<br/>BIT 0,(HL)</tt> || 27 || 4 || C, S, and Z flags modified by definition. P/V detects overflow.<br/>Opposite of the bit #0 is written into the Z flag. C is preserved, N is reset, H is set, and S and P/V are undefined.
 +
|-
 +
| <tt>NOP<br/>PUSH AF<br/>POP AF</tt> || 28 || 3 || None
 +
|-
 +
| <tt>CP (IY+0)<br/>CP (HL)</tt>  || 29 || 4 || C, S, and Z flags modified by definition. P/V detects overflow.
 +
|- style="background-color:lightgray;"
 +
| <tt>NOP<br/>INC (HL)<br/>DEC (HL)</tt>  || 29 || 3 || Preserves C flag, N flag is reset, P/V detects overflow and rest are modified by definition.<br/>C flag preserved, P/V detects overflow and rest modified by definition.<br/>⚠️ Not interrupt safe
 +
|-
 +
| <tt>BIT 0,(HL)<br/>CP (HL)<br/>CP (HL)</tt> || 30 || 4 || Opposite of the bit #0 is written into the Z flag. C is preserved, N is reset, H is set, and S and P/V are undefined.<br/>C, S, and Z flags modified by definition. P/V detects overflow.
 
|}
 
|}

Latest revision as of 19:08, 6 April 2024

Z80 instruction set that don't change registers value (except for F register):

Inst. T-S Bytes Flag modification
NOP 5 1 None
CP (HL) 8 1 C, S, and Z flags modified by definition. P/V detects overflow.
NOP
NOP
10 2 None
SCF
RET NC
11 2 Carry flag set, H and N cleared, rest are preserved.
JR $+2 13 2 None
BIT 0,(HL) 14 2 Opposite of the bit #0 is written into the Z flag. C is preserved, N is reset, H is set, and S and P/V are undefined.
NOP
NOP
NOP
15 3 None
CP (HL)
CP (HL)
16 2 C, S, and Z flags modified by definition. P/V detects overflow.
SCF
RET NC
RET NC
17 3 Carry flag set, H and N cleared, rest are preserved.
NOP
JR $+2
18 3 None
NOP
BIT 0,(HL)
19 3 Opposite of the bit #0 is written into the Z flag. C is preserved, N is reset, H is set, and S and P/V are undefined.
NOP
NOP
NOP
NOP
20 4 None
CP (IY+0) 21 3 C, S, and Z flags modified by definition. P/V detects overflow.
CP (HL)
BIT 0,(HL)
22 3 C, S, and Z flags modified by definition. P/V detects overflow.
Opposite of the bit #0 is written into the Z flag. C is preserved, N is reset, H is set, and S and P/V are undefined.
PUSH AF
POP AF
23 2 None
CP (HL)
CP (HL)
CP (HL)
24 3 C, S, and Z flags modified by definition. P/V detects overflow.
INC (HL)
DEC (HL)
24 2 Preserves C flag, N flag is reset, P/V detects overflow and rest are modified by definition.
C flag preserved, P/V detects overflow and rest modified by definition.
⚠️ Not interrupt safe
NOP
NOP
NOP
NOP
NOP
25 5 None
JR $+2
JR $+2
26 4 None
NOP
CP (HL)
BIT 0,(HL)
27 4 C, S, and Z flags modified by definition. P/V detects overflow.
Opposite of the bit #0 is written into the Z flag. C is preserved, N is reset, H is set, and S and P/V are undefined.
NOP
PUSH AF
POP AF
28 3 None
CP (IY+0)
CP (HL)
29 4 C, S, and Z flags modified by definition. P/V detects overflow.
NOP
INC (HL)
DEC (HL)
29 3 Preserves C flag, N flag is reset, P/V detects overflow and rest are modified by definition.
C flag preserved, P/V detects overflow and rest modified by definition.
⚠️ Not interrupt safe
BIT 0,(HL)
CP (HL)
CP (HL)
30 4 Opposite of the bit #0 is written into the Z flag. C is preserved, N is reset, H is set, and S and P/V are undefined.
C, S, and Z flags modified by definition. P/V detects overflow.