void BX_CPP_AttrRegparmN(1) BX_CPU_C::CMPXCHG_EwGwM(bxInstruction_c *i) { #if BX_CPU_LEVEL >= 4 Bit16u op1_16, op2_16, diff_16; BX_CPU_CALL_METHODR(i->ResolveModrm, (i)); op1_16 = read_RMW_virtual_word(i->seg(), RMAddr(i)); diff_16 = AX - op1_16; SET_FLAGS_OSZAPC_SUB_16(AX, op1_16, diff_16); if (diff_16 == 0) { // if accumulator == dest // dest <-- src op2_16 = BX_READ_16BIT_REG(i->nnn()); write_RMW_virtual_word(op2_16); } else { // accumulator <-- dest AX = op1_16; } #else BX_INFO(("CMPXCHG_EwGw: not supported for cpu-level <= 3")); UndefinedOpcode(i); #endif }
void BX_CPP_AttrRegparmN(1) BX_CPU_C::XADD_EwGwM(bxInstruction_c *i) { #if BX_CPU_LEVEL >= 4 Bit16u op1_16, op2_16, sum_16; /* XADD dst(r/m), src(r) * temp <-- src + dst | sum = op2 + op1 * src <-- dst | op2 = op1 * dst <-- tmp | op1 = sum */ BX_CPU_CALL_METHODR(i->ResolveModrm, (i)); op1_16 = read_RMW_virtual_word(i->seg(), RMAddr(i)); op2_16 = BX_READ_16BIT_REG(i->nnn()); sum_16 = op1_16 + op2_16; write_RMW_virtual_word(sum_16); /* and write destination into source */ BX_WRITE_16BIT_REG(i->nnn(), op1_16); SET_FLAGS_OSZAPC_ADD_16(op1_16, op2_16, sum_16); #else BX_INFO(("XADD_EwGw: not supported on < 80486")); UndefinedOpcode(i); #endif }
void BX_CPP_AttrRegparmN(1) BX_CPU_C::XCHG_EwGwM(bxInstruction_c *i) { Bit16u op1_16, op2_16; BX_CPU_CALL_METHODR(i->ResolveModrm, (i)); op1_16 = read_RMW_virtual_word(i->seg(), RMAddr(i)); op2_16 = BX_READ_16BIT_REG(i->nnn()); write_RMW_virtual_word(op2_16); BX_WRITE_16BIT_REG(i->nnn(), op1_16); }
BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::DEC_EwM(bxInstruction_c *i) { bx_address eaddr = BX_CPU_CALL_METHODR(i->ResolveModrm, (i)); Bit32u op1_16 = read_RMW_virtual_word(i->seg(), eaddr); op1_16--; write_RMW_virtual_word(op1_16); SET_FLAGS_OSZAP_SUB_16(op1_16 + 1, 0, op1_16); BX_NEXT_INSTR(i); }
void BX_CPP_AttrRegparmN(1) BX_CPU_C::DEC_EwM(bxInstruction_c *i) { Bit16u op1_16; BX_CPU_CALL_METHODR(i->ResolveModrm, (i)); op1_16 = read_RMW_virtual_word(i->seg(), RMAddr(i)); op1_16--; write_RMW_virtual_word(op1_16); SET_FLAGS_OSZAPC_DEC_16(op1_16); }
void BX_CPP_AttrRegparmN(1) BX_CPU_C::NEG_EwM(bxInstruction_c *i) { Bit16u op1_16; BX_CPU_CALL_METHODR(i->ResolveModrm, (i)); op1_16 = read_RMW_virtual_word(i->seg(), RMAddr(i)); op1_16 = - (Bit16s)(op1_16); write_RMW_virtual_word(op1_16); SET_FLAGS_OSZAPC_RESULT_16(op1_16, BX_LF_INSTR_NEG16); }
void BX_CPP_AttrRegparmN(1) BX_CPU_C::SUB_EwIwM(bxInstruction_c *i) { Bit16u op1_16, op2_16 = i->Iw(), diff_16; BX_CPU_CALL_METHODR(i->ResolveModrm, (i)); op1_16 = read_RMW_virtual_word(i->seg(), RMAddr(i)); diff_16 = op1_16 - op2_16; write_RMW_virtual_word(diff_16); SET_FLAGS_OSZAPC_SUB_16(op1_16, op2_16, diff_16); }
void BX_CPP_AttrRegparmN(1) BX_CPU_C::ADC_EwIwM(bxInstruction_c *i) { bx_bool temp_CF = getB_CF(); Bit16u op1_16, op2_16 = i->Iw(), sum_16; BX_CPU_CALL_METHODR(i->ResolveModrm, (i)); op1_16 = read_RMW_virtual_word(i->seg(), RMAddr(i)); sum_16 = op1_16 + op2_16 + temp_CF; write_RMW_virtual_word(sum_16); SET_FLAGS_OSZAPC_16(op1_16, op2_16, sum_16, BX_LF_INSTR_ADD_ADC16(temp_CF)); }
void BX_CPP_AttrRegparmN(1) BX_CPU_C::ADD_EwGwM(bxInstruction_c *i) { Bit16u op1_16, op2_16, sum_16; BX_CPU_CALL_METHODR(i->ResolveModrm, (i)); op1_16 = read_RMW_virtual_word(i->seg(), RMAddr(i)); op2_16 = BX_READ_16BIT_REG(i->nnn()); sum_16 = op1_16 + op2_16; write_RMW_virtual_word(sum_16); SET_FLAGS_OSZAPC_ADD_16(op1_16, op2_16, sum_16); }
BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::ADC_EwGwM(bxInstruction_c *i) { bx_address eaddr = BX_CPU_CALL_METHODR(i->ResolveModrm, (i)); Bit32u op1_16 = read_RMW_virtual_word(i->seg(), eaddr); Bit32u op2_16 = BX_READ_16BIT_REG(i->nnn()); Bit32u sum_16 = op1_16 + op2_16 + getB_CF(); write_RMW_virtual_word(sum_16); SET_FLAGS_OSZAPC_ADD_16(op1_16, op2_16, sum_16); BX_NEXT_INSTR(i); }
BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::SUB_EwIwM(bxInstruction_c *i) { bx_address eaddr = BX_CPU_CALL_METHODR(i->ResolveModrm, (i)); Bit32u op1_16 = read_RMW_virtual_word(i->seg(), eaddr); Bit32u op2_16 = i->Iw(); Bit32u diff_16 = op1_16 - op2_16; write_RMW_virtual_word(diff_16); SET_FLAGS_OSZAPC_SUB_16(op1_16, op2_16, diff_16); BX_NEXT_INSTR(i); }
void BX_CPP_AttrRegparmN(1) BX_CPU_C::SBB_EwGwM(bxInstruction_c *i) { Bit16u op1_16, op2_16, diff_16; bx_bool temp_CF = getB_CF(); BX_CPU_CALL_METHODR(i->ResolveModrm, (i)); op1_16 = read_RMW_virtual_word(i->seg(), RMAddr(i)); op2_16 = BX_READ_16BIT_REG(i->nnn()); diff_16 = op1_16 - (op2_16 + temp_CF); write_RMW_virtual_word(diff_16); SET_FLAGS_OSZAPC_16(op1_16, op2_16, diff_16, BX_LF_INSTR_SUB_SBB16(temp_CF)); }
BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::CMPXCHG_EwGwM(bxInstruction_c *i) { bx_address eaddr = BX_CPU_CALL_METHODR(i->ResolveModrm, (i)); Bit16u op1_16 = read_RMW_virtual_word(i->seg(), eaddr); Bit16u diff_16 = AX - op1_16; SET_FLAGS_OSZAPC_SUB_16(AX, op1_16, diff_16); if (diff_16 == 0) { // if accumulator == dest // dest <-- src write_RMW_virtual_word(BX_READ_16BIT_REG(i->nnn())); } else { // accumulator <-- dest AX = op1_16; } BX_NEXT_INSTR(i); }
BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::XADD_EwGwM(bxInstruction_c *i) { /* XADD dst(r/m), src(r) * temp <-- src + dst | sum = op2 + op1 * src <-- dst | op2 = op1 * dst <-- tmp | op1 = sum */ bx_address eaddr = BX_CPU_CALL_METHODR(i->ResolveModrm, (i)); Bit32u op1_16 = read_RMW_virtual_word(i->seg(), eaddr); Bit32u op2_16 = BX_READ_16BIT_REG(i->nnn()); Bit32u sum_16 = op1_16 + op2_16; write_RMW_virtual_word(sum_16); /* and write destination into source */ BX_WRITE_16BIT_REG(i->nnn(), op1_16); SET_FLAGS_OSZAPC_ADD_16(op1_16, op2_16, sum_16); BX_NEXT_INSTR(i); }