Browse Source

Implement SET/RES for IX/IY.

master
Ben Kurtovic 8 years ago
parent
commit
daac49e3d7
2 changed files with 48 additions and 18 deletions
  1. +32
    -2
      src/z80_ops.inc.c
  2. +16
    -16
      src/z80_tables.inc.c

+ 32
- 2
src/z80_ops.inc.c View File

@@ -1855,7 +1855,22 @@ static uint8_t z80_inst_set_b_hl(Z80 *z80, uint8_t opcode)
return 15;
}

// TODO: SET b, (IXY+d)
/*
SET b, (IXY+d) (0xDDCBC6, 0xDDCBCE, 0xDDCBD6, 0xDDCBDE, 0xDDCBE6, 0xDDCBEE,
0xDDCBF6, 0xDDCBFE, 0xFDCBC6, 0xFDCBCE, 0xFDCBD6, 0xFDCBDE, 0xFDCBE6,
0xFDCBEE, 0xFDCBF6, 0xFDCBFE):
Set bit b of (IX+d) or (IY+d).
*/
static uint8_t z80_inst_set_b_ixy(Z80 *z80, uint8_t opcode)
{
uint16_t addr = get_index_addr(z80, z80->regs.pc - 1);
uint8_t val = mmu_read_byte(z80->mmu, addr);
uint8_t bit = (opcode >> 3) & 0x07;
val |= 1 << bit;
mmu_write_byte(z80->mmu, addr, val);
z80->regs.pc++;
return 15;
}

/*
RES b, r (0xCB80, 0xCB81, 0xCB82, 0xCB83, 0xCB84, 0xCB85, 0xCB87, 0xCB88,
@@ -1891,7 +1906,22 @@ static uint8_t z80_inst_res_b_hl(Z80 *z80, uint8_t opcode)
return 15;
}

// TODO: RES b, (IXY+d)
/*
RES b, (IXY+d) (0xDDCB86, 0xDDCB8E, 0xDDCB96, 0xDDCB9E, 0xDDCBA6, 0xDDCBAE,
0xDDCBB6, 0xDDCBBE, 0xFDCB86, 0xFDCB8E, 0xFDCBA6, 0xFDCBAE, 0xFDCBB6,
0xFDCBBE, 0xFDCBC6, 0xFDCBCE):
Set bit b of (IX+d) or (IY+d).
*/
static uint8_t z80_inst_res_b_ixy(Z80 *z80, uint8_t opcode)
{
uint16_t addr = get_index_addr(z80, z80->regs.pc - 1);
uint8_t val = mmu_read_byte(z80->mmu, addr);
uint8_t bit = (opcode >> 3) & 0x07;
val &= ~(1 << bit);
mmu_write_byte(z80->mmu, addr, val);
z80->regs.pc++;
return 15;
}

