Some cleanup in lazy flags CF handling
This commit is contained in:
parent
7956e47de8
commit
0436125d60
@ -1,5 +1,5 @@
|
|||||||
/////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////
|
||||||
// $Id: lazy_flags.cc,v 1.33 2006-08-03 21:03:21 vruppert Exp $
|
// $Id: lazy_flags.cc,v 1.34 2007-03-18 19:29:17 sshwarts Exp $
|
||||||
/////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
// Copyright (C) 2001 MandrakeSoft S.A.
|
// Copyright (C) 2001 MandrakeSoft S.A.
|
||||||
@ -58,8 +58,8 @@ bx_bool BX_CPU_C::get_CFLazy(void)
|
|||||||
{
|
{
|
||||||
unsigned cf;
|
unsigned cf;
|
||||||
|
|
||||||
switch (BX_CPU_THIS_PTR lf_flags_status & 0x00000f) {
|
BX_ASSERT((BX_CPU_THIS_PTR lf_flags_status & 0x00000f) == BX_LF_INDEX_OSZAPC);
|
||||||
case BX_LF_INDEX_OSZAPC:
|
|
||||||
switch (BX_CPU_THIS_PTR oszapc.instr) {
|
switch (BX_CPU_THIS_PTR oszapc.instr) {
|
||||||
case BX_INSTR_ADD8:
|
case BX_INSTR_ADD8:
|
||||||
cf = (BX_CPU_THIS_PTR oszapc.result_8 <
|
cf = (BX_CPU_THIS_PTR oszapc.result_8 <
|
||||||
@ -121,27 +121,23 @@ bx_bool BX_CPU_C::get_CFLazy(void)
|
|||||||
#endif
|
#endif
|
||||||
// used only if CF = 1 when executing SBB instruction
|
// used only if CF = 1 when executing SBB instruction
|
||||||
case BX_INSTR_SBB8:
|
case BX_INSTR_SBB8:
|
||||||
cf =
|
cf = (BX_CPU_THIS_PTR oszapc.op1_8 < BX_CPU_THIS_PTR oszapc.result_8) ||
|
||||||
(BX_CPU_THIS_PTR oszapc.op1_8 < BX_CPU_THIS_PTR oszapc.result_8) ||
|
|
||||||
(BX_CPU_THIS_PTR oszapc.op2_8==0xff);
|
(BX_CPU_THIS_PTR oszapc.op2_8==0xff);
|
||||||
break;
|
break;
|
||||||
// used only if CF = 1 when executing SBB instruction
|
// used only if CF = 1 when executing SBB instruction
|
||||||
case BX_INSTR_SBB16:
|
case BX_INSTR_SBB16:
|
||||||
cf =
|
cf = (BX_CPU_THIS_PTR oszapc.op1_16 < BX_CPU_THIS_PTR oszapc.result_16) ||
|
||||||
(BX_CPU_THIS_PTR oszapc.op1_16 < BX_CPU_THIS_PTR oszapc.result_16) ||
|
|
||||||
(BX_CPU_THIS_PTR oszapc.op2_16==0xffff);
|
(BX_CPU_THIS_PTR oszapc.op2_16==0xffff);
|
||||||
break;
|
break;
|
||||||
// used only if CF = 1 when executing SBB instruction
|
// used only if CF = 1 when executing SBB instruction
|
||||||
case BX_INSTR_SBB32:
|
case BX_INSTR_SBB32:
|
||||||
cf =
|
cf = (BX_CPU_THIS_PTR oszapc.op1_32 < BX_CPU_THIS_PTR oszapc.result_32) ||
|
||||||
(BX_CPU_THIS_PTR oszapc.op1_32 < BX_CPU_THIS_PTR oszapc.result_32) ||
|
|
||||||
(BX_CPU_THIS_PTR oszapc.op2_32==0xffffffff);
|
(BX_CPU_THIS_PTR oszapc.op2_32==0xffffffff);
|
||||||
break;
|
break;
|
||||||
#if BX_SUPPORT_X86_64
|
#if BX_SUPPORT_X86_64
|
||||||
// used only if CF = 1 when executing SBB instruction
|
// used only if CF = 1 when executing SBB instruction
|
||||||
case BX_INSTR_SBB64:
|
case BX_INSTR_SBB64:
|
||||||
cf =
|
cf = (BX_CPU_THIS_PTR oszapc.op1_64 < BX_CPU_THIS_PTR oszapc.result_64) ||
|
||||||
(BX_CPU_THIS_PTR oszapc.op1_64 < BX_CPU_THIS_PTR oszapc.result_64) ||
|
|
||||||
(BX_CPU_THIS_PTR oszapc.op2_64==BX_CONST64(0xffffffffffffffff));
|
(BX_CPU_THIS_PTR oszapc.op2_64==BX_CONST64(0xffffffffffffffff));
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
@ -172,8 +168,7 @@ bx_bool BX_CPU_C::get_CFLazy(void)
|
|||||||
break;
|
break;
|
||||||
case BX_INSTR_SAR8:
|
case BX_INSTR_SAR8:
|
||||||
if (BX_CPU_THIS_PTR oszapc.op2_8 < 8) {
|
if (BX_CPU_THIS_PTR oszapc.op2_8 < 8) {
|
||||||
cf =
|
cf = (BX_CPU_THIS_PTR oszapc.op1_8 >>
|
||||||
(BX_CPU_THIS_PTR oszapc.op1_8 >>
|
|
||||||
(BX_CPU_THIS_PTR oszapc.op2_8 - 1)) & 0x01;
|
(BX_CPU_THIS_PTR oszapc.op2_8 - 1)) & 0x01;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -181,14 +176,12 @@ bx_bool BX_CPU_C::get_CFLazy(void)
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case BX_INSTR_SHR8:
|
case BX_INSTR_SHR8:
|
||||||
cf =
|
cf = (BX_CPU_THIS_PTR oszapc.op1_8 >>
|
||||||
(BX_CPU_THIS_PTR oszapc.op1_8 >>
|
|
||||||
(BX_CPU_THIS_PTR oszapc.op2_8 - 1)) & 0x01;
|
(BX_CPU_THIS_PTR oszapc.op2_8 - 1)) & 0x01;
|
||||||
break;
|
break;
|
||||||
case BX_INSTR_SAR16:
|
case BX_INSTR_SAR16:
|
||||||
if (BX_CPU_THIS_PTR oszapc.op2_16 < 16) {
|
if (BX_CPU_THIS_PTR oszapc.op2_16 < 16) {
|
||||||
cf =
|
cf = (BX_CPU_THIS_PTR oszapc.op1_16 >>
|
||||||
(BX_CPU_THIS_PTR oszapc.op1_16 >>
|
|
||||||
(BX_CPU_THIS_PTR oszapc.op2_16 - 1)) & 0x01;
|
(BX_CPU_THIS_PTR oszapc.op2_16 - 1)) & 0x01;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -197,30 +190,26 @@ bx_bool BX_CPU_C::get_CFLazy(void)
|
|||||||
break;
|
break;
|
||||||
case BX_INSTR_SHR16:
|
case BX_INSTR_SHR16:
|
||||||
case BX_INSTR_SHRD16:
|
case BX_INSTR_SHRD16:
|
||||||
cf =
|
cf = (BX_CPU_THIS_PTR oszapc.op1_16 >>
|
||||||
(BX_CPU_THIS_PTR oszapc.op1_16 >>
|
|
||||||
(BX_CPU_THIS_PTR oszapc.op2_16 - 1)) & 0x01;
|
(BX_CPU_THIS_PTR oszapc.op2_16 - 1)) & 0x01;
|
||||||
break;
|
break;
|
||||||
case BX_INSTR_SAR32:
|
case BX_INSTR_SAR32:
|
||||||
case BX_INSTR_SHR32:
|
case BX_INSTR_SHR32:
|
||||||
case BX_INSTR_SHRD32:
|
case BX_INSTR_SHRD32:
|
||||||
cf =
|
cf = (BX_CPU_THIS_PTR oszapc.op1_32 >>
|
||||||
(BX_CPU_THIS_PTR oszapc.op1_32 >>
|
|
||||||
(BX_CPU_THIS_PTR oszapc.op2_32 - 1)) & 0x01;
|
(BX_CPU_THIS_PTR oszapc.op2_32 - 1)) & 0x01;
|
||||||
break;
|
break;
|
||||||
#if BX_SUPPORT_X86_64
|
#if BX_SUPPORT_X86_64
|
||||||
case BX_INSTR_SAR64:
|
case BX_INSTR_SAR64:
|
||||||
case BX_INSTR_SHR64:
|
case BX_INSTR_SHR64:
|
||||||
case BX_INSTR_SHRD64:
|
case BX_INSTR_SHRD64:
|
||||||
cf =
|
cf = (BX_CPU_THIS_PTR oszapc.op1_64 >>
|
||||||
(BX_CPU_THIS_PTR oszapc.op1_64 >>
|
|
||||||
(BX_CPU_THIS_PTR oszapc.op2_64 - 1)) & 0x01;
|
(BX_CPU_THIS_PTR oszapc.op2_64 - 1)) & 0x01;
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
case BX_INSTR_SHL8:
|
case BX_INSTR_SHL8:
|
||||||
if (BX_CPU_THIS_PTR oszapc.op2_8 <= 8) {
|
if (BX_CPU_THIS_PTR oszapc.op2_8 <= 8) {
|
||||||
cf =
|
cf = (BX_CPU_THIS_PTR oszapc.op1_8 >>
|
||||||
(BX_CPU_THIS_PTR oszapc.op1_8 >>
|
|
||||||
(8 - BX_CPU_THIS_PTR oszapc.op2_8)) & 0x01;
|
(8 - BX_CPU_THIS_PTR oszapc.op2_8)) & 0x01;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -229,8 +218,7 @@ bx_bool BX_CPU_C::get_CFLazy(void)
|
|||||||
break;
|
break;
|
||||||
case BX_INSTR_SHL16:
|
case BX_INSTR_SHL16:
|
||||||
if (BX_CPU_THIS_PTR oszapc.op2_16 <= 16) {
|
if (BX_CPU_THIS_PTR oszapc.op2_16 <= 16) {
|
||||||
cf =
|
cf = (BX_CPU_THIS_PTR oszapc.op1_16 >>
|
||||||
(BX_CPU_THIS_PTR oszapc.op1_16 >>
|
|
||||||
(16 - BX_CPU_THIS_PTR oszapc.op2_16)) & 0x01;
|
(16 - BX_CPU_THIS_PTR oszapc.op2_16)) & 0x01;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -238,14 +226,12 @@ bx_bool BX_CPU_C::get_CFLazy(void)
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case BX_INSTR_SHL32:
|
case BX_INSTR_SHL32:
|
||||||
cf =
|
cf = (BX_CPU_THIS_PTR oszapc.op1_32 >>
|
||||||
(BX_CPU_THIS_PTR oszapc.op1_32 >>
|
|
||||||
(32 - BX_CPU_THIS_PTR oszapc.op2_32)) & 0x01;
|
(32 - BX_CPU_THIS_PTR oszapc.op2_32)) & 0x01;
|
||||||
break;
|
break;
|
||||||
#if BX_SUPPORT_X86_64
|
#if BX_SUPPORT_X86_64
|
||||||
case BX_INSTR_SHL64:
|
case BX_INSTR_SHL64:
|
||||||
cf =
|
cf = (BX_CPU_THIS_PTR oszapc.op1_64 >>
|
||||||
(BX_CPU_THIS_PTR oszapc.op1_64 >>
|
|
||||||
(64 - BX_CPU_THIS_PTR oszapc.op2_64)) & 0x01;
|
(64 - BX_CPU_THIS_PTR oszapc.op2_64)) & 0x01;
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
@ -294,15 +280,11 @@ bx_bool BX_CPU_C::get_CFLazy(void)
|
|||||||
BX_PANIC(("get_CF: OSZAPC: unknown instr %u",
|
BX_PANIC(("get_CF: OSZAPC: unknown instr %u",
|
||||||
(unsigned) BX_CPU_THIS_PTR oszapc.instr));
|
(unsigned) BX_CPU_THIS_PTR oszapc.instr));
|
||||||
}
|
}
|
||||||
|
|
||||||
BX_CPU_THIS_PTR lf_flags_status &= 0xfffff0;
|
BX_CPU_THIS_PTR lf_flags_status &= 0xfffff0;
|
||||||
BX_CPU_THIS_PTR eflags.val32 &= ~(1<<0);
|
BX_CPU_THIS_PTR eflags.val32 &= ~(1<<0);
|
||||||
BX_CPU_THIS_PTR eflags.val32 |= (!!cf)<<0;
|
BX_CPU_THIS_PTR eflags.val32 |= (!!cf)<<0;
|
||||||
return(cf);
|
return(cf);
|
||||||
|
|
||||||
default:
|
|
||||||
BX_PANIC(("get_CF: unknown case"));
|
|
||||||
return(0);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bx_bool BX_CPU_C::get_AFLazy(void)
|
bx_bool BX_CPU_C::get_AFLazy(void)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user