diff --git a/src/z80_flags.inc.c b/src/z80_flags.inc.c index ae9d8a7..202cfa6 100644 --- a/src/z80_flags.inc.c +++ b/src/z80_flags.inc.c @@ -147,12 +147,21 @@ static inline void set_flags_bitshift(Z80 *z80, uint8_t res, uint8_t bit) } /* + Set the flags for a CPL instruction. +*/ +static inline void set_flags_cpl(Z80 *z80) +{ + uint8_t res = z80->regs.a; + set_flags(z80, 0, 1, 0, F3(res), 1, F5(res), 0, 0, 0x3A); +} + +/* Set the flags for a NEG instruction. */ static inline void set_flags_neg(Z80 *z80) { - uint8_t val = z80->regs.a; - uint8_t res = -val; + uint8_t res = z80->regs.a; + uint8_t val = -res; set_flags(z80, CARRY(0, -, val), SUB, OV_SUB(0, val, res), F3(res), HALF(0, -, val), F5(res), ZERO(res), SIGN(res), 0xFF); } diff --git a/src/z80_ops.inc.c b/src/z80_ops.inc.c index e363247..a4762ad 100644 --- a/src/z80_ops.inc.c +++ b/src/z80_ops.inc.c @@ -546,7 +546,7 @@ static uint8_t z80_inst_lddr(Z80 *z80, uint8_t opcode) /* ADD A, r (0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x87): - TODO + Add r (8-bit register) to A. */ static uint8_t z80_inst_add_a_r(Z80 *z80, uint8_t opcode) { @@ -560,7 +560,7 @@ static uint8_t z80_inst_add_a_r(Z80 *z80, uint8_t opcode) /* ADD A, n (0xC6): - TODO + Add n (8-bit immediate) to A. */ static uint8_t z80_inst_add_a_n(Z80 *z80, uint8_t opcode) { @@ -575,7 +575,7 @@ static uint8_t z80_inst_add_a_n(Z80 *z80, uint8_t opcode) /* ADD A, (HL) (0x86): - TODO + Add (HL) to A. */ static uint8_t z80_inst_add_a_hl(Z80 *z80, uint8_t opcode) { @@ -590,7 +590,7 @@ static uint8_t z80_inst_add_a_hl(Z80 *z80, uint8_t opcode) /* ADD A, (IXY+d) (0xDD86, 0xFD86): - TODO + Add (IX+d) or (IY+d) to A. */ static uint8_t z80_inst_add_a_ixy(Z80 *z80, uint8_t opcode) { @@ -606,7 +606,7 @@ static uint8_t z80_inst_add_a_ixy(Z80 *z80, uint8_t opcode) /* ADC A, r (0x88, 0x89, 0x8A, 0x8B, 0x8C, 0x8D, 0x8F): - TODO + Add r (8-bit register) plus the carry flag to A. */ static uint8_t z80_inst_adc_a_r(Z80 *z80, uint8_t opcode) { @@ -621,7 +621,7 @@ static uint8_t z80_inst_adc_a_r(Z80 *z80, uint8_t opcode) /* ADC A, n (0xCE): - TODO + Add n (8-bit immediate) plus the carry flag to A. */ static uint8_t z80_inst_adc_a_n(Z80 *z80, uint8_t opcode) { @@ -637,7 +637,7 @@ static uint8_t z80_inst_adc_a_n(Z80 *z80, uint8_t opcode) /* ADC A, (HL) (0x8E): - TODO + Add (HL) plus the carry flag to A. */ static uint8_t z80_inst_adc_a_hl(Z80 *z80, uint8_t opcode) { @@ -653,7 +653,7 @@ static uint8_t z80_inst_adc_a_hl(Z80 *z80, uint8_t opcode) /* ADC A, (IXY+d) (0xDD8E, 0xFD8E): - TODO + Add (IX+d) or (IY+d) plus the carry flag to A. */ static uint8_t z80_inst_adc_a_ixy(Z80 *z80, uint8_t opcode) { @@ -669,8 +669,8 @@ static uint8_t z80_inst_adc_a_ixy(Z80 *z80, uint8_t opcode) } /* - SUB, r (0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x97): - TODO + SUB r (0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x97): + Subtract r (8-bit register) from A. */ static uint8_t z80_inst_sub_r(Z80 *z80, uint8_t opcode) { @@ -699,7 +699,7 @@ static uint8_t z80_inst_sub_n(Z80 *z80, uint8_t opcode) /* SUB (HL) - TODO + Subtract (HL) from A. */ static uint8_t z80_inst_sub_hl(Z80 *z80, uint8_t opcode) { @@ -714,7 +714,7 @@ static uint8_t z80_inst_sub_hl(Z80 *z80, uint8_t opcode) /* SUB (IXY+d) - TODO + Subtract (IX+d) or (IY+d) from A. */ static uint8_t z80_inst_sub_ixy(Z80 *z80, uint8_t opcode) { @@ -729,8 +729,8 @@ static uint8_t z80_inst_sub_ixy(Z80 *z80, uint8_t opcode) } /* - SBC A, r (...): - TODO + SBC A, r (0x98, 0x99, 0x9A, 0x9B, 0x9C, 0x9D, 0x9F): + Subtract r (8-bit register) plus the carry flag from A. */ static uint8_t z80_inst_sbc_a_r(Z80 *z80, uint8_t opcode) { @@ -744,8 +744,8 @@ static uint8_t z80_inst_sbc_a_r(Z80 *z80, uint8_t opcode) } /* - SBC A, n (...): - TODO + SBC A, n (0xDE): + Subtract n (8-bit immediate) plus the carry flag from A. */ static uint8_t z80_inst_sbc_a_n(Z80 *z80, uint8_t opcode) { @@ -760,8 +760,8 @@ static uint8_t z80_inst_sbc_a_n(Z80 *z80, uint8_t opcode) } /* - SBC A, (HL) - TODO + SBC A, (HL) (0x9E): + Subtract (HL) plus the carry flag from A. */ static uint8_t z80_inst_sbc_a_hl(Z80 *z80, uint8_t opcode) { @@ -776,8 +776,8 @@ static uint8_t z80_inst_sbc_a_hl(Z80 *z80, uint8_t opcode) } /* - SBC A, (IXY+d) - TODO + SBC A, (IXY+d) (0xDD9E, 0xFD9E): + Subtract (IX+d) or (IY+d) plus the carry flag from A. */ static uint8_t z80_inst_sbc_a_ixy(Z80 *z80, uint8_t opcode) { @@ -793,8 +793,8 @@ static uint8_t z80_inst_sbc_a_ixy(Z80 *z80, uint8_t opcode) } /* - AND r - TODO + AND r (0xA0, 0xA1, 0xA2, 0xA3, 0xA4, 0xA5, 0xA7): + Bitwise AND A with r (8-bit register). */ static uint8_t z80_inst_and_r(Z80 *z80, uint8_t opcode) { @@ -822,8 +822,8 @@ static uint8_t z80_inst_and_n(Z80 *z80, uint8_t opcode) } /* - AND (HL) - TODO + AND (HL) (0xA6): + Bitwise AND A with (HL). */ static uint8_t z80_inst_and_hl(Z80 *z80, uint8_t opcode) { @@ -837,8 +837,8 @@ static uint8_t z80_inst_and_hl(Z80 *z80, uint8_t opcode) } /* - AND (IXY+d) - TODO + AND (IXY+d) (0xDDA6, 0xFDA6): + Bitwise AND A with (IX+d) or (IY+d). */ static uint8_t z80_inst_and_ixy(Z80 *z80, uint8_t opcode) { @@ -882,8 +882,8 @@ static uint8_t z80_inst_or_n(Z80 *z80, uint8_t opcode) } /* - OR (HL) - TODO + OR (HL) (0xB6): + Bitwise OR A with (HL). */ static uint8_t z80_inst_or_hl(Z80 *z80, uint8_t opcode) { @@ -942,8 +942,8 @@ static uint8_t z80_inst_xor_n(Z80 *z80, uint8_t opcode) } /* - XOR (HL) - TODO + XOR (HL) (0xAE): + Bitwise XOR A with (HL). */ static uint8_t z80_inst_xor_hl(Z80 *z80, uint8_t opcode) { @@ -955,9 +955,10 @@ static uint8_t z80_inst_xor_hl(Z80 *z80, uint8_t opcode) z80->regs.pc++; return 7; } + /* - XOR (IXY+d) - TODO + XOR (IXY+d) (0xDDAE, 0xFDAE): + Bitwise XOR A with (IX+d) or (IY+d). */ static uint8_t z80_inst_xor_ixy(Z80 *z80, uint8_t opcode) { @@ -1000,7 +1001,7 @@ static uint8_t z80_inst_cp_n(Z80 *z80, uint8_t opcode) /* CP (HL) (0xBE): - Set flags as if the memory pointed to by HL had been subtracted from A. + Set flags as if (HL) had been subtracted from A. */ static uint8_t z80_inst_cp_hl(Z80 *z80, uint8_t opcode) { @@ -1013,8 +1014,8 @@ static uint8_t z80_inst_cp_hl(Z80 *z80, uint8_t opcode) } /* - CP (IXY+d) - TODO + CP (IXY+d) (0xDDBE, 0xFDBE): + Set flags as if (IX+d) or (IY+d) had been subtracted from A. */ static uint8_t z80_inst_cp_ixy(Z80 *z80, uint8_t opcode) { @@ -1057,8 +1058,8 @@ static uint8_t z80_inst_inc_hl(Z80 *z80, uint8_t opcode) } /* - INC (IXY+d) - TODO + INC (IXY+d) (0xDD34, 0xFD34): + Increment (IX+d) or (IY+d). */ static uint8_t z80_inst_inc_ixy(Z80 *z80, uint8_t opcode) { @@ -1102,8 +1103,8 @@ static uint8_t z80_inst_dec_hl(Z80 *z80, uint8_t opcode) } /* - DEC (IXY+d) - TODO + DEC (IXY+d) (0xDD35, 0xFD35): + Decrement (IX+d) or (IY+d). */ static uint8_t z80_inst_dec_ixy(Z80 *z80, uint8_t opcode) { @@ -1119,7 +1120,18 @@ static uint8_t z80_inst_dec_ixy(Z80 *z80, uint8_t opcode) // TODO: DAA -// TODO: CPL +/* + CPL (0x2F): + Invert A. +*/ +static uint8_t z80_inst_cpl(Z80 *z80, uint8_t opcode) +{ + (void) opcode; + z80->regs.a = ~z80->regs.a; + set_flags_cpl(z80); + z80->regs.pc++; + return 8; +} /* NEG (0xED44, 0xED4C, 0xED54, 0xED5C, 0xED64, 0xED6C, 0xED74, 0xED7C): @@ -1128,8 +1140,8 @@ static uint8_t z80_inst_dec_ixy(Z80 *z80, uint8_t opcode) static uint8_t z80_inst_neg(Z80 *z80, uint8_t opcode) { (void) opcode; - set_flags_neg(z80); z80->regs.a = -z80->regs.a; + set_flags_neg(z80); z80->regs.pc++; return 8; } @@ -1232,8 +1244,8 @@ static uint8_t z80_inst_add_hl_ss(Z80 *z80, uint8_t opcode) } /* - ADC HL, ss - TODO + ADC HL, ss (0xED4A, 0xED5A, 0xED6A, 0xED7A): + Add ss plus the carry flag to HL. */ static uint8_t z80_inst_adc_hl_ss(Z80 *z80, uint8_t opcode) { @@ -1262,8 +1274,9 @@ static uint8_t z80_inst_sbc_hl_ss(Z80 *z80, uint8_t opcode) } /* - ADD IXY, pp - TODO + ADD IXY, pp (0xDD09, 0xDD19, 0xDD29, 0xDD39, 0xFD09, 0xFD19, 0xFD29, + 0xFD39): + Add pp to IX or IY. */ static uint8_t z80_inst_add_ixy_ss(Z80 *z80, uint8_t opcode) { @@ -1287,8 +1300,8 @@ static uint8_t z80_inst_inc_ss(Z80 *z80, uint8_t opcode) } /* - INC IXY - TODO + INC IXY (0xDD23, 0xFD23): + Increment IX or IY. */ static uint8_t z80_inst_inc_xy(Z80 *z80, uint8_t opcode) { @@ -1310,8 +1323,8 @@ static uint8_t z80_inst_dec_ss(Z80 *z80, uint8_t opcode) } /* - DEC IXY - TODO + DEC IXY (0xDD2B, 0xFD2B): + Decrement IX or IY. */ static uint8_t z80_inst_dec_xy(Z80 *z80, uint8_t opcode) { @@ -1390,8 +1403,8 @@ static uint8_t z80_inst_rra(Z80 *z80, uint8_t opcode) } /* - RLC r - TODO + RLC r (0xCB00, 0xCB01, 0xCB02, 0xCB03, 0xCB04, 0xCB05, 0xCB07): + Rotate r left one bit. Bit 7 is copied to bit 0 and the carry flag. */ static uint8_t z80_inst_rlc_r(Z80 *z80, uint8_t opcode) { @@ -1406,8 +1419,8 @@ static uint8_t z80_inst_rlc_r(Z80 *z80, uint8_t opcode) } /* - RLC (HL) - TODO + RLC (HL) (0xCB06): + Rotate (HL) left one bit. Bit 7 is copied to bit 0 and the carry flag. */ static uint8_t z80_inst_rlc_hl(Z80 *z80, uint8_t opcode) { @@ -1429,8 +1442,9 @@ static uint8_t z80_inst_rlc_hl(Z80 *z80, uint8_t opcode) */ /* - RL r - TODO + RL r (0xCB10, 0xCB11, 0xCB12, 0xCB13, 0xCB14, 0xCB15, 0xCB17): + Rotate r left one bit. Carry flag is copied to bit 0, and bit 7 is copied + to the carry flag. */ static uint8_t z80_inst_rl_r(Z80 *z80, uint8_t opcode) { @@ -1446,8 +1460,9 @@ static uint8_t z80_inst_rl_r(Z80 *z80, uint8_t opcode) } /* - RL (HL) - TODO + RL (HL) (0xCB16): + Rotate (HL) left one bit. Carry flag is copied to bit 0, and bit 7 is + copied to the carry flag. */ static uint8_t z80_inst_rl_hl(Z80 *z80, uint8_t opcode) { @@ -1470,8 +1485,8 @@ static uint8_t z80_inst_rl_hl(Z80 *z80, uint8_t opcode) */ /* - RRC r - TODO + RRC r (0xCB08, 0xCB09, 0xCB0A, 0xCB0B, 0xCB0C, 0xCB0D, 0xCB0F): + Rotate r right one bit. Bit 0 is copied to bit 7 and the carry flag. */ static uint8_t z80_inst_rrc_r(Z80 *z80, uint8_t opcode) { @@ -1486,8 +1501,8 @@ static uint8_t z80_inst_rrc_r(Z80 *z80, uint8_t opcode) } /* - RRC (HL) - TODO + RRC (HL) (0xCB0E): + Rotate (HL) right one bit. Bit 0 is copied to bit 7 and the carry flag. */ static uint8_t z80_inst_rrc_hl(Z80 *z80, uint8_t opcode) { @@ -1509,8 +1524,9 @@ static uint8_t z80_inst_rrc_hl(Z80 *z80, uint8_t opcode) */ /* - RR r - TODO + RR r (0xCB18, 0xCB19, 0xCB1A, 0xCB1B, 0xCB1C, 0xCB1D, 0xCB1F): + Rotate r right one bit. Carry flag is copied to bit 7, and bit 0 is copied + to the carry flag. */ static uint8_t z80_inst_rr_r(Z80 *z80, uint8_t opcode) { @@ -1526,8 +1542,9 @@ static uint8_t z80_inst_rr_r(Z80 *z80, uint8_t opcode) } /* - RR (HL) - TODO + RR (HL) (0xCB1E): + Rotate (HL) right one bit. Carry flag is copied to bit 7, and bit 0 is + copied to the carry flag. */ static uint8_t z80_inst_rr_hl(Z80 *z80, uint8_t opcode) { @@ -1550,8 +1567,9 @@ static uint8_t z80_inst_rr_hl(Z80 *z80, uint8_t opcode) */ /* - SLA r - TODO + SLA r (0xCB20, 0xCB21, 0xCB22, 0xCB23, 0xCB24, 0xCB25, 0xCB27): + Shift r left one bit. 0 is copied to bit 0, and bit 7 is copied to the + carry flag. */ static uint8_t z80_inst_sla_r(Z80 *z80, uint8_t opcode) { @@ -1565,8 +1583,9 @@ static uint8_t z80_inst_sla_r(Z80 *z80, uint8_t opcode) } /* - SLA (HL) - TODO + SLA (HL) (0xCB26): + Shift (HL) left one bit. 0 is copied to bit 0, and bit 7 is copied to the + carry flag. */ static uint8_t z80_inst_sla_hl(Z80 *z80, uint8_t opcode) { @@ -1587,8 +1606,9 @@ static uint8_t z80_inst_sla_hl(Z80 *z80, uint8_t opcode) */ /* - SRA r - TODO + SRA r (0xCB28, 0xCB29, 0xCB2A, 0xCB2B, 0xCB2C, 0xCB2D, 0xCB2F): + Arithmetic shift r right one bit. The previous bit 7 is copied to the new + bit 7, and bit 0 is copied to the carry flag. */ static uint8_t z80_inst_sra_r(Z80 *z80, uint8_t opcode) { @@ -1603,8 +1623,9 @@ static uint8_t z80_inst_sra_r(Z80 *z80, uint8_t opcode) } /* - SRA (HL) - TODO + SRA (HL) (0xCB2E): + Arithmetic shift (HL) right one bit. The previous bit 7 is copied to the + new bit 7, and bit 0 is copied to the carry flag. */ static uint8_t z80_inst_sra_hl(Z80 *z80, uint8_t opcode) { @@ -1626,8 +1647,9 @@ static uint8_t z80_inst_sra_hl(Z80 *z80, uint8_t opcode) */ /* - SL1 r - TODO + SL1 r (0xCB30, 0xCB31, 0xCB32, 0xCB33, 0xCB34, 0xCB35, 0xCB37): + Shift r left one bit. 1 is copied to bit 0, and bit 7 is copied to the + carry flag. */ static uint8_t z80_inst_sl1_r(Z80 *z80, uint8_t opcode) { @@ -1642,8 +1664,9 @@ static uint8_t z80_inst_sl1_r(Z80 *z80, uint8_t opcode) } /* - SL1 (HL) - TODO + SL1 (HL) (0xCB36): + Shift (HL) left one bit. 1 is copied to bit 0, and bit 7 is copied to the + carry flag. */ static uint8_t z80_inst_sl1_hl(Z80 *z80, uint8_t opcode) { @@ -1665,8 +1688,9 @@ static uint8_t z80_inst_sl1_hl(Z80 *z80, uint8_t opcode) */ /* - SRL r - TODO + SRL r (0xCB38, 0xCB39, 0xCB3A, 0xCB3B, 0xCB3C, 0xCB3D, 0xCB3F): + Logical shift r right one bit. 0 is copied to bit 7, and bit 0 is copied to + the carry flag. */ static uint8_t z80_inst_srl_r(Z80 *z80, uint8_t opcode) { @@ -1680,8 +1704,9 @@ static uint8_t z80_inst_srl_r(Z80 *z80, uint8_t opcode) } /* - SRL (HL) - TODO + SRL (HL) (0xCB3E): + Logical shift (HL) right one bit. 0 is copied to bit 7, and bit 0 is copied + to the carry flag. */ static uint8_t z80_inst_srl_hl(Z80 *z80, uint8_t opcode) { @@ -1755,13 +1780,60 @@ static uint8_t z80_inst_bit_b_ixy(Z80 *z80, uint8_t opcode) return 20; } -// TODO: SET b, r +/* + SET b, r (0xCBC0, 0xCBC1, 0xCBC2, 0xCBC3, 0xCBC4, 0xCBC5, 0xCBC7, 0xCBC8, + 0xCBC9, 0xCBCA, 0xCBCB, 0xCBCC, 0xCBCD, 0xCBCF, 0xCBD0, 0xCBD1, 0xCBD2, + 0xCBD3, 0xCBD4, 0xCBD5, 0xCBD7, 0xCBD8, 0xCBD9, 0xCBDA, 0xCBDB, 0xCBDC, + 0xCBDD, 0xCBDF, 0xCBE0, 0xCBE1, 0xCBE2, 0xCBE3, 0xCBE4, 0xCBE5, 0xCBE7, + 0xCBE8, 0xCBE9, 0xCBEA, 0xCBEB, 0xCBEC, 0xCBED, 0xCBEF, 0xCBF0, 0xCBF1, + 0xCBF2, 0xCBF3, 0xCBF4, 0xCBF5, 0xCBF7, 0xCBF8, 0xCBF9, 0xCBFA, 0xCBFB, + 0xCBFC, 0xCBFD, 0xCBFF): + Set bit b of r. +*/ +static uint8_t z80_inst_set_b_r(Z80 *z80, uint8_t opcode) +{ + uint8_t *reg = extract_reg(z80, opcode << 3); + uint8_t bit = (opcode >> 3) & 0x07; + *reg |= 1 << bit; + z80->regs.pc++; + return 8; +} -// TODO: SET b, (HL) +/* + SET b, (HL) (0xCBC6, 0xCBCE, 0xCBD6, 0xCBDE, 0xCBE6, 0xCBEE, 0xCBF6, + 0xCBFE): + Reset bit b of (HL). +*/ +static uint8_t z80_inst_set_b_hl(Z80 *z80, uint8_t opcode) +{ + uint8_t val = mmu_read_byte(z80->mmu, z80->regs.hl); + uint8_t bit = (opcode >> 3) & 0x07; + val |= 1 << bit; + mmu_write_byte(z80->mmu, z80->regs.hl, val); + z80->regs.pc++; + return 15; +} // TODO: SET b, (IXY+d) -// TODO: RES b, r +/* + RES b, r (0xCB80, 0xCB81, 0xCB82, 0xCB83, 0xCB84, 0xCB85, 0xCB87, 0xCB88, + 0xCB89, 0xCB8A, 0xCB8B, 0xCB8C, 0xCB8D, 0xCB8F, 0xCB90, 0xCB91, 0xCB92, + 0xCB93, 0xCB94, 0xCB95, 0xCB97, 0xCB98, 0xCB99, 0xCB9A, 0xCB9B, 0xCB9C, + 0xCB9D, 0xCB9F, 0xCBA0, 0xCBA1, 0xCBA2, 0xCBA3, 0xCBA4, 0xCBA5, 0xCBA7, + 0xCBA8, 0xCBA9, 0xCBAA, 0xCBAB, 0xCBAC, 0xCBAD, 0xCBAF, 0xCBB0, 0xCBB1, + 0xCBB2, 0xCBB3, 0xCBB4, 0xCBB5, 0xCBB7, 0xCBB8, 0xCBB9, 0xCBBA, 0xCBBB, + 0xCBBC, 0xCBBD, 0xCBBF): + Reset bit b of r. +*/ +static uint8_t z80_inst_res_b_r(Z80 *z80, uint8_t opcode) +{ + uint8_t *reg = extract_reg(z80, opcode << 3); + uint8_t bit = (opcode >> 3) & 0x07; + *reg &= ~(1 << bit); + z80->regs.pc++; + return 8; +} /* RES b, (HL) (0xCB86, 0xCB8E, 0xCB96, 0xCB9E, 0xCBA6, 0xCBAE, 0xCBB6, diff --git a/src/z80_tables.inc.c b/src/z80_tables.inc.c index f94cf72..e0d6135 100644 --- a/src/z80_tables.inc.c +++ b/src/z80_tables.inc.c @@ -49,7 +49,7 @@ static DispatchTable instruction_table = { [0x2C] = z80_inst_inc_r, [0x2D] = z80_inst_dec_r, [0x2E] = z80_inst_ld_r_n, - [0x2F] = z80_inst_unimplemented, // TODO + [0x2F] = z80_inst_cpl, [0x30] = z80_inst_jr_cc_e, [0x31] = z80_inst_ld_dd_nn, [0x32] = z80_inst_ld_nn_a, @@ -648,134 +648,134 @@ static DispatchTable instruction_table_bits = { [0x7D] = z80_inst_bit_b_r, [0x7E] = z80_inst_bit_b_hl, [0x7F] = z80_inst_bit_b_r, - [0x80] = z80_inst_unimplemented, // TODO - [0x81] = z80_inst_unimplemented, // TODO - [0x82] = z80_inst_unimplemented, // TODO - [0x83] = z80_inst_unimplemented, // TODO - [0x84] = z80_inst_unimplemented, // TODO - [0x85] = z80_inst_unimplemented, // TODO + [0x80] = z80_inst_res_b_r, + [0x81] = z80_inst_res_b_r, + [0x82] = z80_inst_res_b_r, + [0x83] = z80_inst_res_b_r, + [0x84] = z80_inst_res_b_r, + [0x85] = z80_inst_res_b_r, [0x86] = z80_inst_res_b_hl, - [0x87] = z80_inst_unimplemented, // TODO - [0x88] = z80_inst_unimplemented, // TODO - [0x89] = z80_inst_unimplemented, // TODO - [0x8A] = z80_inst_unimplemented, // TODO - [0x8B] = z80_inst_unimplemented, // TODO - [0x8C] = z80_inst_unimplemented, // TODO - [0x8D] = z80_inst_unimplemented, // TODO + [0x87] = z80_inst_res_b_r, + [0x88] = z80_inst_res_b_r, + [0x89] = z80_inst_res_b_r, + [0x8A] = z80_inst_res_b_r, + [0x8B] = z80_inst_res_b_r, + [0x8C] = z80_inst_res_b_r, + [0x8D] = z80_inst_res_b_r, [0x8E] = z80_inst_res_b_hl, - [0x8F] = z80_inst_unimplemented, // TODO - [0x90] = z80_inst_unimplemented, // TODO - [0x91] = z80_inst_unimplemented, // TODO - [0x92] = z80_inst_unimplemented, // TODO - [0x93] = z80_inst_unimplemented, // TODO - [0x94] = z80_inst_unimplemented, // TODO - [0x95] = z80_inst_unimplemented, // TODO + [0x8F] = z80_inst_res_b_r, + [0x90] = z80_inst_res_b_r, + [0x91] = z80_inst_res_b_r, + [0x92] = z80_inst_res_b_r, + [0x93] = z80_inst_res_b_r, + [0x94] = z80_inst_res_b_r, + [0x95] = z80_inst_res_b_r, [0x96] = z80_inst_res_b_hl, - [0x97] = z80_inst_unimplemented, // TODO - [0x98] = z80_inst_unimplemented, // TODO - [0x99] = z80_inst_unimplemented, // TODO - [0x9A] = z80_inst_unimplemented, // TODO - [0x9B] = z80_inst_unimplemented, // TODO - [0x9C] = z80_inst_unimplemented, // TODO - [0x9D] = z80_inst_unimplemented, // TODO + [0x97] = z80_inst_res_b_r, + [0x98] = z80_inst_res_b_r, + [0x99] = z80_inst_res_b_r, + [0x9A] = z80_inst_res_b_r, + [0x9B] = z80_inst_res_b_r, + [0x9C] = z80_inst_res_b_r, + [0x9D] = z80_inst_res_b_r, [0x9E] = z80_inst_res_b_hl, - [0x9F] = z80_inst_unimplemented, // TODO - [0xA0] = z80_inst_unimplemented, // TODO - [0xA1] = z80_inst_unimplemented, // TODO - [0xA2] = z80_inst_unimplemented, // TODO - [0xA3] = z80_inst_unimplemented, // TODO - [0xA4] = z80_inst_unimplemented, // TODO - [0xA5] = z80_inst_unimplemented, // TODO + [0x9F] = z80_inst_res_b_r, + [0xA0] = z80_inst_res_b_r, + [0xA1] = z80_inst_res_b_r, + [0xA2] = z80_inst_res_b_r, + [0xA3] = z80_inst_res_b_r, + [0xA4] = z80_inst_res_b_r, + [0xA5] = z80_inst_res_b_r, [0xA6] = z80_inst_res_b_hl, - [0xA7] = z80_inst_unimplemented, // TODO - [0xA8] = z80_inst_unimplemented, // TODO - [0xA9] = z80_inst_unimplemented, // TODO - [0xAA] = z80_inst_unimplemented, // TODO - [0xAB] = z80_inst_unimplemented, // TODO - [0xAC] = z80_inst_unimplemented, // TODO - [0xAD] = z80_inst_unimplemented, // TODO + [0xA7] = z80_inst_res_b_r, + [0xA8] = z80_inst_res_b_r, + [0xA9] = z80_inst_res_b_r, + [0xAA] = z80_inst_res_b_r, + [0xAB] = z80_inst_res_b_r, + [0xAC] = z80_inst_res_b_r, + [0xAD] = z80_inst_res_b_r, [0xAE] = z80_inst_res_b_hl, - [0xAF] = z80_inst_unimplemented, // TODO - [0xB0] = z80_inst_unimplemented, // TODO - [0xB1] = z80_inst_unimplemented, // TODO - [0xB2] = z80_inst_unimplemented, // TODO - [0xB3] = z80_inst_unimplemented, // TODO - [0xB4] = z80_inst_unimplemented, // TODO - [0xB5] = z80_inst_unimplemented, // TODO + [0xAF] = z80_inst_res_b_r, + [0xB0] = z80_inst_res_b_r, + [0xB1] = z80_inst_res_b_r, + [0xB2] = z80_inst_res_b_r, + [0xB3] = z80_inst_res_b_r, + [0xB4] = z80_inst_res_b_r, + [0xB5] = z80_inst_res_b_r, [0xB6] = z80_inst_res_b_hl, - [0xB7] = z80_inst_unimplemented, // TODO - [0xB8] = z80_inst_unimplemented, // TODO - [0xB9] = z80_inst_unimplemented, // TODO - [0xBA] = z80_inst_unimplemented, // TODO - [0xBB] = z80_inst_unimplemented, // TODO - [0xBC] = z80_inst_unimplemented, // TODO - [0xBD] = z80_inst_unimplemented, // TODO + [0xB7] = z80_inst_res_b_r, + [0xB8] = z80_inst_res_b_r, + [0xB9] = z80_inst_res_b_r, + [0xBA] = z80_inst_res_b_r, + [0xBB] = z80_inst_res_b_r, + [0xBC] = z80_inst_res_b_r, + [0xBD] = z80_inst_res_b_r, [0xBE] = z80_inst_res_b_hl, - [0xBF] = z80_inst_unimplemented, // TODO - [0xC0] = z80_inst_unimplemented, // TODO - [0xC1] = z80_inst_unimplemented, // TODO - [0xC2] = z80_inst_unimplemented, // TODO - [0xC3] = z80_inst_unimplemented, // TODO - [0xC4] = z80_inst_unimplemented, // TODO - [0xC5] = z80_inst_unimplemented, // TODO - [0xC6] = z80_inst_unimplemented, // TODO - [0xC7] = z80_inst_unimplemented, // TODO - [0xC8] = z80_inst_unimplemented, // TODO - [0xC9] = z80_inst_unimplemented, // TODO - [0xCA] = z80_inst_unimplemented, // TODO - [0xCB] = z80_inst_unimplemented, // TODO - [0xCC] = z80_inst_unimplemented, // TODO - [0xCD] = z80_inst_unimplemented, // TODO - [0xCE] = z80_inst_unimplemented, // TODO - [0xCF] = z80_inst_unimplemented, // TODO - [0xD0] = z80_inst_unimplemented, // TODO - [0xD1] = z80_inst_unimplemented, // TODO - [0xD2] = z80_inst_unimplemented, // TODO - [0xD3] = z80_inst_unimplemented, // TODO - [0xD4] = z80_inst_unimplemented, // TODO - [0xD5] = z80_inst_unimplemented, // TODO - [0xD6] = z80_inst_unimplemented, // TODO - [0xD7] = z80_inst_unimplemented, // TODO - [0xD8] = z80_inst_unimplemented, // TODO - [0xD9] = z80_inst_unimplemented, // TODO - [0xDA] = z80_inst_unimplemented, // TODO - [0xDB] = z80_inst_unimplemented, // TODO - [0xDC] = z80_inst_unimplemented, // TODO - [0xDD] = z80_inst_unimplemented, // TODO - [0xDE] = z80_inst_unimplemented, // TODO - [0xDF] = z80_inst_unimplemented, // TODO - [0xE0] = z80_inst_unimplemented, // TODO - [0xE1] = z80_inst_unimplemented, // TODO - [0xE2] = z80_inst_unimplemented, // TODO - [0xE3] = z80_inst_unimplemented, // TODO - [0xE4] = z80_inst_unimplemented, // TODO - [0xE5] = z80_inst_unimplemented, // TODO - [0xE6] = z80_inst_unimplemented, // TODO - [0xE7] = z80_inst_unimplemented, // TODO - [0xE8] = z80_inst_unimplemented, // TODO - [0xE9] = z80_inst_unimplemented, // TODO - [0xEA] = z80_inst_unimplemented, // TODO - [0xEB] = z80_inst_unimplemented, // TODO - [0xEC] = z80_inst_unimplemented, // TODO - [0xED] = z80_inst_unimplemented, // TODO - [0xEE] = z80_inst_unimplemented, // TODO - [0xEF] = z80_inst_unimplemented, // TODO - [0xF0] = z80_inst_unimplemented, // TODO - [0xF1] = z80_inst_unimplemented, // TODO - [0xF2] = z80_inst_unimplemented, // TODO - [0xF3] = z80_inst_unimplemented, // TODO - [0xF4] = z80_inst_unimplemented, // TODO - [0xF5] = z80_inst_unimplemented, // TODO - [0xF6] = z80_inst_unimplemented, // TODO - [0xF7] = z80_inst_unimplemented, // TODO - [0xF8] = z80_inst_unimplemented, // TODO - [0xF9] = z80_inst_unimplemented, // TODO - [0xFA] = z80_inst_unimplemented, // TODO - [0xFB] = z80_inst_unimplemented, // TODO - [0xFC] = z80_inst_unimplemented, // TODO - [0xFD] = z80_inst_unimplemented, // TODO - [0xFE] = z80_inst_unimplemented, // TODO - [0xFF] = z80_inst_unimplemented // TODO + [0xBF] = z80_inst_res_b_r, + [0xC0] = z80_inst_set_b_r, + [0xC1] = z80_inst_set_b_r, + [0xC2] = z80_inst_set_b_r, + [0xC3] = z80_inst_set_b_r, + [0xC4] = z80_inst_set_b_r, + [0xC5] = z80_inst_set_b_r, + [0xC6] = z80_inst_set_b_hl, + [0xC7] = z80_inst_set_b_r, + [0xC8] = z80_inst_set_b_r, + [0xC9] = z80_inst_set_b_r, + [0xCA] = z80_inst_set_b_r, + [0xCB] = z80_inst_set_b_r, + [0xCC] = z80_inst_set_b_r, + [0xCD] = z80_inst_set_b_r, + [0xCE] = z80_inst_set_b_hl, + [0xCF] = z80_inst_set_b_r, + [0xD0] = z80_inst_set_b_r, + [0xD1] = z80_inst_set_b_r, + [0xD2] = z80_inst_set_b_r, + [0xD3] = z80_inst_set_b_r, + [0xD4] = z80_inst_set_b_r, + [0xD5] = z80_inst_set_b_r, + [0xD6] = z80_inst_set_b_hl, + [0xD7] = z80_inst_set_b_r, + [0xD8] = z80_inst_set_b_r, + [0xD9] = z80_inst_set_b_r, + [0xDA] = z80_inst_set_b_r, + [0xDB] = z80_inst_set_b_r, + [0xDC] = z80_inst_set_b_r, + [0xDD] = z80_inst_set_b_r, + [0xDE] = z80_inst_set_b_hl, + [0xDF] = z80_inst_set_b_r, + [0xE0] = z80_inst_set_b_r, + [0xE1] = z80_inst_set_b_r, + [0xE2] = z80_inst_set_b_r, + [0xE3] = z80_inst_set_b_r, + [0xE4] = z80_inst_set_b_r, + [0xE5] = z80_inst_set_b_r, + [0xE6] = z80_inst_set_b_hl, + [0xE7] = z80_inst_set_b_r, + [0xE8] = z80_inst_set_b_r, + [0xE9] = z80_inst_set_b_r, + [0xEA] = z80_inst_set_b_r, + [0xEB] = z80_inst_set_b_r, + [0xEC] = z80_inst_set_b_r, + [0xED] = z80_inst_set_b_r, + [0xEE] = z80_inst_set_b_hl, + [0xEF] = z80_inst_set_b_r, + [0xF0] = z80_inst_set_b_r, + [0xF1] = z80_inst_set_b_r, + [0xF2] = z80_inst_set_b_r, + [0xF3] = z80_inst_set_b_r, + [0xF4] = z80_inst_set_b_r, + [0xF5] = z80_inst_set_b_r, + [0xF6] = z80_inst_set_b_hl, + [0xF7] = z80_inst_set_b_r, + [0xF8] = z80_inst_set_b_r, + [0xF9] = z80_inst_set_b_r, + [0xFA] = z80_inst_set_b_r, + [0xFB] = z80_inst_set_b_r, + [0xFC] = z80_inst_set_b_r, + [0xFD] = z80_inst_set_b_r, + [0xFE] = z80_inst_set_b_hl, + [0xFF] = z80_inst_set_b_r }; static DispatchTable instruction_table_index = {