(cpu64) Merged another wad of files.

This commit is contained in:
Kevin Lawton 2002-09-15 01:00:20 +00:00
parent 425a8cda81
commit a372b32c79
5 changed files with 104 additions and 25 deletions

View File

@ -51,16 +51,10 @@ EXT_DEBUG_OBJS = @EXT_DEBUG_OBJS@
# been synced yet.
OBJS32 = \
ctrl_xfer_pro.o \
flag_ctrl_pro.o \
segment_ctrl_pro.o \
stack_pro.o \
paging.o \
debugstuff.o \
arith32.o \
mult32.o \
stack32.o \
bit.o \
flag_ctrl.o \
io.o \
string.o \
$(EXT_DEBUG_OBJS) \
@ -104,6 +98,12 @@ OBJSXX = \
exception.o \
proc_ctrl.o \
lazy_flags.o \
stack_pro.o \
flag_ctrl_pro.o \
stack32.o \
debugstuff.o \
flag_ctrl.o \
mult32.o \
# Objects which are only used for x86-64 code, but which have been

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: flag_ctrl.cc,v 1.9 2002-09-12 18:10:40 bdenney Exp $
// $Id: flag_ctrl.cc,v 1.10 2002-09-15 01:00:19 kevinlawton Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2002 MandrakeSoft S.A.
@ -151,6 +151,12 @@ BX_CPU_C::PUSHF_Fv(BxInstruction_t *i)
}
#if BX_CPU_LEVEL >= 3
#if BX_SUPPORT_X86_64
if (BX_CPU_THIS_PTR cpu_mode == BX_MODE_LONG_64) {
push_64(read_eflags() & 0x00fcffff);
}
else
#endif
if (i->os_32) {
push_32(read_eflags() & 0x00fcffff);
}
@ -168,7 +174,7 @@ BX_CPU_C::POPF_Fv(BxInstruction_t *i)
#if BX_CPU_LEVEL >= 3
if (v8086_mode()) {
if (BX_CPU_THIS_PTR get_IOPL () < 3) {
if (BX_CPU_THIS_PTR get_IOPL() < 3) {
exception(BX_GP_EXCEPTION, 0, 0);
return;
}
@ -183,6 +189,22 @@ BX_CPU_C::POPF_Fv(BxInstruction_t *i)
}
}
#if BX_SUPPORT_X86_64
if (BX_CPU_THIS_PTR cpu_mode == BX_MODE_LONG_64) {
Bit64u eflags_tmp;
pop_64(&eflags_tmp);
eflags_tmp &= 0x00277fd7;
if (!real_mode()) {
write_eflags(eflags_tmp, /* change IOPL? */ CPL==0, /* change IF? */ CPL<=BX_CPU_THIS_PTR get_IOPL(), 0, 0);
}
else { /* real mode */
write_eflags(eflags_tmp, /* change IOPL? */ 1, /* change IF? */ 1, 0, 0);
}
}
else
#endif // #if BX_SUPPORT_X86_64
if (i->os_32) {
Bit32u eflags_tmp;
@ -204,7 +226,7 @@ BX_CPU_C::POPF_Fv(BxInstruction_t *i)
pop_16(&flags);
if (!real_mode()) {
write_flags(flags, /* change IOPL? */ CPL==0, /* change IF? */ CPL<=BX_CPU_THIS_PTR get_IOPL ());
write_flags(flags, /* change IOPL? */ CPL==0, /* change IF? */ CPL<=BX_CPU_THIS_PTR get_IOPL());
}
else { /* real mode */
write_flags(flags, /* change IOPL? */ 1, /* change IF? */ 1);

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: mult32.cc,v 1.6 2001-10-03 13:10:37 bdenney Exp $
// $Id: mult32.cc,v 1.7 2002-09-15 01:00:19 kevinlawton Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2001 MandrakeSoft S.A.
@ -35,6 +35,11 @@
#if BX_SUPPORT_X86_64==0
#define RAX EAX
#define RDX EDX
#endif
void
BX_CPU_C::MUL_EAXEd(BxInstruction_t *i)
@ -61,8 +66,8 @@ BX_CPU_C::MUL_EAXEd(BxInstruction_t *i)
/* now write product back to destination */
EAX = product_32l;
EDX = product_32h;
RAX = product_32l;
RDX = product_32h;
/* set eflags:
* MUL affects the following flags: C,O
@ -99,8 +104,8 @@ BX_CPU_C::IMUL_EAXEd(BxInstruction_t *i)
/* now write product back to destination */
EAX = product_32l;
EDX = product_32h;
RAX = product_32l;
RDX = product_32h;
/* set eflags:
* IMUL affects the following flags: C,O
@ -154,8 +159,8 @@ BX_CPU_C::DIV_EAXEd(BxInstruction_t *i)
/* now write quotient back to destination */
EAX = quotient_32l;
EDX = remainder_32;
RAX = quotient_32l;
RDX = remainder_32;
}
@ -193,8 +198,8 @@ BX_CPU_C::IDIV_EAXEd(BxInstruction_t *i)
/* now write quotient back to destination */
EAX = quotient_32l;
EDX = remainder_32;
RAX = quotient_32l;
RDX = remainder_32;
}
@ -224,7 +229,7 @@ BX_CPU_C::IMUL_GdEdId(BxInstruction_t *i)
product_64 = ((Bit64s) op2_32) * ((Bit64s) op3_32);
/* now write product back to destination */
BX_WRITE_32BIT_REG(i->nnn, product_32);
BX_WRITE_32BIT_REGZ(i->nnn, product_32);
/* set eflags:
* IMUL affects the following flags: C,O
@ -267,7 +272,7 @@ BX_CPU_C::IMUL_GdEd(BxInstruction_t *i)
product_64 = ((Bit64s) op1_32) * ((Bit64s) op2_32);
/* now write product back to destination */
BX_WRITE_32BIT_REG(i->nnn, product_32);
BX_WRITE_32BIT_REGZ(i->nnn, product_32);
/* set eflags:
* IMUL affects the following flags: C,O

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: stack32.cc,v 1.9 2002-09-13 00:15:23 kevinlawton Exp $
// $Id: stack32.cc,v 1.10 2002-09-15 01:00:20 kevinlawton Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2001 MandrakeSoft S.A.
@ -37,6 +37,13 @@
#endif
#if BX_SUPPORT_X86_64==0
// Make life easier for merging 64&32-bit code.
#define RBP EBP
#endif
void
BX_CPU_C::POP_Ed(BxInstruction_t *i)
{
@ -45,7 +52,7 @@ BX_CPU_C::POP_Ed(BxInstruction_t *i)
pop_32(&val32);
if (i->mod == 0xc0) {
BX_WRITE_32BIT_REG(i->rm, val32);
BX_WRITE_32BIT_REGZ(i->rm, val32);
}
else {
// Note: there is one little weirdism here. When 32bit addressing
@ -63,7 +70,11 @@ BX_CPU_C::POP_Ed(BxInstruction_t *i)
void
BX_CPU_C::PUSH_ERX(BxInstruction_t *i)
{
#if BX_SUPPORT_X86_64
push_32(BX_CPU_THIS_PTR gen_reg[i->nnn].dword.erx);
#else
push_32(BX_CPU_THIS_PTR gen_reg[i->b1 & 0x07].dword.erx);
#endif
}
void
@ -72,7 +83,11 @@ BX_CPU_C::POP_ERX(BxInstruction_t *i)
Bit32u erx;
pop_32(&erx);
#if BX_SUPPORT_X86_64
BX_CPU_THIS_PTR gen_reg[i->nnn].dword.erx = erx;
#else
BX_CPU_THIS_PTR gen_reg[i->b1 & 0x07].dword.erx = erx;
#endif
}
@ -441,7 +456,7 @@ BX_CPU_C::ENTER_IwIb(BxInstruction_t *i)
} /* if (level > 0) ... */
if (i->os_32)
EBP = frame_ptr32;
RBP = frame_ptr32;
else
BP = frame_ptr32;
@ -504,7 +519,7 @@ BX_CPU_C::LEAVE(BxInstruction_t *i)
Bit32u temp32;
pop_32(&temp32);
EBP = temp32;
RBP = temp32;
}
else
#endif

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: stack_pro.cc,v 1.6 2001-10-03 13:10:37 bdenney Exp $
// $Id: stack_pro.cc,v 1.7 2002-09-15 01:00:20 kevinlawton Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2001 MandrakeSoft S.A.
@ -129,6 +129,24 @@ BX_CPU_C::push_32(Bit32u value32)
return;
}
}
#if BX_SUPPORT_X86_64
void
BX_CPU_C::push_64(Bit64u value64)
{
/* 64bit stack size: pushes use SS:RSP, assume protected mode */
if (!can_push(&BX_CPU_THIS_PTR sregs[BX_SEG_REG_SS].cache, RSP, 8)) {
BX_PANIC(("push_64(): push outside stack limits"));
/* #SS(0) */
}
write_virtual_qword(BX_SEG_REG_SS, RSP-8, &value64);
RSP -= 8;
/* will return after error anyway */
return;
}
#endif // #if BX_SUPPORT_X86_64
#endif /* BX_CPU_LEVEL >= 3 */
void
@ -192,6 +210,25 @@ BX_CPU_C::pop_32(Bit32u *value32_ptr)
else
SP += 4;
}
#if BX_SUPPORT_X86_64
void
BX_CPU_C::pop_64(Bit64u *value64_ptr)
{
if ( !can_pop(8) ) {
BX_PANIC(("pop_64(): can't pop from stack"));
exception(BX_SS_EXCEPTION, 0, 0);
return;
}
/* access within limits */
read_virtual_qword(BX_SEG_REG_SS, RSP, value64_ptr);
RSP += 8;
}
#endif // #if BX_SUPPORT_X86_64
#endif