speedup and cleanup

This commit is contained in:
Stanislav Shwartsman 2004-09-04 19:37:37 +00:00
parent 6dc8a1cafd
commit 3916754e30
5 changed files with 43 additions and 77 deletions

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: ctrl_xfer_pro.cc,v 1.25 2004-05-10 21:05:48 sshwarts Exp $
// $Id: ctrl_xfer_pro.cc,v 1.26 2004-09-04 19:37:36 sshwarts Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2001 MandrakeSoft S.A.
@ -1376,11 +1376,7 @@ BX_CPU_C::return_protected(bxInstruction_c *i, Bit16u pop_bytes)
/* check ES, DS, FS, GS for validity */
validate_seg_regs();
return;
}
return;
}
#endif

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: shift16.cc,v 1.23 2004-08-27 20:13:32 sshwarts Exp $
// $Id: shift16.cc,v 1.24 2004-09-04 19:37:37 sshwarts Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2001 MandrakeSoft S.A.
@ -256,7 +256,6 @@ BX_CPU_C::RCL_Ew(bxInstruction_c *i)
else // 0xd3
count = CL;
count &= 0x1F;
count %= 17;
/* op1 is a register or memory reference */
@ -313,7 +312,6 @@ BX_CPU_C::RCR_Ew(bxInstruction_c *i)
else // 0xd3
count = CL;
count = count & 0x1F;
count %= 17;
/* op1 is a register or memory reference */

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: shift8.cc,v 1.18 2004-08-27 20:13:32 sshwarts Exp $
// $Id: shift8.cc,v 1.19 2004-09-04 19:37:37 sshwarts Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2001 MandrakeSoft S.A.
@ -134,7 +134,6 @@ BX_CPU_C::RCL_Eb(bxInstruction_c *i)
else // 0xd2
count = CL;
count &= 0x1F;
count %= 9;
/* op1 is a register or memory reference */
@ -187,7 +186,6 @@ BX_CPU_C::RCR_Eb(bxInstruction_c *i)
else // 0xd2
count = CL;
count &= 0x1F;
count %= 9;
/* op1 is a register or memory reference */

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: stack32.cc,v 1.19 2004-09-04 10:21:28 sshwarts Exp $
// $Id: stack32.cc,v 1.20 2004-09-04 19:37:37 sshwarts Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2001 MandrakeSoft S.A.
@ -349,10 +349,11 @@ BX_CPU_C::ENTER_IwIb(bxInstruction_c *i)
}
else { /* level > 0 */
if (i->os32L())
bytes_to_push = 4 + (level-1)*4 + 4 + i->Iw();
bytes_to_push = 4 + level*4 + i->Iw();
else
bytes_to_push = 2 + (level-1)*2 + 2 + i->Iw();
bytes_to_push = 2 + level*2 + i->Iw();
}
if (BX_CPU_THIS_PTR sregs[BX_SEG_REG_SS].cache.u.segment.d_b)
temp_ESP = ESP;
else

View File

