Split BOUND instruction to two different according to operand size

Coding style change
This commit is contained in:
Stanislav Shwartsman 2005-01-28 20:50:48 +00:00
parent 54e23418f5
commit bbcc5e0e3a
6 changed files with 122 additions and 151 deletions

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: cpu.h,v 1.193 2004-12-17 10:50:47 sshwarts Exp $
// $Id: cpu.h,v 1.194 2005-01-28 20:50:47 sshwarts Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2001 MandrakeSoft S.A.
@ -1506,7 +1506,6 @@ public: // for now...
BX_SMF void PUSHAD16(bxInstruction_c *);
BX_SMF void POPAD32(bxInstruction_c *);
BX_SMF void POPAD16(bxInstruction_c *);
BX_SMF void BOUND_GvMa(bxInstruction_c *);
BX_SMF void ARPL_EwGw(bxInstruction_c *);
BX_SMF void PUSH_Id(bxInstruction_c *);
BX_SMF void PUSH_Iw(bxInstruction_c *);
@ -1515,6 +1514,9 @@ public: // for now...
BX_SMF void OUTSB_DXXb(bxInstruction_c *);
BX_SMF void OUTSW_DXXv(bxInstruction_c *);
BX_SMF void BOUND_GwMa(bxInstruction_c *);
BX_SMF void BOUND_GdMa(bxInstruction_c *);
BX_SMF void TEST_EbGb(bxInstruction_c *);
BX_SMF void TEST_EdGd(bxInstruction_c *);
BX_SMF void TEST_EwGw(bxInstruction_c *);
@ -1579,8 +1581,6 @@ public: // for now...
BX_SMF void RETnear32(bxInstruction_c *);
BX_SMF void RETnear16(bxInstruction_c *);
BX_SMF void LES_GvMp(bxInstruction_c *);
BX_SMF void LDS_GvMp(bxInstruction_c *);
BX_SMF void MOV_EbIb(bxInstruction_c *);
BX_SMF void MOV_EdId(bxInstruction_c *);
BX_SMF void MOV_EwIw(bxInstruction_c *);
@ -1686,9 +1686,12 @@ public: // for now...
BX_SMF void BTC_EwGw(bxInstruction_c *);
BX_SMF void BTC_EdGd(bxInstruction_c *);
BX_SMF void LES_GvMp(bxInstruction_c *);
BX_SMF void LDS_GvMp(bxInstruction_c *);
BX_SMF void LSS_GvMp(bxInstruction_c *);
BX_SMF void LFS_GvMp(bxInstruction_c *);
BX_SMF void LGS_GvMp(bxInstruction_c *);
BX_SMF void MOVZX_GdEb(bxInstruction_c *);
BX_SMF void MOVZX_GwEb(bxInstruction_c *);
BX_SMF void MOVZX_GdEw(bxInstruction_c *);

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: fetchdecode.cc,v 1.73 2004-12-11 20:51:08 sshwarts Exp $
// $Id: fetchdecode.cc,v 1.74 2005-01-28 20:50:47 sshwarts Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2001 MandrakeSoft S.A.
@ -489,7 +489,7 @@ static BxOpcodeInfo_t BxOpcodeInfo[512*2] = {
/* 5F */ { 0, &BX_CPU_C::POP_RX },
/* 60 */ { 0, &BX_CPU_C::PUSHAD16 },
/* 61 */ { 0, &BX_CPU_C::POPAD16 },
/* 62 */ { BxAnother, &BX_CPU_C::BOUND_GvMa },
/* 62 */ { BxAnother, &BX_CPU_C::BOUND_GwMa },
/* 63 */ { BxAnother, &BX_CPU_C::ARPL_EwGw },
/* 64 */ { BxPrefix | BxAnother, &BX_CPU_C::BxError }, // FS:
/* 65 */ { BxPrefix | BxAnother, &BX_CPU_C::BxError }, // GS:
@ -1037,7 +1037,7 @@ static BxOpcodeInfo_t BxOpcodeInfo[512*2] = {
/* 5F */ { 0, &BX_CPU_C::POP_ERX },
/* 60 */ { 0, &BX_CPU_C::PUSHAD32 },
/* 61 */ { 0, &BX_CPU_C::POPAD32 },
/* 62 */ { BxAnother, &BX_CPU_C::BOUND_GvMa },
/* 62 */ { BxAnother, &BX_CPU_C::BOUND_GdMa },
/* 63 */ { BxAnother, &BX_CPU_C::ARPL_EwGw },
/* 64 */ { BxPrefix | BxAnother, &BX_CPU_C::BxError }, // FS:
/* 65 */ { BxPrefix | BxAnother, &BX_CPU_C::BxError }, // GS:

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: protect_ctrl.cc,v 1.32 2004-10-16 19:34:17 sshwarts Exp $
// $Id: protect_ctrl.cc,v 1.33 2005-01-28 20:50:48 sshwarts Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2001 MandrakeSoft S.A.
@ -45,11 +45,11 @@ BX_CPU_C::ARPL_EwGw(bxInstruction_c *i)
/* op1_16 is a register or memory reference */
if (i->modC0()) {
op1_16 = BX_READ_16BIT_REG(i->rm());
}
}
else {
/* pointer, segment address pair */
read_RMW_virtual_word(i->seg(), RMAddr(i), &op1_16);
}
}
op2_16 = BX_READ_16BIT_REG(i->nnn());
@ -60,31 +60,28 @@ BX_CPU_C::ARPL_EwGw(bxInstruction_c *i)
if (i->os32L()) {
// if 32bit opsize, then 0xff3f is or'd into
// upper 16bits of register
Bit32u op1_32;
op1_32 = BX_READ_32BIT_REG(i->rm());
Bit32u op1_32 = BX_READ_32BIT_REG(i->rm());
op1_32 = (op1_32 & 0xffff0000) | op1_16;
op1_32 |= 0xff3f0000;
BX_WRITE_32BIT_REGZ(i->rm(), op1_32);
}
}
else {
BX_WRITE_16BIT_REG(i->rm(), op1_16);
}
}
}
else {
Write_RMW_virtual_word(op1_16);
}
set_ZF(1);
}
set_ZF(1);
}
else {
set_ZF(0);
}
}
}
else {
BX_DEBUG(("ARPL: not recognized in real or virtual-8086 mode"));
UndefinedOpcode(i);
return;
}
}
#endif
}
@ -189,7 +186,6 @@ BX_CPU_C::LAR_GvEw(bxInstruction_c *i)
else {
BX_WRITE_16BIT_REG(i->nnn(), dword2 & 0xff00);
}
return;
}
}
@ -292,16 +288,16 @@ BX_CPU_C::SLDT_Ew(bxInstruction_c *i)
if (real_mode() || v8086_mode()) {
BX_INFO(("SLDT: not recognized in real or virtual-8086 mode"));
UndefinedOpcode(i);
}
}
else {
Bit16u val16 = BX_CPU_THIS_PTR ldtr.selector.value;
if (i->modC0()) {
BX_WRITE_16BIT_REG(i->rm(), val16);
}
}
else {
write_virtual_word(i->seg(), RMAddr(i), &val16);
}
}
}
#endif
}
@ -316,11 +312,11 @@ BX_CPU_C::STR_Ew(bxInstruction_c *i)
Bit16u val16 = BX_CPU_THIS_PTR tr.selector.value;
if (i->modC0()) {
BX_WRITE_16BIT_REG(i->rm(), val16);
}
}
else {
write_virtual_word(i->seg(), RMAddr(i), &val16);
}
}
}
}
void
@ -515,8 +511,7 @@ void BX_CPU_C::LTR_Ew(bxInstruction_c *i)
#endif
}
void
BX_CPU_C::VERR_Ew(bxInstruction_c *i)
void BX_CPU_C::VERR_Ew(bxInstruction_c *i)
{
/* for 16 bit operand size mode */
Bit16u raw_selector;
@ -602,12 +597,10 @@ BX_CPU_C::VERR_Ew(bxInstruction_c *i)
}
set_ZF(1); /* accessible */
BX_DEBUG(("VERR: data segment OK"));
return;
}
}
void
BX_CPU_C::VERW_Ew(bxInstruction_c *i)
void BX_CPU_C::VERW_Ew(bxInstruction_c *i)
{
/* for 16 bit operand size mode */
Bit16u raw_selector;
@ -677,18 +670,14 @@ BX_CPU_C::VERW_Ew(bxInstruction_c *i)
set_ZF(0); /* not accessible */
BX_INFO(("VERW: data seg not writable"));
return;
}
void
BX_CPU_C::SGDT_Ms(bxInstruction_c *i)
void BX_CPU_C::SGDT_Ms(bxInstruction_c *i)
{
#if BX_CPU_LEVEL < 2
BX_PANIC(("SGDT_Ms: not supported on 8086!"));
UndefinedOpcode(i);
#else
Bit16u limit_16;
Bit32u base_32;
/* op1 is a register or memory reference */
if (i->modC0()) {
@ -700,10 +689,8 @@ BX_CPU_C::SGDT_Ms(bxInstruction_c *i)
#if BX_SUPPORT_X86_64
if (BX_CPU_THIS_PTR cpu_mode == BX_MODE_LONG_64)
{
Bit64u base_64;
limit_16 = BX_CPU_THIS_PTR gdtr.limit;
base_64 = BX_CPU_THIS_PTR gdtr.base;
Bit16u limit_16 = BX_CPU_THIS_PTR gdtr.limit;
Bit64u base_64 = BX_CPU_THIS_PTR gdtr.base;
write_virtual_word(i->seg(), RMAddr(i), &limit_16);
write_virtual_qword(i->seg(), RMAddr(i)+2, &base_64);
@ -711,8 +698,8 @@ BX_CPU_C::SGDT_Ms(bxInstruction_c *i)
else
#endif
{
limit_16 = BX_CPU_THIS_PTR gdtr.limit;
base_32 = BX_CPU_THIS_PTR gdtr.base;
Bit16u limit_16 = BX_CPU_THIS_PTR gdtr.limit;
Bit32u base_32 = BX_CPU_THIS_PTR gdtr.base;
#if BX_CPU_LEVEL == 2
base_32 |= 0xff000000; /* ??? */
#else /* 386+ */
@ -724,15 +711,12 @@ BX_CPU_C::SGDT_Ms(bxInstruction_c *i)
#endif
}
void
BX_CPU_C::SIDT_Ms(bxInstruction_c *i)
void BX_CPU_C::SIDT_Ms(bxInstruction_c *i)
{
#if BX_CPU_LEVEL < 2
BX_PANIC(("SIDT_Ms: not supported on 8086!"));
UndefinedOpcode(i);
#else
Bit16u limit_16;
Bit32u base_32;
// ams says it works ok in v8086 mode
// if (v8086_mode()) BX_PANIC(("protect_ctrl: v8086 mode unsupported"));
@ -747,10 +731,8 @@ BX_CPU_C::SIDT_Ms(bxInstruction_c *i)
#if BX_SUPPORT_X86_64
if (BX_CPU_THIS_PTR cpu_mode == BX_MODE_LONG_64)
{
Bit64u base_64;
limit_16 = BX_CPU_THIS_PTR idtr.limit;
base_64 = BX_CPU_THIS_PTR idtr.base;
Bit16u limit_16 = BX_CPU_THIS_PTR idtr.limit;
Bit64u base_64 = BX_CPU_THIS_PTR idtr.base;
write_virtual_word(i->seg(), RMAddr(i), &limit_16);
write_virtual_qword(i->seg(), RMAddr(i)+2, &base_64);
@ -758,8 +740,8 @@ BX_CPU_C::SIDT_Ms(bxInstruction_c *i)
else
#endif
{
limit_16 = BX_CPU_THIS_PTR idtr.limit;
base_32 = BX_CPU_THIS_PTR idtr.base;
Bit16u limit_16 = BX_CPU_THIS_PTR idtr.limit;
Bit32u base_32 = BX_CPU_THIS_PTR idtr.base;
#if BX_CPU_LEVEL == 2
base_32 |= 0xff000000;
@ -774,8 +756,7 @@ BX_CPU_C::SIDT_Ms(bxInstruction_c *i)
#endif
}
void
BX_CPU_C::LGDT_Ms(bxInstruction_c *i)
void BX_CPU_C::LGDT_Ms(bxInstruction_c *i)
{
#if BX_CPU_LEVEL < 2
BX_PANIC(("LGDT_Ms: not supported on 8086!"));
@ -824,7 +805,7 @@ BX_CPU_C::LGDT_Ms(bxInstruction_c *i)
BX_CPU_THIS_PTR gdtr.limit = limit_16;
BX_CPU_THIS_PTR gdtr.base = base0_31;
}
}
else
#endif
{
@ -842,8 +823,7 @@ BX_CPU_C::LGDT_Ms(bxInstruction_c *i)
#endif
}
void
BX_CPU_C::LIDT_Ms(bxInstruction_c *i)
void BX_CPU_C::LIDT_Ms(bxInstruction_c *i)
{
#if BX_CPU_LEVEL < 2
BX_PANIC(("LIDT_Ms: not supported on 8086!"));

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: protect_ctrl_pro.cc,v 1.7 2004-08-13 20:00:03 sshwarts Exp $
// $Id: protect_ctrl_pro.cc,v 1.8 2005-01-28 20:50:48 sshwarts Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2001 MandrakeSoft S.A.
@ -30,8 +30,7 @@
#define LOG_THIS BX_CPU_THIS_PTR
void
BX_CPU_C::enter_protected_mode(void)
void BX_CPU_C::enter_protected_mode(void)
{
// BX_INFO(("processor switching into PROTECTED mode!!!"));
// debug(BX_CPU_THIS_PTR prev_eip);
@ -40,13 +39,12 @@ BX_CPU_C::enter_protected_mode(void)
if (bx_dbg.reset)
BX_INFO(("processor switching into PROTECTED mode!!!"));
if ( BX_CPU_THIS_PTR sregs[BX_SEG_REG_CS].selector.rpl!=0 || BX_CPU_THIS_PTR sregs[BX_SEG_REG_SS].selector.rpl!=0 )
BX_PANIC(("enter_protected_mode: CS or SS rpl != 0"));
if (BX_CPU_THIS_PTR sregs[BX_SEG_REG_CS].selector.rpl!=0 || BX_CPU_THIS_PTR sregs[BX_SEG_REG_SS].selector.rpl!=0)
BX_PANIC(("enter_protected_mode: CS or SS rpl != 0"));
}
void
BX_CPU_C::enter_real_mode(void)
void BX_CPU_C::enter_real_mode(void)
{
// BX_INFO(("processor switching into REAL mode!!!"));
// debug(BX_CPU_THIS_PTR prev_eip);
@ -55,6 +53,6 @@ BX_CPU_C::enter_real_mode(void)
if (bx_dbg.reset)
BX_INFO(("processor switching into REAL mode!!!"));
if ( BX_CPU_THIS_PTR sregs[BX_SEG_REG_CS].selector.rpl!=0 || BX_CPU_THIS_PTR sregs[BX_SEG_REG_SS].selector.rpl!=0 )
BX_PANIC(("enter_real_mode: CS or SS rpl != 0"));
if (BX_CPU_THIS_PTR sregs[BX_SEG_REG_CS].selector.rpl!=0 || BX_CPU_THIS_PTR sregs[BX_SEG_REG_SS].selector.rpl!=0)
BX_PANIC(("enter_real_mode: CS or SS rpl != 0"));
}

View File

@ -27,52 +27,45 @@
#include "bochs.h"
#define LOG_THIS BX_CPU_THIS_PTR
void
BX_CPU_C::BOUND_GvMa(bxInstruction_c *i)
void BX_CPU_C::BOUND_GwMa(bxInstruction_c *i)
{
#if BX_CPU_LEVEL < 2
BX_PANIC(("BOUND: not supported on 8086!"));
#else
if (i->modC0()) {
BX_INFO(("BOUND: op2 must be memory reference"));
BX_INFO(("BOUND_GwMa: op2 must be memory reference"));
UndefinedOpcode(i);
}
if (i->os32L()) {
Bit32s bound_min, bound_max;
Bit32s op1_32;
Bit16s bound_min, bound_max;
Bit16s op1_16 = BX_READ_16BIT_REG(i->nnn());
op1_32 = BX_READ_32BIT_REG(i->nnn());
read_virtual_word(i->seg(), RMAddr(i), (Bit16u *) &bound_min);
read_virtual_word(i->seg(), RMAddr(i)+2, (Bit16u *) &bound_max);
read_virtual_dword(i->seg(), RMAddr(i), (Bit32u *) &bound_min);
read_virtual_dword(i->seg(), RMAddr(i)+4, (Bit32u *) &bound_max);
if (op1_32 < bound_min || op1_32 > bound_max) {
BX_INFO(("BOUND: fails bounds test"));
exception(BX_BR_EXCEPTION, 0, 0);
}
if (op1_16 < bound_min || op1_16 > bound_max) {
BX_INFO(("BOUND_GdMa: fails bounds test"));
exception(BX_BR_EXCEPTION, 0, 0);
}
else {
Bit16s bound_min, bound_max;
Bit16s op1_16;
op1_16 = BX_READ_16BIT_REG(i->nnn());
read_virtual_word(i->seg(), RMAddr(i), (Bit16u *) &bound_min);
read_virtual_word(i->seg(), RMAddr(i)+2, (Bit16u *) &bound_max);
if (op1_16 < bound_min || op1_16 > bound_max) {
BX_INFO(("BOUND: fails bounds test"));
exception(BX_BR_EXCEPTION, 0, 0);
}
}
#endif
}
void
BX_CPU_C::INT1(bxInstruction_c *i)
void BX_CPU_C::BOUND_GdMa(bxInstruction_c *i)
{
if (i->modC0()) {
BX_INFO(("BOUND_GdMa: op2 must be memory reference"));
UndefinedOpcode(i);
}
Bit32s bound_min, bound_max;
Bit32s op1_32 = BX_READ_32BIT_REG(i->nnn());
read_virtual_dword(i->seg(), RMAddr(i), (Bit32u *) &bound_min);
read_virtual_dword(i->seg(), RMAddr(i)+4, (Bit32u *) &bound_max);
if (op1_32 < bound_min || op1_32 > bound_max) {
BX_INFO(("BOUND_GdMa: fails bounds test"));
exception(BX_BR_EXCEPTION, 0, 0);
}
}
void BX_CPU_C::INT1(bxInstruction_c *i)
{
// This is an undocumented instrucion (opcode 0xf1)
// which is useful for an ICE system.
@ -91,8 +84,7 @@ BX_CPU_C::INT1(bxInstruction_c *i)
EIP);
}
void
BX_CPU_C::INT3(bxInstruction_c *i)
void BX_CPU_C::INT3(bxInstruction_c *i)
{
// INT 3 is not IOPL sensitive
@ -107,8 +99,7 @@ BX_CPU_C::INT3(bxInstruction_c *i)
}
void
BX_CPU_C::INT_Ib(bxInstruction_c *i)
void BX_CPU_C::INT_Ib(bxInstruction_c *i)
{
#if BX_DEBUGGER
BX_CPU_THIS_PTR show_flag |= Flag_int;
@ -132,8 +123,7 @@ if ( (imm8 == 0x21) && (AH == 0x4c) ) {
}
void
BX_CPU_C::INTO(bxInstruction_c *i)
void BX_CPU_C::INTO(bxInstruction_c *i)
{
#if BX_DEBUGGER
BX_CPU_THIS_PTR show_flag |= Flag_int;

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: stack32.cc,v 1.24 2004-11-27 20:36:53 sshwarts Exp $
// $Id: stack32.cc,v 1.25 2005-01-28 20:50:48 sshwarts Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2001 MandrakeSoft S.A.
@ -209,29 +209,29 @@ void BX_CPU_C::PUSHAD32(bxInstruction_c *i)
else
temp_ESP = SP;
if (protected_mode()) {
if ( !can_push(&BX_CPU_THIS_PTR sregs[BX_SEG_REG_SS].cache, temp_ESP, 32) ) {
if (protected_mode()) {
if (! can_push(&BX_CPU_THIS_PTR sregs[BX_SEG_REG_SS].cache, temp_ESP, 32)) {
BX_ERROR(("PUSHAD(): stack doesn't have enough room!"));
exception(BX_SS_EXCEPTION, 0, 0);
return;
}
}
else {
if (temp_ESP < 32)
BX_PANIC(("pushad: eSP < 32"));
}
}
}
else {
if (temp_ESP < 32)
BX_PANIC(("pushad: eSP < 32"));
}
esp = ESP;
esp = ESP;
/* ??? optimize this by using virtual write, all checks passed */
push_32(EAX);
push_32(ECX);
push_32(EDX);
push_32(EBX);
push_32(esp);
push_32(EBP);
push_32(ESI);
push_32(EDI);
/* ??? optimize this by using virtual write, all checks passed */
push_32(EAX);
push_32(ECX);
push_32(EDX);
push_32(EBX);
push_32(esp);
push_32(EBP);
push_32(ESI);
push_32(EDI);
#endif
}
@ -241,33 +241,33 @@ void BX_CPU_C::POPAD32(bxInstruction_c *i)
BX_INFO(("POPAD: not supported on an 8086"));
UndefinedOpcode(i);
#else
Bit32u edi, esi, ebp, etmp, ebx, edx, ecx, eax;
Bit32u edi, esi, ebp, etmp, ebx, edx, ecx, eax;
if (protected_mode()) {
if ( !can_pop(32) ) {
BX_ERROR(("POPAD: not enough bytes on stack"));
exception(BX_SS_EXCEPTION, 0, 0);
return;
}
}
if (protected_mode()) {
if ( !can_pop(32) ) {
BX_ERROR(("POPAD: not enough bytes on stack"));
exception(BX_SS_EXCEPTION, 0, 0);
return;
}
}
/* ??? optimize this */
pop_32(&edi);
pop_32(&esi);
pop_32(&ebp);
pop_32(&etmp); /* value for ESP discarded */
pop_32(&ebx);
pop_32(&edx);
pop_32(&ecx);
pop_32(&eax);
/* ??? optimize this */
pop_32(&edi);
pop_32(&esi);
pop_32(&ebp);
pop_32(&etmp); /* value for ESP discarded */
pop_32(&ebx);
pop_32(&edx);
pop_32(&ecx);
pop_32(&eax);
EDI = edi;
ESI = esi;
EBP = ebp;
EBX = ebx;
EDX = edx;
ECX = ecx;
EAX = eax;
EDI = edi;
ESI = esi;
EBP = ebp;
EBX = ebx;
EDX = edx;
ECX = ecx;
EAX = eax;
#endif
}