From 6b55fa3d2e22f776c4e68dc66689ceeb3a643c61 Mon Sep 17 00:00:00 2001 From: Cacodemon345 Date: Mon, 5 Sep 2022 01:25:08 +0600 Subject: [PATCH] NEC NOT1 instruction (#5) Fix bit value usage of TEST1 instruction --- src/cpu/808x.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/cpu/808x.c b/src/cpu/808x.c index 311c927dc..56afeb391 100644 --- a/src/cpu/808x.c +++ b/src/cpu/808x.c @@ -1757,13 +1757,31 @@ execx86(int cycs) do_mod_rm(); wait(3, 0); { - uint8_t bit = (opcode & 0x8) ? (pfq_fetchb() & 0x7) : (CL & 0xF); + uint8_t bit = (opcode & 0x8) ? (pfq_fetchb()) : (CL); + bit &= ((1 << bits) - 1); read_ea(0, bits); set_zf_ex(!(cpu_data & (1 << bit))); cpu_state.flags &= ~(V_FLAG | C_FLAG); } } + case 0x16: /* NOT1 r8/m8, CL*/ + case 0x17: /* NOT1 r16/m16, CL*/ + case 0x1e: /* NOT1 r8/m8, imm3 */ + case 0x1f: /* NOT1 r16/m16, imm4 */ + { + bits = 8 << (opcode & 0x1); + do_mod_rm(); + wait(3, 0); + { + uint8_t bit = (opcode & 0x8) ? (pfq_fetchb()) : (CL); + bit &= ((1 << bits) - 1); + read_ea(0, bits); + + if (bits == 8) seteab((cpu_data & 0xFF) ^ (1 << bit)); + else seteaw((cpu_data & 0xFFFF) ^ (1 << bit)); + } + } default: { opcode = orig_opcode; break;