@ -1,6 +1,4 @@
/////////////////////////////////////////////////////////////////////////
// $Id: stack_pro.cc,v 1.16 2004-05-10 21:05:50 sshwarts Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2001 MandrakeSoft S.A.
//
@ -25,73 +23,60 @@
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#define NEED_CPU_REG_SHORTCUTS 1
#include "bochs.h"
#define LOG_THIS BX_CPU_THIS_PTR
void BX_CPP_AttrRegparmN(1)
BX_CPU_C::push_16(Bit16u value16)
{
BailBigRSP("push_16");
Bit32u temp_ESP;
/* must use StackAddrSize, and either ESP or SP accordingly */
if (BX_CPU_THIS_PTR sregs[BX_SEG_REG_SS].cache.u.segment.d_b) { /* StackAddrSize = 32 */
/* 32bit stack size: pushes use SS:ESP */
#if BX_CPU_LEVEL >= 2
if (protected_mode()) {
#if BX_CPU_LEVEL >= 3
if (BX_CPU_THIS_PTR sregs[BX_SEG_REG_SS].cache.u.segment.d_b)
temp_ESP = ESP;
else
#endif
temp_ESP = SP;
if (!can_push(&BX_CPU_THIS_PTR sregs[BX_SEG_REG_SS].cache, temp_ESP, 2)) {
BX_DEBUG(("push_16(): push outside stack limits"));
exception(BX_SS_EXCEPTION, 0, 0);
return;
if (protected_mode()) {
if (!can_push(&BX_CPU_THIS_PTR sregs[BX_SEG_REG_SS].cache, ESP, 2)) {
BX_INFO(("push_16(): push outside stack limits"));
exception(BX_SS_EXCEPTION, 0, 0);
}
/* access within limits */
write_virtual_word(BX_SEG_REG_SS, temp_ESP - 2, &value16);
if (BX_CPU_THIS_PTR sregs[BX_SEG_REG_SS].cache.u.segment.d_b)
ESP -= 2;
else
SP -= 2;
return;
}
else
else
#endif
{ /* real mode */
if (BX_CPU_THIS_PTR sregs[BX_SEG_REG_SS].cache.u.segment.d_b) {
if (ESP == 1)
BX_PANIC(("CPU shutting down due to lack of stack space, ESP==1"));
ESP -= 2;
temp_ESP = ESP;
}
write_virtual_word(BX_SEG_REG_SS, ESP-2, &value16);
ESP -= 2;
}
else
{
/* 16bit stack size: pushes use SS:SP */
#if BX_CPU_LEVEL >= 2
if (protected_mode()) {
if (!can_push(&BX_CPU_THIS_PTR sregs[BX_SEG_REG_SS].cache, SP, 2)) {
BX_INFO(("push_16(): push outside stack limits"));
exception(BX_SS_EXCEPTION, 0, 0);
}
else {
}
else
#endif
{ /* real mode */
if (SP == 1)
BX_PANIC(("CPU shutting down due to lack of stack space, SP==1"));
SP -= 2;
temp_ESP = SP;
}
write_virtual_word(BX_SEG_REG_SS, temp_ESP, &value16);
return;
}
write_virtual_word(BX_SEG_REG_SS, SP-2, &value16);
SP -= 2;
}
}
#if BX_CPU_LEVEL >= 3
/* push 32 bit operand size */
void
BX_CPU_C::push_32(Bit32u value32)
/* push 32 bit operand size */
void BX_CPU_C::push_32(Bit32u value32)
{
BailBigRSP("push_32");
/* must use StackAddrSize, and either ESP or SP accordingly */
if (BX_CPU_THIS_PTR sregs[BX_SEG_REG_SS].cache.u.segment.d_b) { /* StackAddrSize = 32 */
/* 32bit stack size: pushes use SS:ESP */
@ -109,9 +94,7 @@ BailBigRSP("push_32");
write_virtual_dword(BX_SEG_REG_SS, ESP-4, &value32);
ESP -= 4;
/* will return after error anyway */
return;
}
}
else { /* 16bit stack size: pushes use SS:SP */
if (protected_mode()) {
if (!can_push(&BX_CPU_THIS_PTR sregs[BX_SEG_REG_SS].cache, SP, 4)) {
@ -127,14 +110,11 @@ BailBigRSP("push_32");
write_virtual_dword(BX_SEG_REG_SS, (Bit16u) (SP-4), &value32);
SP -= 4;
/* will return after error anyway */
return;
}
}
}
#if BX_SUPPORT_X86_64
void
BX_CPU_C::push_64(Bit64u value64)
void BX_CPU_C::push_64(Bit64u value64)
{
/* 64bit stack size: pushes use SS:RSP, assume protected mode */
#if BX_IGNORE_THIS
@ -146,8 +126,6 @@ BX_CPU_C::push_64(Bit64u value64)
write_virtual_qword(BX_SEG_REG_SS, RSP-8, &value64);
RSP -= 8;
/* will return after error anyway */
return;
}
#endif // #if BX_SUPPORT_X86_64
@ -156,7 +134,6 @@ BX_CPU_C::push_64(Bit64u value64)
void
BX_CPU_C::pop_16(Bit16u *value16_ptr)
{
BailBigRSP("pop_16");
Bit32u temp_ESP;
#if BX_CPU_LEVEL >= 3
@ -176,7 +153,6 @@ BailBigRSP("pop_16");
}
#endif
/* access within limits */
read_virtual_word(BX_SEG_REG_SS, temp_ESP, value16_ptr);
@ -190,7 +166,6 @@ BailBigRSP("pop_16");
void
BX_CPU_C::pop_32(Bit32u *value32_ptr)
{
BailBigRSP("pop_32");
Bit32u temp_ESP;
/* 32 bit stack mode: use SS:ESP */
@ -218,8 +193,7 @@ BailBigRSP("pop_32");
}
#if BX_SUPPORT_X86_64
void
BX_CPU_C::pop_64(Bit64u *value64_ptr)
void BX_CPU_C::pop_64(Bit64u *value64_ptr)
{
if ( !can_pop(8) ) {
BX_ERROR(("pop_64(): can't pop from stack"));
@ -238,7 +212,6 @@ BX_CPU_C::pop_64(Bit64u *value64_ptr)
#endif
#if BX_CPU_LEVEL >= 2
bx_bool BX_CPP_AttrRegparmN(3)
BX_CPU_C::can_push(bx_descriptor_t *descriptor, Bit32u esp, Bit32u bytes)
@ -265,7 +238,7 @@ BX_CPU_C::can_push(bx_descriptor_t *descriptor, Bit32u esp, Bit32u bytes)
}
if (descriptor->p==0) {
BX_PANIC(("can_push(): not present"));
BX_PANIC(("can_push(): descriptor not present"));
return(0);
}