Changes

Jump to: navigation, search

Z80

1,652 bytes added, 10 March
/* Z80 Instructions */
* wz = an internal 16-bit register connected to 16-bit operations
* tmp, tmp2 = temporary storage whose value is thrown away after each instruction
 
=== 8-bit ALU group ===
 
{| class="wikitable" style="white-space: nowrap;"
|-
! Instruction !! Opcode !! NOPs !! Cycles !! S !! Z !! 5 !! H !! 3 !! P !! N !! C !! Effect !! Description
|-
| add a,R || 10000rrr || 1 || 4 (4) || + || + || + || + || + || V || 0 || + || a += R ||rowspan=5|Add
|-
| add a,J || 11i11101 1000010b || 2 || 8 (4,4) || + || + || + || + || + || V || 0 || + || a += J
|-
| add a,N || 11000110 nnnnnnnn || 2 || 7 (4,3) || + || + || + || + || + || V || 0 || + || a += N
|-
| add a,(hl) || 10000110 || 2 || 7 (4,3) || + || + || + || + || + || V || 0 || + || a += (hl)
|-
| add a,(I+D) || 11i11101 10000110 dddddddd || 5 || 19 (4,4,3,5,3) || + || + || + || + || + || V || 0 || + || a += (I+D)
|-
| adc a,R || 10001rrr || 1 || 4 (4) || + || + || + || + || + || V || 0 || + || a += R + cf ||rowspan=5|Add with Carry
|-
| adc a,J || 11i11101 1000110b || 2 || 8 (4,4) || + || + || + || + || + || V || 0 || + || a += J + cf
|-
| adc a,N || 11001110 nnnnnnnn || 2 || 7 (4,3) || + || + || + || + || + || V || 0 || + || a += N + cf
|-
| adc a,(hl) || 10001110 || 2 || 7 (4,3) || + || + || + || + || + || V || 0 || + || a += (hl) + cf
|-
| adc a,(I+D) || 11i11101 10001110 dddddddd || 5 || 19 (4,4,3,5,3) || + || + || + || + || + || V || 0 || + || a += (I+D) + cf
|-
| sub R || 10010rrr || 1 || 4 (4) || + || + || + || + || + || V || 1 || + || a -= R ||rowspan=5|Subtract
|-
| sub J || 11i11101 1001010b || 2 || 8 (4,4) || + || + || + || + || + || V || 1 || + || a -= J
|-
| sub N || 11010110 nnnnnnnn || 2 || 7 (4,3) || + || + || + || + || + || V || 1 || + || a -= N
|-
| sub (hl) || 10010110 || 2 || 7 (4,3) || + || + || + || + || + || V || 1 || + || a -= (hl)
|-
| sub (I+D) || 11i11101 10010110 dddddddd || 5 || 19 (4,4,3,5,3) || + || + || + || + || + || V || 1 || + || a -= (I+D)
|-
| sbc a,R || 10011rrr || 1 || 4 (4) || + || + || + || + || + || V || 1 || + || a -= R + cf ||rowspan=5|Subtract with Carry
|-
| sbc a,J || 11i11101 1001110b || 2 || 8 (4,4) || + || + || + || + || + || V || 1 || + || a -= J + cf
|-
| sbc a,N || 11011110 nnnnnnnn || 2 || 7 (4,3) || + || + || + || + || + || V || 1 || + || a -= N + cf
|-
| sbc a,(hl) || 10011110 || 2 || 7 (4,3) || + || + || + || + || + || V || 1 || + || a -= (hl) + cf
|-
| sbc a,(I+D) || 11i11101 10011110 dddddddd || 5 || 19 (4,4,3,5,3) || + || + || + || + || + || V || 1 || + || a -= (I+D) + cf
|-
| and R || 10100rrr || 1 || 4 (4) || + || + || + || 1 || + || P || 0 || 0 || a := a AND R ||rowspan=5|Logical AND
|-
| and J || 11i11101 1010010b || 2 || 8 (4,4) || + || + || + || 1 || + || P || 0 || 0 || a := a AND J
|-
| and N || 11100110 nnnnnnnn || 2 || 7 (4,3) || + || + || + || 1 || + || P || 0 || 0 || a := a AND N
|-
| and (hl) || 10100110 || 2 || 7 (4,3) || + || + || + || 1 || + || P || 0 || 0 || a := a AND (hl)
|-
| and (I+D) || 11i11101 10100110 dddddddd || 5 || 19 (4,4,3,5,3) || + || + || + || 1 || + || P || 0 || 0 || a := a AND (I+D)
|-
| xor R || 10101rrr || 1 || 4 (4) || + || + || + || 0 || + || P || 0 || 0 || a := a XOR R ||rowspan=5|Logical eXclusive OR
|-
| xor J || 11i11101 1010110b || 2 || 8 (4,4) || + || + || + || 0 || + || P || 0 || 0 || a := a XOR J
|-
| xor N || 11101110 nnnnnnnn || 2 || 7 (4,3) || + || + || + || 0 || + || P || 0 || 0 || a := a XOR N
|-
| xor (hl) || 10101110 || 2 || 7 (4,3) || + || + || + || 0 || + || P || 0 || 0 || a := a XOR (hl)
|-
| xor (I+D) || 11i11101 10101110 dddddddd || 5 || 19 (4,4,3,5,3) || + || + || + || 0 || + || P || 0 || 0 || a := a XOR (I+D)
|-
| or R || 10110rrr || 1 || 4 (4) || + || + || + || 0 || + || P || 0 || 0 || a := a OR R ||rowspan=5|Logical Inclusive OR
|-
| or J || 11i11101 1011010b || 2 || 8 (4,4) || + || + || + || 0 || + || P || 0 || 0 || a := a OR J
|-
| or N || 11110110 nnnnnnnn || 2 || 7 (4,3) || + || + || + || 0 || + || P || 0 || 0 || a := a OR N
|-
| or (hl) || 10110110 || 2 || 7 (4,3) || + || + || + || 0 || + || P || 0 || 0 || a := a OR (hl)
|-
| or (I+D) || 11i11101 10110110 dddddddd || 5 || 19 (4,4,3,5,3) || + || + || + || 0 || + || P || 0 || 0 || a := a OR (I+D)
|-
| cp R || 10111rrr || 1 || 4 (4) || + || + || X || + || X || V || 1 || + || tmp := a - R, f5 := R.5, f3 := R.3 ||rowspan=5|Compare
|-
| cp J || 11i11101 1011110b || 2 || 8 (4,4) || + || + || X || + || X || V || 1 || + || tmp := a - J, f5 := J.5, f3 := J.3
|-
| cp N || 11111110 nnnnnnnn || 2 || 7 (4,3) || + || + || X || + || X || V || 1 || + || tmp := a - N, f5 := N.5, f3 := N.3
|-
| cp (hl) || 10111110 || 2 || 7 (4,3) || + || + || X || + || X || V || 1 || + || tmp := a - (hl), f5 := (hl).5, f3 := (hl).3
|-
| cp (I+D) || 11i11101 10111110 dddddddd || 5 || 19 (4,4,3,5,3) || + || + || X || + || X || V || 1 || + || tmp := a - (I+D), f5 := (I+D).5, f3 := (I+D).3
|}
=== Letter A ===
|-
| ccf || 00111111 || 1 || 4 (4) || - || - || A || X || A || - || 0 || X || hf := cf, cf := ~cf || Complement Carry Flag
|-
| cp R || 10111rrr || 1 || 4 (4) || + || + || X || + || X || V || 1 || + || tmp := a - R, f5 := R.5, f3 := R.3 ||rowspan=5|Compare
|-
| cp J || 11i11101 1011110b || 2 || 8 (4,4) || + || + || X || + || X || V || 1 || + || tmp := a - J, f5 := J.5, f3 := J.3
|-
| cp N || 11111110 nnnnnnnn || 2 || 7 (4,3) || + || + || X || + || X || V || 1 || + || tmp := a - N, f5 := N.5, f3 := N.3
|-
| cp (hl) || 10111110 || 2 || 7 (4,3) || + || + || X || + || X || V || 1 || + || tmp := a - (hl), f5 := (hl).5, f3 := (hl).3
|-
| cp (I+D) || 11i11101 10111110 dddddddd || 5 || 19 (4,4,3,5,3) || + || + || X || + || X || V || 1 || + || tmp := a - (I+D), f5 := (I+D).5, f3 := (I+D).3
|-
| cpd || 11101101 10101001 || 4 || 16 (4,4,3,5) || + || + || X || + || X || C || 1 || - || tmp := a - (hl) => flags, bc -= 1, hl -= 1,
|-
! Instruction !! Opcode !! NOPs !! Cycles !! S !! Z !! 5 !! H !! 3 !! P !! N !! C !! Effect !! Description
|-
| or R || 10110rrr || 1 || 4 (4) || + || + || + || 0 || + || P || 0 || 0 || a := a OR R ||rowspan=5|Logical Inclusive OR
|-
| or J || 11i11101 1011010b || 2 || 8 (4,4) || + || + || + || 0 || + || P || 0 || 0 || a := a OR J
|-
| or N || 11110110 nnnnnnnn || 2 || 7 (4,3) || + || + || + || 0 || + || P || 0 || 0 || a := a OR N
|-
| or (hl) || 10110110 || 2 || 7 (4,3) || + || + || + || 0 || + || P || 0 || 0 || a := a OR (hl)
|-
| or (I+D) || 11i11101 10110110 dddddddd || 5 || 19 (4,4,3,5,3) || + || + || + || 0 || + || P || 0 || 0 || a := a OR (I+D)
|-
| out (N),a || 11010011 nnnnnnnn || 3 || 11 (4,3,4) || - || - || - || - || - || - || - || - || ((N)) := a ||rowspan=3| I/O Output
{| class="wikitable" style="white-space: nowrap;"
! Instruction !! Opcode !! NOPs !! Cycles !! S !! Z !! 5 !! H !! 3 !! P !! N !! C !! Effect !! Description
|-
| sbc a,R || 10011rrr || 1 || 4 (4) || + || + || + || + || + || V || 1 || + || a -= R + cf ||rowspan=6|Subtract with Carry
|-
| sbc a,J || 11i11101 1001110b || 2 || 8 (4,4) || + || + || + || + || + || V || 1 || + || a -= J + cf
|-
| sbc a,N || 11011110 nnnnnnnn || 2 || 7 (4,3) || + || + || + || + || + || V || 1 || + || a -= N + cf
|-
| sbc a,(hl) || 10011110 || 2 || 7 (4,3) || + || + || + || + || + || V || 1 || + || a -= (hl) + cf
|-
| sbc a,(I+D) || 11i11101 10011110 dddddddd || 5 || 19 (4,4,3,5,3) || + || + || + || + || + || V || 1 || + || a -= (I+D) + cf
|-
| sbc hl,Q || 11101101 01qq0010 || 4 || 15 (4,4,4,3) || + || + || + || + || + || V || 1 || + || hl -= Q + cf
|-
| srl (I+D)->R || 11i11101 11001011 dddddddd 00111rrr || 7 || 23 (4,4,3,5,4,3) || 0 || + || + || 0 || + || P || 0 || X || cf := (I+D).0, (I+D) := R := (I+D) >> 1
|-
| sub R || 10010rrr || 1 || 4 (4) || + || + || + || + || + || V || 1 || + || a -= R ||rowspan=5|Subtract
|-
| sub J || 11i11101 1001010b || 2 || 8 (4,4) || + || + || + || + || + || V || 1 || + || a -= J
|-
| sub N || 11010110 nnnnnnnn || 2 || 7 (4,3) || + || + || + || + || + || V || 1 || + || a -= N
|-
| sub (hl) || 10010110 || 2 || 7 (4,3) || + || + || + || + || + || V || 1 || + || a -= (hl)
|-
| sub (I+D) || 11i11101 10010110 dddddddd || 5 || 19 (4,4,3,5,3) || + || + || + || + || + || V || 1 || + || a -= (I+D)
|}
 
=== Letter X ===
 
{| class="wikitable" style="white-space: nowrap;"
! Instruction !! Opcode !! NOPs !! Cycles !! S !! Z !! 5 !! H !! 3 !! P !! N !! C !! Effect !! Description
|-
| xor R || 10101rrr || 1 || 4 (4) || + || + || + || 0 || + || P || 0 || 0 || a := a XOR R ||rowspan=5|Logical eXclusive OR
|-
| xor J || 11i11101 1010110b || 2 || 8 (4,4) || + || + || + || 0 || + || P || 0 || 0 || a := a XOR J
|-
| xor N || 11101110 nnnnnnnn || 2 || 7 (4,3) || + || + || + || 0 || + || P || 0 || 0 || a := a XOR N
|-
| xor (hl) || 10101110 || 2 || 7 (4,3) || + || + || + || 0 || + || P || 0 || 0 || a := a XOR (hl)
|-
| xor (I+D) || 11i11101 10101110 dddddddd || 5 || 19 (4,4,3,5,3) || + || + || + || 0 || + || P || 0 || 0 || a := a XOR (I+D)
|}
13,173
edits