simplify code by merging two opcodes with similar behavior
This commit is contained in:
parent
cb1c03efec
commit
4e9e3f85de
@ -3736,9 +3736,7 @@ public: // for now...
|
||||
|
||||
BX_SMF void CMPXCHG8B(bxInstruction_c *) BX_CPP_AttrRegparmN(1);
|
||||
BX_SMF void RETnear32_Iw(bxInstruction_c *) BX_CPP_AttrRegparmN(1);
|
||||
BX_SMF void RETnear32(bxInstruction_c *) BX_CPP_AttrRegparmN(1);
|
||||
BX_SMF void RETnear16_Iw(bxInstruction_c *) BX_CPP_AttrRegparmN(1);
|
||||
BX_SMF void RETnear16(bxInstruction_c *) BX_CPP_AttrRegparmN(1);
|
||||
BX_SMF void RETfar32_Iw(bxInstruction_c *) BX_CPP_AttrRegparmN(1);
|
||||
BX_SMF void RETfar16_Iw(bxInstruction_c *) BX_CPP_AttrRegparmN(1);
|
||||
|
||||
@ -4098,7 +4096,6 @@ public: // for now...
|
||||
BX_SMF void XADD_EqGqM(bxInstruction_c *) BX_CPP_AttrRegparmN(1);
|
||||
|
||||
BX_SMF void RETnear64_Iw(bxInstruction_c *) BX_CPP_AttrRegparmN(1);
|
||||
BX_SMF void RETnear64(bxInstruction_c *) BX_CPP_AttrRegparmN(1);
|
||||
BX_SMF void RETfar64_Iw(bxInstruction_c *) BX_CPP_AttrRegparmN(1);
|
||||
|
||||
BX_SMF void CMOVO_GqEqR(bxInstruction_c *) BX_CPP_AttrRegparmN(1);
|
||||
|
@ -139,33 +139,6 @@ void BX_CPP_AttrRegparmN(1) BX_CPU_C::RETnear16_Iw(bxInstruction_c *i)
|
||||
BX_NEXT_TRACE(i);
|
||||
}
|
||||
|
||||
void BX_CPP_AttrRegparmN(1) BX_CPU_C::RETnear16(bxInstruction_c *i)
|
||||
{
|
||||
BX_ASSERT(BX_CPU_THIS_PTR cpu_mode != BX_MODE_LONG_64);
|
||||
|
||||
#if BX_DEBUGGER
|
||||
BX_CPU_THIS_PTR show_flag |= Flag_ret;
|
||||
#endif
|
||||
|
||||
RSP_SPECULATIVE;
|
||||
|
||||
Bit16u return_IP = pop_16();
|
||||
|
||||
if (return_IP > BX_CPU_THIS_PTR sregs[BX_SEG_REG_CS].cache.u.segment.limit_scaled)
|
||||
{
|
||||
BX_ERROR(("%s: offset outside of CS limits", i->getIaOpcodeNameShort()));
|
||||
exception(BX_GP_EXCEPTION, 0);
|
||||
}
|
||||
|
||||
EIP = return_IP;
|
||||
|
||||
RSP_COMMIT;
|
||||
|
||||
BX_INSTR_UCNEAR_BRANCH(BX_CPU_ID, BX_INSTR_IS_RET, PREV_RIP, EIP);
|
||||
|
||||
BX_NEXT_TRACE(i);
|
||||
}
|
||||
|
||||
void BX_CPP_AttrRegparmN(1) BX_CPU_C::RETfar16_Iw(bxInstruction_c *i)
|
||||
{
|
||||
Bit16u ip, cs_raw;
|
||||
|
@ -117,7 +117,6 @@ void BX_CPP_AttrRegparmN(1) BX_CPU_C::RETnear32_Iw(bxInstruction_c *i)
|
||||
|
||||
RSP_SPECULATIVE;
|
||||
|
||||
Bit16u imm16 = i->Iw();
|
||||
Bit32u return_EIP = pop_32();
|
||||
if (return_EIP > BX_CPU_THIS_PTR sregs[BX_SEG_REG_CS].cache.u.segment.limit_scaled)
|
||||
{
|
||||
@ -126,6 +125,7 @@ void BX_CPP_AttrRegparmN(1) BX_CPU_C::RETnear32_Iw(bxInstruction_c *i)
|
||||
}
|
||||
EIP = return_EIP;
|
||||
|
||||
Bit16u imm16 = i->Iw();
|
||||
if (BX_CPU_THIS_PTR sregs[BX_SEG_REG_SS].cache.u.segment.d_b)
|
||||
ESP += imm16;
|
||||
else
|
||||
@ -138,31 +138,6 @@ void BX_CPP_AttrRegparmN(1) BX_CPU_C::RETnear32_Iw(bxInstruction_c *i)
|
||||
BX_NEXT_TRACE(i);
|
||||
}
|
||||
|
||||
void BX_CPP_AttrRegparmN(1) BX_CPU_C::RETnear32(bxInstruction_c *i)
|
||||
{
|
||||
BX_ASSERT(BX_CPU_THIS_PTR cpu_mode != BX_MODE_LONG_64);
|
||||
|
||||
#if BX_DEBUGGER
|
||||
BX_CPU_THIS_PTR show_flag |= Flag_ret;
|
||||
#endif
|
||||
|
||||
RSP_SPECULATIVE;
|
||||
|
||||
Bit32u return_EIP = pop_32();
|
||||
if (return_EIP > BX_CPU_THIS_PTR sregs[BX_SEG_REG_CS].cache.u.segment.limit_scaled)
|
||||
{
|
||||
BX_ERROR(("%s: offset outside of CS limits", i->getIaOpcodeNameShort()));
|
||||
exception(BX_GP_EXCEPTION, 0);
|
||||
}
|
||||
EIP = return_EIP;
|
||||
|
||||
RSP_COMMIT;
|
||||
|
||||
BX_INSTR_UCNEAR_BRANCH(BX_CPU_ID, BX_INSTR_IS_RET, PREV_RIP, EIP);
|
||||
|
||||
BX_NEXT_TRACE(i);
|
||||
}
|
||||
|
||||
void BX_CPP_AttrRegparmN(1) BX_CPU_C::RETfar32_Iw(bxInstruction_c *i)
|
||||
{
|
||||
invalidate_prefetch_q();
|
||||
|
@ -64,27 +64,6 @@ void BX_CPP_AttrRegparmN(1) BX_CPU_C::RETnear64_Iw(bxInstruction_c *i)
|
||||
BX_NEXT_TRACE(i);
|
||||
}
|
||||
|
||||
void BX_CPP_AttrRegparmN(1) BX_CPU_C::RETnear64(bxInstruction_c *i)
|
||||
{
|
||||
#if BX_DEBUGGER
|
||||
BX_CPU_THIS_PTR show_flag |= Flag_ret;
|
||||
#endif
|
||||
|
||||
Bit64u return_RIP = stack_read_qword(RSP);
|
||||
|
||||
if (! IsCanonical(return_RIP)) {
|
||||
BX_ERROR(("%s: canonical RIP violation", i->getIaOpcodeNameShort()));
|
||||
exception(BX_GP_EXCEPTION, 0);
|
||||
}
|
||||
|
||||
RIP = return_RIP;
|
||||
RSP += 8;
|
||||
|
||||
BX_INSTR_UCNEAR_BRANCH(BX_CPU_ID, BX_INSTR_IS_RET, PREV_RIP, RIP);
|
||||
|
||||
BX_NEXT_TRACE(i);
|
||||
}
|
||||
|
||||
void BX_CPP_AttrRegparmN(1) BX_CPU_C::RETfar64_Iw(bxInstruction_c *i)
|
||||
{
|
||||
invalidate_prefetch_q();
|
||||
|
@ -568,9 +568,9 @@ bx_define_opcode(BX_IA_RETF_Op16_Iw, NULL, &BX_CPU_C::RETfar16_Iw, 0, OP_Iw, OP_
|
||||
bx_define_opcode(BX_IA_RETF_Op32, NULL, &BX_CPU_C::RETfar32_Iw, 0, OP_NONE, OP_NONE, OP_NONE, OP_NONE, BX_TRACE_END)
|
||||
bx_define_opcode(BX_IA_RETF_Op32_Iw, NULL, &BX_CPU_C::RETfar32_Iw, 0, OP_Iw, OP_NONE, OP_NONE, OP_NONE, BX_TRACE_END)
|
||||
|
||||
bx_define_opcode(BX_IA_RET_Op16, NULL, &BX_CPU_C::RETnear16, 0, OP_NONE, OP_NONE, OP_NONE, OP_NONE, BX_TRACE_END)
|
||||
bx_define_opcode(BX_IA_RET_Op16, NULL, &BX_CPU_C::RETnear16_Iw, 0, OP_NONE, OP_NONE, OP_NONE, OP_NONE, BX_TRACE_END)
|
||||
bx_define_opcode(BX_IA_RET_Op16_Iw, NULL, &BX_CPU_C::RETnear16_Iw, 0, OP_Iw, OP_NONE, OP_NONE, OP_NONE, BX_TRACE_END)
|
||||
bx_define_opcode(BX_IA_RET_Op32, NULL, &BX_CPU_C::RETnear32, 0, OP_NONE, OP_NONE, OP_NONE, OP_NONE, BX_TRACE_END)
|
||||
bx_define_opcode(BX_IA_RET_Op32, NULL, &BX_CPU_C::RETnear32_Iw, 0, OP_NONE, OP_NONE, OP_NONE, OP_NONE, BX_TRACE_END)
|
||||
bx_define_opcode(BX_IA_RET_Op32_Iw, NULL, &BX_CPU_C::RETnear32_Iw, 0, OP_Iw, OP_NONE, OP_NONE, OP_NONE, BX_TRACE_END)
|
||||
|
||||
bx_define_opcode(BX_IA_NOT_Eb, &BX_CPU_C::NOT_EbM, &BX_CPU_C::NOT_EbR, 0, OP_Eb, OP_NONE, OP_NONE, OP_NONE, BX_LOCKABLE)
|
||||
@ -1634,7 +1634,7 @@ bx_define_opcode(BX_IA_CQO, NULL, &BX_CPU_C::CQO, 0, OP_NONE, OP_NONE, OP_NONE,
|
||||
bx_define_opcode(BX_IA_XADD_EqGq, &BX_CPU_C::XADD_EqGqM, &BX_CPU_C::XADD_EqGqR, 0, OP_Eq, OP_Gq, OP_NONE, OP_NONE, BX_LOCKABLE)
|
||||
|
||||
bx_define_opcode(BX_IA_RET_Op64_Iw, NULL, &BX_CPU_C::RETnear64_Iw, 0, OP_Iw, OP_NONE, OP_NONE, OP_NONE, BX_TRACE_END)
|
||||
bx_define_opcode(BX_IA_RET_Op64, NULL, &BX_CPU_C::RETnear64, 0, OP_NONE, OP_NONE, OP_NONE, OP_NONE, BX_TRACE_END)
|
||||
bx_define_opcode(BX_IA_RET_Op64, NULL, &BX_CPU_C::RETnear64_Iw, 0, OP_NONE, OP_NONE, OP_NONE, OP_NONE, BX_TRACE_END)
|
||||
bx_define_opcode(BX_IA_RETF_Op64_Iw, NULL, &BX_CPU_C::RETfar64_Iw, 0, OP_Iw, OP_NONE, OP_NONE, OP_NONE, BX_TRACE_END)
|
||||
bx_define_opcode(BX_IA_RETF_Op64, NULL, &BX_CPU_C::RETfar64_Iw, 0, OP_NONE, OP_NONE, OP_NONE, OP_NONE, BX_TRACE_END)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user