/*
JP nn (0xC3):


+ 16
- 16
src/z80_tables.inc.c View File

@@ -1172,7 +1172,7 @@ static DispatchTable instruction_table_index_bits = {
[0x83] = z80_inst_unimplemented, // TODO
[0x84] = z80_inst_unimplemented, // TODO
[0x85] = z80_inst_unimplemented, // TODO
[0x86] = z80_inst_unimplemented, // TODO
[0x86] = z80_inst_res_b_ixy,
[0x87] = z80_inst_unimplemented, // TODO
[0x88] = z80_inst_unimplemented, // TODO
[0x89] = z80_inst_unimplemented, // TODO
@@ -1180,7 +1180,7 @@ static DispatchTable instruction_table_index_bits = {
[0x8B] = z80_inst_unimplemented, // TODO
[0x8C] = z80_inst_unimplemented, // TODO
[0x8D] = z80_inst_unimplemented, // TODO
[0x8E] = z80_inst_unimplemented, // TODO
[0x8E] = z80_inst_res_b_ixy,
[0x8F] = z80_inst_unimplemented, // TODO
[0x90] = z80_inst_unimplemented, // TODO
[0x91] = z80_inst_unimplemented, // TODO
@@ -1188,7 +1188,7 @@ static DispatchTable instruction_table_index_bits = {
[0x93] = z80_inst_unimplemented, // TODO
[0x94] = z80_inst_unimplemented, // TODO
[0x95] = z80_inst_unimplemented, // TODO
[0x96] = z80_inst_unimplemented, // TODO
[0x96] = z80_inst_res_b_ixy,
[0x97] = z80_inst_unimplemented, // TODO
[0x98] = z80_inst_unimplemented, // TODO
[0x99] = z80_inst_unimplemented, // TODO
@@ -1196,7 +1196,7 @@ static DispatchTable instruction_table_index_bits = {
[0x9B] = z80_inst_unimplemented, // TODO
[0x9C] = z80_inst_unimplemented, // TODO
[0x9D] = z80_inst_unimplemented, // TODO
[0x9E] = z80_inst_unimplemented, // TODO
[0x9E] = z80_inst_res_b_ixy,
[0x9F] = z80_inst_unimplemented, // TODO
[0xA0] = z80_inst_unimplemented, // TODO
[0xA1] = z80_inst_unimplemented, // TODO
@@ -1204,7 +1204,7 @@ static DispatchTable instruction_table_index_bits = {
[0xA3] = z80_inst_unimplemented, // TODO
[0xA4] = z80_inst_unimplemented, // TODO
[0xA5] = z80_inst_unimplemented, // TODO
[0xA6] = z80_inst_unimplemented, // TODO
[0xA6] = z80_inst_res_b_ixy,
[0xA7] = z80_inst_unimplemented, // TODO
[0xA8] = z80_inst_unimplemented, // TODO
[0xA9] = z80_inst_unimplemented, // TODO
@@ -1212,7 +1212,7 @@ static DispatchTable instruction_table_index_bits = {
[0xAB] = z80_inst_unimplemented, // TODO
[0xAC] = z80_inst_unimplemented, // TODO
[0xAD] = z80_inst_unimplemented, // TODO
[0xAE] = z80_inst_unimplemented, // TODO
[0xAE] = z80_inst_res_b_ixy,
[0xAF] = z80_inst_unimplemented, // TODO
[0xB0] = z80_inst_unimplemented, // TODO
[0xB1] = z80_inst_unimplemented, // TODO
@@ -1220,7 +1220,7 @@ static DispatchTable instruction_table_index_bits = {
[0xB3] = z80_inst_unimplemented, // TODO
[0xB4] = z80_inst_unimplemented, // TODO
[0xB5] = z80_inst_unimplemented, // TODO
[0xB6] = z80_inst_unimplemented, // TODO
[0xB6] = z80_inst_res_b_ixy,
[0xB7] = z80_inst_unimplemented, // TODO
[0xB8] = z80_inst_unimplemented, // TODO
[0xB9] = z80_inst_unimplemented, // TODO
@@ -1228,7 +1228,7 @@ static DispatchTable instruction_table_index_bits = {
[0xBB] = z80_inst_unimplemented, // TODO
[0xBC] = z80_inst_unimplemented, // TODO
[0xBD] = z80_inst_unimplemented, // TODO
[0xBE] = z80_inst_unimplemented, // TODO
[0xBE] = z80_inst_res_b_ixy,
[0xBF] = z80_inst_unimplemented, // TODO
[0xC0] = z80_inst_unimplemented, // TODO
[0xC1] = z80_inst_unimplemented, // TODO
@@ -1236,7 +1236,7 @@ static DispatchTable instruction_table_index_bits = {
[0xC3] = z80_inst_unimplemented, // TODO
[0xC4] = z80_inst_unimplemented, // TODO
[0xC5] = z80_inst_unimplemented, // TODO
[0xC6] = z80_inst_unimplemented, // TODO
[0xC6] = z80_inst_set_b_ixy,
[0xC7] = z80_inst_unimplemented, // TODO
[0xC8] = z80_inst_unimplemented, // TODO
[0xC9] = z80_inst_unimplemented, // TODO
@@ -1244,7 +1244,7 @@ static DispatchTable instruction_table_index_bits = {
[0xCB] = z80_inst_unimplemented, // TODO
[0xCC] = z80_inst_unimplemented, // TODO
[0xCD] = z80_inst_unimplemented, // TODO
[0xCE] = z80_inst_unimplemented, // TODO
[0xCE] = z80_inst_set_b_ixy,
[0xCF] = z80_inst_unimplemented, // TODO
[0xD0] = z80_inst_unimplemented, // TODO
[0xD1] = z80_inst_unimplemented, // TODO
@@ -1252,7 +1252,7 @@ static DispatchTable instruction_table_index_bits = {
[0xD3] = z80_inst_unimplemented, // TODO
[0xD4] = z80_inst_unimplemented, // TODO
[0xD5] = z80_inst_unimplemented, // TODO
[0xD6] = z80_inst_unimplemented, // TODO
[0xD6] = z80_inst_set_b_ixy,
[0xD7] = z80_inst_unimplemented, // TODO
[0xD8] = z80_inst_unimplemented, // TODO
[0xD9] = z80_inst_unimplemented, // TODO
@@ -1260,7 +1260,7 @@ static DispatchTable instruction_table_index_bits = {
[0xDB] = z80_inst_unimplemented, // TODO
[0xDC] = z80_inst_unimplemented, // TODO
[0xDD] = z80_inst_unimplemented, // TODO
[0xDE] = z80_inst_unimplemented, // TODO
[0xDE] = z80_inst_set_b_ixy,
[0xDF] = z80_inst_unimplemented, // TODO
[0xE0] = z80_inst_unimplemented, // TODO
[0xE1] = z80_inst_unimplemented, // TODO
@@ -1268,7 +1268,7 @@ static DispatchTable instruction_table_index_bits = {
[0xE3] = z80_inst_unimplemented, // TODO
[0xE4] = z80_inst_unimplemented, // TODO
[0xE5] = z80_inst_unimplemented, // TODO
[0xE6] = z80_inst_unimplemented, // TODO
[0xE6] = z80_inst_set_b_ixy,
[0xE7] = z80_inst_unimplemented, // TODO
[0xE8] = z80_inst_unimplemented, // TODO
[0xE9] = z80_inst_unimplemented, // TODO
@@ -1276,7 +1276,7 @@ static DispatchTable instruction_table_index_bits = {
[0xEB] = z80_inst_unimplemented, // TODO
[0xEC] = z80_inst_unimplemented, // TODO
[0xED] = z80_inst_unimplemented, // TODO
[0xEE] = z80_inst_unimplemented, // TODO
[0xEE] = z80_inst_set_b_ixy,
[0xEF] = z80_inst_unimplemented, // TODO
[0xF0] = z80_inst_unimplemented, // TODO
[0xF1] = z80_inst_unimplemented, // TODO
@@ -1284,7 +1284,7 @@ static DispatchTable instruction_table_index_bits = {
[0xF3] = z80_inst_unimplemented, // TODO
[0xF4] = z80_inst_unimplemented, // TODO
[0xF5] = z80_inst_unimplemented, // TODO
[0xF6] = z80_inst_unimplemented, // TODO
[0xF6] = z80_inst_set_b_ixy,
[0xF7] = z80_inst_unimplemented, // TODO
[0xF8] = z80_inst_unimplemented, // TODO
[0xF9] = z80_inst_unimplemented, // TODO
@@ -1292,6 +1292,6 @@ static DispatchTable instruction_table_index_bits = {
[0xFB] = z80_inst_unimplemented, // TODO
[0xFC] = z80_inst_unimplemented, // TODO
[0xFD] = z80_inst_unimplemented, // TODO
[0xFE] = z80_inst_unimplemented, // TODO
[0xFE] = z80_inst_set_b_ixy,
[0xFF] = z80_inst_unimplemented // TODO
};

Loading…
Cancel
Save