2nd step of lazy flags optimization
This commit is contained in:
parent
88899cf617
commit
295a36ef58
128
bochs/cpu/cpu.h
128
bochs/cpu/cpu.h
@ -1,5 +1,5 @@
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
// $Id: cpu.h,v 1.381 2007-12-04 19:27:22 sshwarts Exp $
|
||||
// $Id: cpu.h,v 1.382 2007-12-05 06:17:09 sshwarts Exp $
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2001 MandrakeSoft S.A.
|
||||
@ -1309,7 +1309,7 @@ public: // for now...
|
||||
} \
|
||||
BX_SMF void force_##flag(void) { \
|
||||
if ( (BX_CPU_THIS_PTR lf_flags_status & (lfMask)) != 0) { \
|
||||
set_##flag(!!get_##flag##Lazy()); \
|
||||
set_##flag(get_##flag##Lazy()); \
|
||||
} \
|
||||
}
|
||||
|
||||
@ -3524,97 +3524,78 @@ BX_CPP_INLINE void BX_CPU_C::set_PF_base(Bit8u val)
|
||||
|
||||
/* op1, op2, result */
|
||||
#define SET_FLAGS_OSZAPC_SIZE(size, lf_op1, lf_op2, lf_result, ins) { \
|
||||
BX_CPU_THIS_PTR oszapc.op1##size = lf_op1; \
|
||||
BX_CPU_THIS_PTR oszapc.op2##size = lf_op2; \
|
||||
BX_CPU_THIS_PTR oszapc.result##size = lf_result; \
|
||||
BX_CPU_THIS_PTR oszapc.instr = ins; \
|
||||
BX_CPU_THIS_PTR oszapc.op1_##size = (lf_op1); \
|
||||
BX_CPU_THIS_PTR oszapc.op2_##size = (lf_op2); \
|
||||
BX_CPU_THIS_PTR oszapc.result = (Bit##size##s)(lf_result); \
|
||||
BX_CPU_THIS_PTR oszapc.instr = (ins); \
|
||||
BX_CPU_THIS_PTR lf_flags_status = EFlagsOSZAPCMask; \
|
||||
}
|
||||
|
||||
#define SET_FLAGS_OSZAPC_8(op1, op2, result, ins) \
|
||||
SET_FLAGS_OSZAPC_SIZE(_8, op1, op2, result, ins)
|
||||
SET_FLAGS_OSZAPC_SIZE(8, op1, op2, result, ins)
|
||||
#define SET_FLAGS_OSZAPC_16(op1, op2, result, ins) \
|
||||
SET_FLAGS_OSZAPC_SIZE(_16, op1, op2, result, ins)
|
||||
SET_FLAGS_OSZAPC_SIZE(16, op1, op2, result, ins)
|
||||
#define SET_FLAGS_OSZAPC_32(op1, op2, result, ins) \
|
||||
SET_FLAGS_OSZAPC_SIZE(_32, op1, op2, result, ins)
|
||||
SET_FLAGS_OSZAPC_SIZE(32, op1, op2, result, ins)
|
||||
#if BX_SUPPORT_X86_64
|
||||
#define SET_FLAGS_OSZAPC_64(op1, op2, result, ins) \
|
||||
SET_FLAGS_OSZAPC_SIZE(_64, op1, op2, result, ins)
|
||||
SET_FLAGS_OSZAPC_SIZE(64, op1, op2, result, ins)
|
||||
#endif
|
||||
|
||||
/* op1 and result only */
|
||||
#define SET_FLAGS_OSZAPC_S1_SIZE(size, lf_op1, lf_result, ins) { \
|
||||
BX_CPU_THIS_PTR oszapc.op1##size = lf_op1; \
|
||||
BX_CPU_THIS_PTR oszapc.result##size = lf_result; \
|
||||
BX_CPU_THIS_PTR oszapc.instr = ins; \
|
||||
BX_CPU_THIS_PTR oszapc.op1_##size = (lf_op1); \
|
||||
BX_CPU_THIS_PTR oszapc.result = (Bit##size##s)(lf_result); \
|
||||
BX_CPU_THIS_PTR oszapc.instr = (ins); \
|
||||
BX_CPU_THIS_PTR lf_flags_status = EFlagsOSZAPCMask; \
|
||||
}
|
||||
|
||||
#define SET_FLAGS_OSZAPC_S1_8(op1, result, ins) \
|
||||
SET_FLAGS_OSZAPC_S1_SIZE(_8, op1, result, ins)
|
||||
SET_FLAGS_OSZAPC_S1_SIZE(8, op1, result, ins)
|
||||
#define SET_FLAGS_OSZAPC_S1_16(op1, result, ins) \
|
||||
SET_FLAGS_OSZAPC_S1_SIZE(_16, op1, result, ins)
|
||||
SET_FLAGS_OSZAPC_S1_SIZE(16, op1, result, ins)
|
||||
#define SET_FLAGS_OSZAPC_S1_32(op1, result, ins) \
|
||||
SET_FLAGS_OSZAPC_S1_SIZE(_32, op1, result, ins)
|
||||
SET_FLAGS_OSZAPC_S1_SIZE(32, op1, result, ins)
|
||||
#if BX_SUPPORT_X86_64
|
||||
#define SET_FLAGS_OSZAPC_S1_64(op1, result, ins) \
|
||||
SET_FLAGS_OSZAPC_S1_SIZE(_64, op1, result, ins)
|
||||
SET_FLAGS_OSZAPC_S1_SIZE(64, op1, result, ins)
|
||||
#endif
|
||||
|
||||
/* op2 and result only */
|
||||
#define SET_FLAGS_OSZAPC_S2_SIZE(size, lf_op2, lf_result, ins) { \
|
||||
BX_CPU_THIS_PTR oszapc.op2##size = lf_op2; \
|
||||
BX_CPU_THIS_PTR oszapc.result##size = lf_result; \
|
||||
BX_CPU_THIS_PTR oszapc.instr = ins; \
|
||||
BX_CPU_THIS_PTR oszapc.op2_##size = (lf_op2); \
|
||||
BX_CPU_THIS_PTR oszapc.result = (Bit##size##s)(lf_result); \
|
||||
BX_CPU_THIS_PTR oszapc.instr = (ins); \
|
||||
BX_CPU_THIS_PTR lf_flags_status = EFlagsOSZAPCMask; \
|
||||
}
|
||||
|
||||
#define SET_FLAGS_OSZAPC_S2_8(op2, result, ins) \
|
||||
SET_FLAGS_OSZAPC_S2_SIZE(_8, op2, result, ins)
|
||||
SET_FLAGS_OSZAPC_S2_SIZE(8, op2, result, ins)
|
||||
#define SET_FLAGS_OSZAPC_S2_16(op2, result, ins) \
|
||||
SET_FLAGS_OSZAPC_S2_SIZE(_16, op2, result, ins)
|
||||
SET_FLAGS_OSZAPC_S2_SIZE(16, op2, result, ins)
|
||||
#define SET_FLAGS_OSZAPC_S2_32(op2, result, ins) \
|
||||
SET_FLAGS_OSZAPC_S2_SIZE(_32, op2, result, ins)
|
||||
SET_FLAGS_OSZAPC_S2_SIZE(32, op2, result, ins)
|
||||
#if BX_SUPPORT_X86_64
|
||||
#define SET_FLAGS_OSZAPC_S2_64(op2, result, ins) \
|
||||
SET_FLAGS_OSZAPC_S2_SIZE(_64, op2, result, ins)
|
||||
#endif
|
||||
|
||||
/* op1 and op2 only */
|
||||
#define SET_FLAGS_OSZAPC_S1S2_SIZE(size, lf_op1, lf_op2, ins) { \
|
||||
BX_CPU_THIS_PTR oszapc.op1##size = lf_op1; \
|
||||
BX_CPU_THIS_PTR oszapc.op2##size = lf_op2; \
|
||||
BX_CPU_THIS_PTR oszapc.instr = ins; \
|
||||
BX_CPU_THIS_PTR lf_flags_status = EFlagsOSZAPCMask; \
|
||||
}
|
||||
|
||||
#define SET_FLAGS_OSZAPC_S1S2_8(op1, op2, ins) \
|
||||
SET_FLAGS_OSZAPC_S1S2_SIZE(_8, op1, op2, ins)
|
||||
#define SET_FLAGS_OSZAPC_S1S2_16(op1, op2, ins) \
|
||||
SET_FLAGS_OSZAPC_S1S2_SIZE(_16, op1, op2, ins)
|
||||
#define SET_FLAGS_OSZAPC_S1S2_32(op1, op2, ins) \
|
||||
SET_FLAGS_OSZAPC_S1S2_SIZE(_32, op1, op2, ins)
|
||||
#if BX_SUPPORT_X86_64
|
||||
#define SET_FLAGS_OSZAPC_S1S2_64(op1, op2, ins) \
|
||||
SET_FLAGS_OSZAPC_S1S2_SIZE(_64, op1, op2, ins)
|
||||
SET_FLAGS_OSZAPC_S2_SIZE(64, op2, result, ins)
|
||||
#endif
|
||||
|
||||
/* result only */
|
||||
#define SET_FLAGS_OSZAPC_RESULT_SIZE(size, lf_result, ins) { \
|
||||
BX_CPU_THIS_PTR oszapc.result##size = lf_result; \
|
||||
BX_CPU_THIS_PTR oszapc.instr = ins; \
|
||||
BX_CPU_THIS_PTR oszapc.result = (Bit##size##s)(lf_result); \
|
||||
BX_CPU_THIS_PTR oszapc.instr = (ins); \
|
||||
BX_CPU_THIS_PTR lf_flags_status = EFlagsOSZAPCMask; \
|
||||
}
|
||||
|
||||
#define SET_FLAGS_OSZAPC_RESULT_8(result, ins) \
|
||||
SET_FLAGS_OSZAPC_RESULT_SIZE(_8, result, ins)
|
||||
SET_FLAGS_OSZAPC_RESULT_SIZE(8, result, ins)
|
||||
#define SET_FLAGS_OSZAPC_RESULT_16(result, ins) \
|
||||
SET_FLAGS_OSZAPC_RESULT_SIZE(_16, result, ins)
|
||||
SET_FLAGS_OSZAPC_RESULT_SIZE(16, result, ins)
|
||||
#define SET_FLAGS_OSZAPC_RESULT_32(result, ins) \
|
||||
SET_FLAGS_OSZAPC_RESULT_SIZE(_32, result, ins)
|
||||
SET_FLAGS_OSZAPC_RESULT_SIZE(32, result, ins)
|
||||
#if BX_SUPPORT_X86_64
|
||||
#define SET_FLAGS_OSZAPC_RESULT_64(result, ins) \
|
||||
SET_FLAGS_OSZAPC_RESULT_SIZE(_64, result, ins)
|
||||
SET_FLAGS_OSZAPC_RESULT_SIZE(64, result, ins)
|
||||
#endif
|
||||
|
||||
// *******************
|
||||
@ -3624,20 +3605,20 @@ BX_CPP_INLINE void BX_CPU_C::set_PF_base(Bit8u val)
|
||||
/* result only */
|
||||
#define SET_FLAGS_OSZAP_RESULT_SIZE(size, lf_result, ins) { \
|
||||
force_CF(); \
|
||||
BX_CPU_THIS_PTR oszapc.result##size = lf_result; \
|
||||
BX_CPU_THIS_PTR oszapc.instr = ins; \
|
||||
BX_CPU_THIS_PTR oszapc.result = (Bit##size##s)(lf_result); \
|
||||
BX_CPU_THIS_PTR oszapc.instr = (ins); \
|
||||
BX_CPU_THIS_PTR lf_flags_status = EFlagsOSZAPMask; \
|
||||
}
|
||||
|
||||
#define SET_FLAGS_OSZAP_RESULT_8(result, ins) \
|
||||
SET_FLAGS_OSZAP_RESULT_SIZE(_8, result, ins)
|
||||
SET_FLAGS_OSZAP_RESULT_SIZE(8, result, ins)
|
||||
#define SET_FLAGS_OSZAP_RESULT_16(result, ins) \
|
||||
SET_FLAGS_OSZAP_RESULT_SIZE(_16, result, ins)
|
||||
SET_FLAGS_OSZAP_RESULT_SIZE(16, result, ins)
|
||||
#define SET_FLAGS_OSZAP_RESULT_32(result, ins) \
|
||||
SET_FLAGS_OSZAP_RESULT_SIZE(_32, result, ins)
|
||||
SET_FLAGS_OSZAP_RESULT_SIZE(32, result, ins)
|
||||
#if BX_SUPPORT_X86_64
|
||||
#define SET_FLAGS_OSZAP_RESULT_64(result, ins) \
|
||||
SET_FLAGS_OSZAP_RESULT_SIZE(_64, result, ins)
|
||||
SET_FLAGS_OSZAP_RESULT_SIZE(64, result, ins)
|
||||
#endif
|
||||
|
||||
// transition to new lazy flags code
|
||||
@ -3653,14 +3634,14 @@ BX_CPP_INLINE void BX_CPU_C::set_PF_base(Bit8u val)
|
||||
#endif
|
||||
|
||||
#define SET_FLAGS_OSZAPC_ADD_8(op1_8, op2_8, sum_8) \
|
||||
SET_FLAGS_OSZAPC_S1_8((op1_8), (sum_8), BX_INSTR_ADD8)
|
||||
SET_FLAGS_OSZAPC_8((op1_8), (op2_8), (sum_8), BX_INSTR_ADD8)
|
||||
#define SET_FLAGS_OSZAPC_ADD_16(op1_16, op2_16, sum_16) \
|
||||
SET_FLAGS_OSZAPC_S1_16((op1_16), (sum_16), BX_INSTR_ADD16)
|
||||
SET_FLAGS_OSZAPC_16((op1_16), (op2_16), (sum_16), BX_INSTR_ADD16)
|
||||
#define SET_FLAGS_OSZAPC_ADD_32(op1_32, op2_32, sum_32) \
|
||||
SET_FLAGS_OSZAPC_S1_32((op1_32), (sum_32), BX_INSTR_ADD32)
|
||||
SET_FLAGS_OSZAPC_32((op1_32), (op2_32), (sum_32), BX_INSTR_ADD32)
|
||||
#if BX_SUPPORT_X86_64
|
||||
#define SET_FLAGS_OSZAPC_ADD_64(op1_64, op2_64, sum_64) \
|
||||
SET_FLAGS_OSZAPC_S1_64((op1_64), (sum_64), BX_INSTR_ADD64)
|
||||
SET_FLAGS_OSZAPC_64((op1_64), (op2_64), (sum_64), BX_INSTR_ADD64)
|
||||
#endif
|
||||
|
||||
#define SET_FLAGS_OSZAPC_SUB_8(op1_8, op2_8, diff_8) \
|
||||
@ -3675,25 +3656,25 @@ BX_CPP_INLINE void BX_CPU_C::set_PF_base(Bit8u val)
|
||||
#endif
|
||||
|
||||
#define SET_FLAGS_OSZAPC_INC_8(result) \
|
||||
SET_FLAGS_OSZAP_RESULT_SIZE(_8, (result), BX_INSTR_INC8)
|
||||
SET_FLAGS_OSZAP_RESULT_SIZE(8, (result), BX_INSTR_INC8)
|
||||
#define SET_FLAGS_OSZAPC_INC_16(result) \
|
||||
SET_FLAGS_OSZAP_RESULT_SIZE(_16, (result), BX_INSTR_INC16)
|
||||
SET_FLAGS_OSZAP_RESULT_SIZE(16, (result), BX_INSTR_INC16)
|
||||
#define SET_FLAGS_OSZAPC_INC_32(result) \
|
||||
SET_FLAGS_OSZAP_RESULT_SIZE(_32, (result), BX_INSTR_INC32)
|
||||
SET_FLAGS_OSZAP_RESULT_SIZE(32, (result), BX_INSTR_INC32)
|
||||
#if BX_SUPPORT_X86_64
|
||||
#define SET_FLAGS_OSZAPC_INC_64(result) \
|
||||
SET_FLAGS_OSZAP_RESULT_SIZE(_64, (result), BX_INSTR_INC64)
|
||||
SET_FLAGS_OSZAP_RESULT_SIZE(64, (result), BX_INSTR_INC64)
|
||||
#endif
|
||||
|
||||
#define SET_FLAGS_OSZAPC_DEC_8(result) \
|
||||
SET_FLAGS_OSZAP_RESULT_SIZE(_8, (result), BX_INSTR_DEC8)
|
||||
SET_FLAGS_OSZAP_RESULT_SIZE(8, (result), BX_INSTR_DEC8)
|
||||
#define SET_FLAGS_OSZAPC_DEC_16(result) \
|
||||
SET_FLAGS_OSZAP_RESULT_SIZE(_16, (result), BX_INSTR_DEC16)
|
||||
SET_FLAGS_OSZAP_RESULT_SIZE(16, (result), BX_INSTR_DEC16)
|
||||
#define SET_FLAGS_OSZAPC_DEC_32(result) \
|
||||
SET_FLAGS_OSZAP_RESULT_SIZE(_32, (result), BX_INSTR_DEC32)
|
||||
SET_FLAGS_OSZAP_RESULT_SIZE(32, (result), BX_INSTR_DEC32)
|
||||
#if BX_SUPPORT_X86_64
|
||||
#define SET_FLAGS_OSZAPC_DEC_64(result) \
|
||||
SET_FLAGS_OSZAP_RESULT_SIZE(_64, (result), BX_INSTR_DEC64)
|
||||
SET_FLAGS_OSZAP_RESULT_SIZE(64, (result), BX_INSTR_DEC64)
|
||||
#endif
|
||||
|
||||
IMPLEMENT_EFLAG_ACCESSOR (ID, 21)
|
||||
@ -3712,16 +3693,16 @@ IMPLEMENT_EFLAG_ACCESSOR (DF, 10)
|
||||
IMPLEMENT_EFLAG_ACCESSOR (IF, 9)
|
||||
IMPLEMENT_EFLAG_ACCESSOR (TF, 8)
|
||||
|
||||
|
||||
// <TAG-DEFINES-DECODE-START>
|
||||
//
|
||||
// For decoding...
|
||||
//
|
||||
|
||||
#define BX_TASK_FROM_JUMP 10
|
||||
#define BX_TASK_FROM_CALL_OR_INT 11
|
||||
#define BX_TASK_FROM_IRET 12
|
||||
|
||||
// <TAG-DEFINES-DECODE-START>
|
||||
|
||||
//
|
||||
// For decoding...
|
||||
//
|
||||
|
||||
// If the Immediate bit is set, the lowest 3 bits of the attribute
|
||||
// specify which kinds of immediate data a required by instruction.
|
||||
|
||||
@ -3770,6 +3751,7 @@ IMPLEMENT_EFLAG_ACCESSOR (TF, 8)
|
||||
#define BxGroup14 BxGroupN
|
||||
#define BxGroup15 BxGroupN
|
||||
#define BxGroup16 BxGroupN
|
||||
|
||||
// <TAG-DEFINES-DECODE-END>
|
||||
|
||||
// Can be used as LHS or RHS.
|
||||
|
@ -1,5 +1,5 @@
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
// $Id: lazy_flags.cc,v 1.39 2007-12-04 19:27:23 sshwarts Exp $
|
||||
// $Id: lazy_flags.cc,v 1.40 2007-12-05 06:17:09 sshwarts Exp $
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2001 MandrakeSoft S.A.
|
||||
@ -54,8 +54,10 @@ const bx_bool bx_parity_lookup[256] = {
|
||||
1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1
|
||||
};
|
||||
|
||||
// set to 1 if you want to update eflags state after lazy flag evaluation
|
||||
#define UPDATE_EFLAGS_LAZY 0
|
||||
#define result_8 ((Bit8u) (BX_CPU_THIS_PTR oszapc.result))
|
||||
#define result_16 ((Bit16u)(BX_CPU_THIS_PTR oszapc.result))
|
||||
#define result_32 ((Bit32u)(BX_CPU_THIS_PTR oszapc.result))
|
||||
#define result_64 (BX_CPU_THIS_PTR oszapc.result)
|
||||
|
||||
bx_bool BX_CPU_C::get_CFLazy(void)
|
||||
{
|
||||
@ -63,43 +65,35 @@ bx_bool BX_CPU_C::get_CFLazy(void)
|
||||
|
||||
switch (BX_CPU_THIS_PTR oszapc.instr) {
|
||||
case BX_INSTR_ADD8:
|
||||
cf = (BX_CPU_THIS_PTR oszapc.result_8 <
|
||||
BX_CPU_THIS_PTR oszapc.op1_8);
|
||||
cf = (result_8 < BX_CPU_THIS_PTR oszapc.op1_8);
|
||||
break;
|
||||
case BX_INSTR_ADD16:
|
||||
cf = (BX_CPU_THIS_PTR oszapc.result_16 <
|
||||
BX_CPU_THIS_PTR oszapc.op1_16);
|
||||
cf = (result_16 < BX_CPU_THIS_PTR oszapc.op1_16);
|
||||
break;
|
||||
case BX_INSTR_ADD32:
|
||||
cf = (BX_CPU_THIS_PTR oszapc.result_32 <
|
||||
BX_CPU_THIS_PTR oszapc.op1_32);
|
||||
cf = (result_32 < BX_CPU_THIS_PTR oszapc.op1_32);
|
||||
break;
|
||||
#if BX_SUPPORT_X86_64
|
||||
case BX_INSTR_ADD64:
|
||||
cf = (BX_CPU_THIS_PTR oszapc.result_64 <
|
||||
BX_CPU_THIS_PTR oszapc.op1_64);
|
||||
cf = (result_64 < BX_CPU_THIS_PTR oszapc.op1_64);
|
||||
break;
|
||||
#endif
|
||||
// used only if CF = 1 when executing ADC instruction
|
||||
case BX_INSTR_ADC8:
|
||||
cf = (BX_CPU_THIS_PTR oszapc.result_8 <=
|
||||
BX_CPU_THIS_PTR oszapc.op1_8);
|
||||
cf = (result_8 <= BX_CPU_THIS_PTR oszapc.op1_8);
|
||||
break;
|
||||
// used only if CF = 1 when executing ADC instruction
|
||||
case BX_INSTR_ADC16:
|
||||
cf = (BX_CPU_THIS_PTR oszapc.result_16 <=
|
||||
BX_CPU_THIS_PTR oszapc.op1_16);
|
||||
cf = (result_16 <= BX_CPU_THIS_PTR oszapc.op1_16);
|
||||
break;
|
||||
// used only if CF = 1 when executing ADC instruction
|
||||
case BX_INSTR_ADC32:
|
||||
cf = (BX_CPU_THIS_PTR oszapc.result_32 <=
|
||||
BX_CPU_THIS_PTR oszapc.op1_32);
|
||||
cf = (result_32 <= BX_CPU_THIS_PTR oszapc.op1_32);
|
||||
break;
|
||||
#if BX_SUPPORT_X86_64
|
||||
// used only if CF = 1 when executing ADC instruction
|
||||
case BX_INSTR_ADC64:
|
||||
cf = (BX_CPU_THIS_PTR oszapc.result_64 <=
|
||||
BX_CPU_THIS_PTR oszapc.op1_64);
|
||||
cf = (result_64 <= BX_CPU_THIS_PTR oszapc.op1_64);
|
||||
break;
|
||||
#endif
|
||||
case BX_INSTR_SUB8:
|
||||
@ -122,38 +116,38 @@ bx_bool BX_CPU_C::get_CFLazy(void)
|
||||
#endif
|
||||
// used only if CF = 1 when executing SBB instruction
|
||||
case BX_INSTR_SBB8:
|
||||
cf = (BX_CPU_THIS_PTR oszapc.op1_8 < BX_CPU_THIS_PTR oszapc.result_8) ||
|
||||
cf = (BX_CPU_THIS_PTR oszapc.op1_8 < result_8) ||
|
||||
(BX_CPU_THIS_PTR oszapc.op2_8==0xff);
|
||||
break;
|
||||
// used only if CF = 1 when executing SBB instruction
|
||||
case BX_INSTR_SBB16:
|
||||
cf = (BX_CPU_THIS_PTR oszapc.op1_16 < BX_CPU_THIS_PTR oszapc.result_16) ||
|
||||
cf = (BX_CPU_THIS_PTR oszapc.op1_16 < result_16) ||
|
||||
(BX_CPU_THIS_PTR oszapc.op2_16==0xffff);
|
||||
break;
|
||||
// used only if CF = 1 when executing SBB instruction
|
||||
case BX_INSTR_SBB32:
|
||||
cf = (BX_CPU_THIS_PTR oszapc.op1_32 < BX_CPU_THIS_PTR oszapc.result_32) ||
|
||||
cf = (BX_CPU_THIS_PTR oszapc.op1_32 < result_32) ||
|
||||
(BX_CPU_THIS_PTR oszapc.op2_32==0xffffffff);
|
||||
break;
|
||||
#if BX_SUPPORT_X86_64
|
||||
// used only if CF = 1 when executing SBB instruction
|
||||
case BX_INSTR_SBB64:
|
||||
cf = (BX_CPU_THIS_PTR oszapc.op1_64 < BX_CPU_THIS_PTR oszapc.result_64) ||
|
||||
cf = (BX_CPU_THIS_PTR oszapc.op1_64 < result_64) ||
|
||||
(BX_CPU_THIS_PTR oszapc.op2_64==BX_CONST64(0xffffffffffffffff));
|
||||
break;
|
||||
#endif
|
||||
case BX_INSTR_NEG8:
|
||||
cf = (BX_CPU_THIS_PTR oszapc.result_8 != 0);
|
||||
cf = (result_8 != 0);
|
||||
break;
|
||||
case BX_INSTR_NEG16:
|
||||
cf = (BX_CPU_THIS_PTR oszapc.result_16 != 0);
|
||||
cf = (result_16 != 0);
|
||||
break;
|
||||
case BX_INSTR_NEG32:
|
||||
cf = (BX_CPU_THIS_PTR oszapc.result_32 != 0);
|
||||
cf = (result_32 != 0);
|
||||
break;
|
||||
#if BX_SUPPORT_X86_64
|
||||
case BX_INSTR_NEG64:
|
||||
cf = (BX_CPU_THIS_PTR oszapc.result_64 != 0);
|
||||
cf = (result_64 != 0);
|
||||
break;
|
||||
#endif
|
||||
case BX_INSTR_LOGIC8:
|
||||
@ -234,28 +228,28 @@ bx_bool BX_CPU_C::get_CFLazy(void)
|
||||
break;
|
||||
#endif
|
||||
case BX_INSTR_IMUL8:
|
||||
cf = ! ((BX_CPU_THIS_PTR oszapc.result_8 < 0x80 &&
|
||||
cf = ! ((result_8 < 0x80 &&
|
||||
BX_CPU_THIS_PTR oszapc.op2_8 == 0) ||
|
||||
((BX_CPU_THIS_PTR oszapc.result_8 & 0x80) &&
|
||||
((result_8 & 0x80) &&
|
||||
BX_CPU_THIS_PTR oszapc.op2_8 == 0xff));
|
||||
break;
|
||||
case BX_INSTR_IMUL16:
|
||||
cf = ! ((BX_CPU_THIS_PTR oszapc.result_16 < 0x8000 &&
|
||||
cf = ! ((result_16 < 0x8000 &&
|
||||
BX_CPU_THIS_PTR oszapc.op2_16 == 0) ||
|
||||
((BX_CPU_THIS_PTR oszapc.result_16 & 0x8000) &&
|
||||
((result_16 & 0x8000) &&
|
||||
BX_CPU_THIS_PTR oszapc.op2_16 == 0xffff));
|
||||
break;
|
||||
case BX_INSTR_IMUL32:
|
||||
cf = ! ((BX_CPU_THIS_PTR oszapc.result_32 < 0x80000000 &&
|
||||
cf = ! ((result_32 < 0x80000000 &&
|
||||
BX_CPU_THIS_PTR oszapc.op2_32 == 0) ||
|
||||
((BX_CPU_THIS_PTR oszapc.result_32 & 0x80000000) &&
|
||||
((result_32 & 0x80000000) &&
|
||||
BX_CPU_THIS_PTR oszapc.op2_32 == 0xffffffff));
|
||||
break;
|
||||
#if BX_SUPPORT_X86_64
|
||||
case BX_INSTR_IMUL64:
|
||||
cf = ! ((BX_CPU_THIS_PTR oszapc.result_64 < BX_CONST64(0x8000000000000000) &&
|
||||
cf = ! ((result_64 < BX_CONST64(0x8000000000000000) &&
|
||||
BX_CPU_THIS_PTR oszapc.op2_64 == 0) ||
|
||||
((BX_CPU_THIS_PTR oszapc.result_64 & BX_CONST64(0x8000000000000000)) &&
|
||||
((result_64 & BX_CONST64(0x8000000000000000)) &&
|
||||
BX_CPU_THIS_PTR oszapc.op2_64 == BX_CONST64(0xffffffffffffffff)));
|
||||
break;
|
||||
#endif
|
||||
@ -279,11 +273,6 @@ bx_bool BX_CPU_C::get_CFLazy(void)
|
||||
(unsigned) BX_CPU_THIS_PTR oszapc.instr));
|
||||
}
|
||||
|
||||
#if UPDATE_EFLAGS_LAZY
|
||||
BX_CPU_THIS_PTR lf_flags_status &= ~EFlagsCFMask;
|
||||
BX_CPU_THIS_PTR eflags.val32 &= ~(1<<0);
|
||||
BX_CPU_THIS_PTR eflags.val32 |= (!!cf)<<0;
|
||||
#endif
|
||||
return(cf);
|
||||
}
|
||||
|
||||
@ -293,93 +282,59 @@ bx_bool BX_CPU_C::get_AFLazy(void)
|
||||
|
||||
switch (BX_CPU_THIS_PTR oszapc.instr) {
|
||||
case BX_INSTR_ADD8:
|
||||
// restore op1 and fall through into AF calculation
|
||||
BX_CPU_THIS_PTR oszapc.op2_8 =
|
||||
BX_CPU_THIS_PTR oszapc.result_8 - BX_CPU_THIS_PTR oszapc.op1_8;
|
||||
case BX_INSTR_ADC8:
|
||||
case BX_INSTR_SUB8:
|
||||
case BX_INSTR_SBB8:
|
||||
af = ((BX_CPU_THIS_PTR oszapc.op1_8 ^
|
||||
BX_CPU_THIS_PTR oszapc.op2_8) ^
|
||||
BX_CPU_THIS_PTR oszapc.result_8) & 0x10;
|
||||
BX_CPU_THIS_PTR oszapc.op2_8) ^ result_8) & 0x10;
|
||||
break;
|
||||
case BX_INSTR_ADD16:
|
||||
// restore op1 and fall through into AF calculation
|
||||
BX_CPU_THIS_PTR oszapc.op2_16 =
|
||||
BX_CPU_THIS_PTR oszapc.result_16 - BX_CPU_THIS_PTR oszapc.op1_16;
|
||||
case BX_INSTR_ADC16:
|
||||
case BX_INSTR_SUB16:
|
||||
case BX_INSTR_SBB16:
|
||||
af = ((BX_CPU_THIS_PTR oszapc.op1_16 ^
|
||||
BX_CPU_THIS_PTR oszapc.op2_16) ^
|
||||
BX_CPU_THIS_PTR oszapc.result_16) & 0x10;
|
||||
BX_CPU_THIS_PTR oszapc.op2_16) ^ result_16) & 0x10;
|
||||
break;
|
||||
case BX_INSTR_ADD32:
|
||||
// restore op1 and fall through into AF calculation
|
||||
BX_CPU_THIS_PTR oszapc.op2_32 =
|
||||
BX_CPU_THIS_PTR oszapc.result_32 - BX_CPU_THIS_PTR oszapc.op1_32;
|
||||
case BX_INSTR_ADC32:
|
||||
case BX_INSTR_SUB32:
|
||||
case BX_INSTR_SBB32:
|
||||
af = ((BX_CPU_THIS_PTR oszapc.op1_32 ^
|
||||
BX_CPU_THIS_PTR oszapc.op2_32) ^
|
||||
BX_CPU_THIS_PTR oszapc.result_32) & 0x10;
|
||||
BX_CPU_THIS_PTR oszapc.op2_32) ^ result_32) & 0x10;
|
||||
break;
|
||||
#if BX_SUPPORT_X86_64
|
||||
case BX_INSTR_ADD64:
|
||||
// restore op1 and fall through into AF calculation
|
||||
BX_CPU_THIS_PTR oszapc.op2_64 =
|
||||
BX_CPU_THIS_PTR oszapc.result_64 - BX_CPU_THIS_PTR oszapc.op1_64;
|
||||
case BX_INSTR_ADC64:
|
||||
case BX_INSTR_SUB64:
|
||||
case BX_INSTR_SBB64:
|
||||
af = ((BX_CPU_THIS_PTR oszapc.op1_64 ^
|
||||
BX_CPU_THIS_PTR oszapc.op2_64) ^
|
||||
BX_CPU_THIS_PTR oszapc.result_64) & 0x10;
|
||||
BX_CPU_THIS_PTR oszapc.op2_64) ^ result_64) & 0x10;
|
||||
break;
|
||||
#endif
|
||||
case BX_INSTR_NEG8:
|
||||
af = (BX_CPU_THIS_PTR oszapc.result_8 & 0x0f) != 0;
|
||||
break;
|
||||
case BX_INSTR_NEG16:
|
||||
af = (BX_CPU_THIS_PTR oszapc.result_16 & 0x0f) != 0;
|
||||
break;
|
||||
case BX_INSTR_NEG32:
|
||||
af = (BX_CPU_THIS_PTR oszapc.result_32 & 0x0f) != 0;
|
||||
break;
|
||||
#if BX_SUPPORT_X86_64
|
||||
case BX_INSTR_NEG64:
|
||||
af = (BX_CPU_THIS_PTR oszapc.result_64 & 0x0f) != 0;
|
||||
break;
|
||||
#endif
|
||||
af = (result_8 & 0xf) != 0;
|
||||
break;
|
||||
case BX_INSTR_INC8:
|
||||
af = (BX_CPU_THIS_PTR oszapc.result_8 & 0x0f) == 0;
|
||||
break;
|
||||
case BX_INSTR_INC16:
|
||||
af = (BX_CPU_THIS_PTR oszapc.result_16 & 0x0f) == 0;
|
||||
break;
|
||||
case BX_INSTR_INC32:
|
||||
af = (BX_CPU_THIS_PTR oszapc.result_32 & 0x0f) == 0;
|
||||
break;
|
||||
#if BX_SUPPORT_X86_64
|
||||
case BX_INSTR_INC64:
|
||||
af = (BX_CPU_THIS_PTR oszapc.result_64 & 0x0f) == 0;
|
||||
break;
|
||||
#endif
|
||||
af = (result_8 & 0xf) == 0;
|
||||
break;
|
||||
case BX_INSTR_DEC8:
|
||||
af = (BX_CPU_THIS_PTR oszapc.result_8 & 0x0f) == 0x0f;
|
||||
break;
|
||||
case BX_INSTR_DEC16:
|
||||
af = (BX_CPU_THIS_PTR oszapc.result_16 & 0x0f) == 0x0f;
|
||||
break;
|
||||
case BX_INSTR_DEC32:
|
||||
af = (BX_CPU_THIS_PTR oszapc.result_32 & 0x0f) == 0x0f;
|
||||
break;
|
||||
#if BX_SUPPORT_X86_64
|
||||
case BX_INSTR_DEC64:
|
||||
af = (BX_CPU_THIS_PTR oszapc.result_64 & 0x0f) == 0x0f;
|
||||
break;
|
||||
#endif
|
||||
af = (result_8 & 0xf) == 0xf;
|
||||
break;
|
||||
case BX_INSTR_LOGIC8:
|
||||
case BX_INSTR_LOGIC16:
|
||||
case BX_INSTR_LOGIC32:
|
||||
@ -415,176 +370,18 @@ bx_bool BX_CPU_C::get_AFLazy(void)
|
||||
af = 0; // Keep compiler quiet.
|
||||
BX_PANIC(("get_AF: OSZAPC: unknown instr %u", (unsigned) BX_CPU_THIS_PTR oszapc.instr));
|
||||
}
|
||||
#if UPDATE_EFLAGS_LAZY
|
||||
BX_CPU_THIS_PTR lf_flags_status &= ~EFlagsAFMask;
|
||||
BX_CPU_THIS_PTR eflags.val32 &= ~(1<<4);
|
||||
BX_CPU_THIS_PTR eflags.val32 |= (!!af)<<4;
|
||||
#endif
|
||||
|
||||
return(af);
|
||||
}
|
||||
|
||||
bx_bool BX_CPU_C::get_ZFLazy(void)
|
||||
{
|
||||
unsigned zf;
|
||||
|
||||
switch (BX_CPU_THIS_PTR oszapc.instr) {
|
||||
case BX_INSTR_LOGIC8:
|
||||
case BX_INSTR_ADD8:
|
||||
case BX_INSTR_ADC8:
|
||||
case BX_INSTR_SUB8:
|
||||
case BX_INSTR_SBB8:
|
||||
case BX_INSTR_NEG8:
|
||||
case BX_INSTR_SAR8:
|
||||
case BX_INSTR_SHR8:
|
||||
case BX_INSTR_SHL8:
|
||||
case BX_INSTR_IMUL8:
|
||||
case BX_INSTR_MUL8:
|
||||
case BX_INSTR_INC8:
|
||||
case BX_INSTR_DEC8:
|
||||
zf = (BX_CPU_THIS_PTR oszapc.result_8 == 0);
|
||||
break;
|
||||
case BX_INSTR_LOGIC16:
|
||||
case BX_INSTR_ADD16:
|
||||
case BX_INSTR_ADC16:
|
||||
case BX_INSTR_SUB16:
|
||||
case BX_INSTR_SBB16:
|
||||
case BX_INSTR_NEG16:
|
||||
case BX_INSTR_SAR16:
|
||||
case BX_INSTR_SHR16:
|
||||
case BX_INSTR_SHRD16:
|
||||
case BX_INSTR_SHL16:
|
||||
case BX_INSTR_IMUL16:
|
||||
case BX_INSTR_MUL16:
|
||||
case BX_INSTR_INC16:
|
||||
case BX_INSTR_DEC16:
|
||||
zf = (BX_CPU_THIS_PTR oszapc.result_16 == 0);
|
||||
break;
|
||||
case BX_INSTR_LOGIC32:
|
||||
case BX_INSTR_ADD32:
|
||||
case BX_INSTR_ADC32:
|
||||
case BX_INSTR_SUB32:
|
||||
case BX_INSTR_SBB32:
|
||||
case BX_INSTR_NEG32:
|
||||
case BX_INSTR_SAR32:
|
||||
case BX_INSTR_SHR32:
|
||||
case BX_INSTR_SHRD32:
|
||||
case BX_INSTR_SHL32:
|
||||
case BX_INSTR_IMUL32:
|
||||
case BX_INSTR_MUL32:
|
||||
case BX_INSTR_INC32:
|
||||
case BX_INSTR_DEC32:
|
||||
zf = (BX_CPU_THIS_PTR oszapc.result_32 == 0);
|
||||
break;
|
||||
#if BX_SUPPORT_X86_64
|
||||
case BX_INSTR_LOGIC64:
|
||||
case BX_INSTR_ADD64:
|
||||
case BX_INSTR_ADC64:
|
||||
case BX_INSTR_SUB64:
|
||||
case BX_INSTR_SBB64:
|
||||
case BX_INSTR_NEG64:
|
||||
case BX_INSTR_SAR64:
|
||||
case BX_INSTR_SHR64:
|
||||
case BX_INSTR_SHRD64:
|
||||
case BX_INSTR_SHL64:
|
||||
case BX_INSTR_IMUL64:
|
||||
case BX_INSTR_MUL64:
|
||||
case BX_INSTR_INC64:
|
||||
case BX_INSTR_DEC64:
|
||||
zf = (BX_CPU_THIS_PTR oszapc.result_64 == 0);
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
zf = 0;
|
||||
BX_PANIC(("get_ZF: OSZAPC: unknown instr"));
|
||||
}
|
||||
#if UPDATE_EFLAGS_LAZY
|
||||
BX_CPU_THIS_PTR lf_flags_status &= ~EFlagsZFMask;
|
||||
BX_CPU_THIS_PTR eflags.val32 &= ~(1<<6);
|
||||
BX_CPU_THIS_PTR eflags.val32 |= zf<<6; // zf always exactly 0 or 1.
|
||||
#endif
|
||||
return(zf);
|
||||
return (BX_CPU_THIS_PTR oszapc.result == 0);
|
||||
}
|
||||
|
||||
bx_bool BX_CPU_C::get_SFLazy(void)
|
||||
{
|
||||
unsigned sf;
|
||||
|
||||
switch (BX_CPU_THIS_PTR oszapc.instr) {
|
||||
case BX_INSTR_LOGIC8:
|
||||
case BX_INSTR_ADD8:
|
||||
case BX_INSTR_ADC8:
|
||||
case BX_INSTR_SUB8:
|
||||
case BX_INSTR_SBB8:
|
||||
case BX_INSTR_NEG8:
|
||||
case BX_INSTR_SAR8:
|
||||
case BX_INSTR_SHR8:
|
||||
case BX_INSTR_SHL8:
|
||||
case BX_INSTR_IMUL8:
|
||||
case BX_INSTR_MUL8:
|
||||
case BX_INSTR_INC8:
|
||||
case BX_INSTR_DEC8:
|
||||
sf = (BX_CPU_THIS_PTR oszapc.result_8 >= 0x80);
|
||||
break;
|
||||
case BX_INSTR_LOGIC16:
|
||||
case BX_INSTR_ADD16:
|
||||
case BX_INSTR_ADC16:
|
||||
case BX_INSTR_SUB16:
|
||||
case BX_INSTR_SBB16:
|
||||
case BX_INSTR_NEG16:
|
||||
case BX_INSTR_SAR16:
|
||||
case BX_INSTR_SHR16:
|
||||
case BX_INSTR_SHRD16:
|
||||
case BX_INSTR_SHL16:
|
||||
case BX_INSTR_IMUL16:
|
||||
case BX_INSTR_MUL16:
|
||||
case BX_INSTR_INC16:
|
||||
case BX_INSTR_DEC16:
|
||||
sf = (BX_CPU_THIS_PTR oszapc.result_16 >= 0x8000);
|
||||
break;
|
||||
case BX_INSTR_LOGIC32:
|
||||
case BX_INSTR_ADD32:
|
||||
case BX_INSTR_ADC32:
|
||||
case BX_INSTR_SUB32:
|
||||
case BX_INSTR_SBB32:
|
||||
case BX_INSTR_NEG32:
|
||||
case BX_INSTR_SAR32:
|
||||
case BX_INSTR_SHR32:
|
||||
case BX_INSTR_SHRD32:
|
||||
case BX_INSTR_SHL32:
|
||||
case BX_INSTR_IMUL32:
|
||||
case BX_INSTR_MUL32:
|
||||
case BX_INSTR_INC32:
|
||||
case BX_INSTR_DEC32:
|
||||
sf = (BX_CPU_THIS_PTR oszapc.result_32 >= 0x80000000);
|
||||
break;
|
||||
#if BX_SUPPORT_X86_64
|
||||
case BX_INSTR_LOGIC64:
|
||||
case BX_INSTR_ADD64:
|
||||
case BX_INSTR_ADC64:
|
||||
case BX_INSTR_SUB64:
|
||||
case BX_INSTR_SBB64:
|
||||
case BX_INSTR_NEG64:
|
||||
case BX_INSTR_SAR64:
|
||||
case BX_INSTR_SHR64:
|
||||
case BX_INSTR_SHRD64:
|
||||
case BX_INSTR_SHL64:
|
||||
case BX_INSTR_IMUL64:
|
||||
case BX_INSTR_MUL64:
|
||||
case BX_INSTR_INC64:
|
||||
case BX_INSTR_DEC64:
|
||||
sf = (BX_CPU_THIS_PTR oszapc.result_64 >= BX_CONST64(0x8000000000000000));
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
sf = 0; // Keep compiler quiet.
|
||||
BX_PANIC(("get_SF: OSZAPC: unknown instr"));
|
||||
}
|
||||
#if UPDATE_EFLAGS_LAZY
|
||||
BX_CPU_THIS_PTR lf_flags_status &= ~EFlagsSFMask;
|
||||
BX_CPU_THIS_PTR eflags.val32 &= ~(1<<7);
|
||||
BX_CPU_THIS_PTR eflags.val32 |= (!!sf)<<7;
|
||||
#endif
|
||||
return(sf);
|
||||
return (BX_CPU_THIS_PTR oszapc.result >> BX_LF_SIGN_BIT);
|
||||
}
|
||||
|
||||
#define GET_ADD_OVERFLOW(op1, op2, result, mask) \
|
||||
@ -599,59 +396,55 @@ bx_bool BX_CPU_C::get_OFLazy(void)
|
||||
|
||||
switch (BX_CPU_THIS_PTR oszapc.instr) {
|
||||
case BX_INSTR_ADD8:
|
||||
// restore op1 and fall through into OF calculation
|
||||
BX_CPU_THIS_PTR oszapc.op2_8 =
|
||||
BX_CPU_THIS_PTR oszapc.result_8 - BX_CPU_THIS_PTR oszapc.op1_8;
|
||||
case BX_INSTR_ADC8:
|
||||
of = GET_ADD_OVERFLOW(BX_CPU_THIS_PTR oszapc.op1_8, BX_CPU_THIS_PTR oszapc.op2_8,
|
||||
BX_CPU_THIS_PTR oszapc.result_8, 0x80);
|
||||
of = GET_ADD_OVERFLOW(BX_CPU_THIS_PTR oszapc.op1_8,
|
||||
BX_CPU_THIS_PTR oszapc.op2_8,
|
||||
result_8, 0x80);
|
||||
break;
|
||||
case BX_INSTR_ADD16:
|
||||
// restore op1 and fall through into OF calculation
|
||||
BX_CPU_THIS_PTR oszapc.op2_16 =
|
||||
BX_CPU_THIS_PTR oszapc.result_16 - BX_CPU_THIS_PTR oszapc.op1_16;
|
||||
case BX_INSTR_ADC16:
|
||||
of = GET_ADD_OVERFLOW(BX_CPU_THIS_PTR oszapc.op1_16, BX_CPU_THIS_PTR oszapc.op2_16,
|
||||
BX_CPU_THIS_PTR oszapc.result_16, 0x8000);
|
||||
of = GET_ADD_OVERFLOW(BX_CPU_THIS_PTR oszapc.op1_16,
|
||||
BX_CPU_THIS_PTR oszapc.op2_16,
|
||||
result_16, 0x8000);
|
||||
break;
|
||||
case BX_INSTR_ADD32:
|
||||
// restore op1 and fall through into OF calculation
|
||||
BX_CPU_THIS_PTR oszapc.op2_32 =
|
||||
BX_CPU_THIS_PTR oszapc.result_32 - BX_CPU_THIS_PTR oszapc.op1_32;
|
||||
case BX_INSTR_ADC32:
|
||||
of = GET_ADD_OVERFLOW(BX_CPU_THIS_PTR oszapc.op1_32, BX_CPU_THIS_PTR oszapc.op2_32,
|
||||
BX_CPU_THIS_PTR oszapc.result_32, 0x80000000);
|
||||
of = GET_ADD_OVERFLOW(BX_CPU_THIS_PTR oszapc.op1_32,
|
||||
BX_CPU_THIS_PTR oszapc.op2_32,
|
||||
result_32, 0x80000000);
|
||||
break;
|
||||
#if BX_SUPPORT_X86_64
|
||||
case BX_INSTR_ADD64:
|
||||
// restore op1 and fall through into OF calculation
|
||||
BX_CPU_THIS_PTR oszapc.op2_64 =
|
||||
BX_CPU_THIS_PTR oszapc.result_64 - BX_CPU_THIS_PTR oszapc.op1_64;
|
||||
case BX_INSTR_ADC64:
|
||||
of = GET_ADD_OVERFLOW(BX_CPU_THIS_PTR oszapc.op1_64, BX_CPU_THIS_PTR oszapc.op2_64,
|
||||
BX_CPU_THIS_PTR oszapc.result_64, BX_CONST64(0x8000000000000000));
|
||||
of = GET_ADD_OVERFLOW(BX_CPU_THIS_PTR oszapc.op1_64,
|
||||
BX_CPU_THIS_PTR oszapc.op2_64,
|
||||
result_64, BX_CONST64(0x8000000000000000));
|
||||
break;
|
||||
#endif
|
||||
case BX_INSTR_SUB8:
|
||||
case BX_INSTR_SBB8:
|
||||
of = GET_SUB_OVERFLOW(BX_CPU_THIS_PTR oszapc.op1_8, BX_CPU_THIS_PTR oszapc.op2_8,
|
||||
BX_CPU_THIS_PTR oszapc.result_8, 0x80);
|
||||
of = GET_SUB_OVERFLOW(BX_CPU_THIS_PTR oszapc.op1_8,
|
||||
BX_CPU_THIS_PTR oszapc.op2_8,
|
||||
result_8, 0x80);
|
||||
break;
|
||||
case BX_INSTR_SUB16:
|
||||
case BX_INSTR_SBB16:
|
||||
of = GET_SUB_OVERFLOW(BX_CPU_THIS_PTR oszapc.op1_16, BX_CPU_THIS_PTR oszapc.op2_16,
|
||||
BX_CPU_THIS_PTR oszapc.result_16, 0x8000);
|
||||
of = GET_SUB_OVERFLOW(BX_CPU_THIS_PTR oszapc.op1_16,
|
||||
BX_CPU_THIS_PTR oszapc.op2_16,
|
||||
result_16, 0x8000);
|
||||
break;
|
||||
case BX_INSTR_SUB32:
|
||||
case BX_INSTR_SBB32:
|
||||
of = GET_SUB_OVERFLOW(BX_CPU_THIS_PTR oszapc.op1_32, BX_CPU_THIS_PTR oszapc.op2_32,
|
||||
BX_CPU_THIS_PTR oszapc.result_32, 0x80000000);
|
||||
of = GET_SUB_OVERFLOW(BX_CPU_THIS_PTR oszapc.op1_32,
|
||||
BX_CPU_THIS_PTR oszapc.op2_32,
|
||||
result_32, 0x80000000);
|
||||
break;
|
||||
#if BX_SUPPORT_X86_64
|
||||
case BX_INSTR_SUB64:
|
||||
case BX_INSTR_SBB64:
|
||||
of = GET_SUB_OVERFLOW(BX_CPU_THIS_PTR oszapc.op1_64, BX_CPU_THIS_PTR oszapc.op2_64,
|
||||
BX_CPU_THIS_PTR oszapc.result_64, BX_CONST64(0x8000000000000000));
|
||||
of = GET_SUB_OVERFLOW(BX_CPU_THIS_PTR oszapc.op1_64,
|
||||
BX_CPU_THIS_PTR oszapc.op2_64,
|
||||
result_64, BX_CONST64(0x8000000000000000));
|
||||
break;
|
||||
#endif
|
||||
case BX_INSTR_LOGIC8:
|
||||
@ -694,82 +487,71 @@ bx_bool BX_CPU_C::get_OFLazy(void)
|
||||
#endif
|
||||
case BX_INSTR_SHRD16:
|
||||
/* undocumented, but this formula works right for any shift count */
|
||||
of = (((BX_CPU_THIS_PTR oszapc.result_16 << 1) ^
|
||||
BX_CPU_THIS_PTR oszapc.result_16) & 0x8000) > 0;
|
||||
of = (((result_16 << 1) ^ result_16) & 0x8000) > 0;
|
||||
break;
|
||||
case BX_INSTR_SHRD32:
|
||||
/* undocumented, but this formula works right for any shift count */
|
||||
of = (((BX_CPU_THIS_PTR oszapc.result_32 << 1) ^
|
||||
BX_CPU_THIS_PTR oszapc.result_32) & 0x80000000) > 0;
|
||||
of = (((result_32 << 1) ^ result_32) & 0x80000000) > 0;
|
||||
break;
|
||||
#if BX_SUPPORT_X86_64
|
||||
case BX_INSTR_SHRD64:
|
||||
/* undocumented, but this formula works right for any shift count */
|
||||
of = (((BX_CPU_THIS_PTR oszapc.result_64 << 1) ^
|
||||
BX_CPU_THIS_PTR oszapc.result_64) & BX_CONST64(0x8000000000000000)) > 0;
|
||||
of = (((result_64 << 1) ^ result_64) & BX_CONST64(0x8000000000000000)) > 0;
|
||||
break;
|
||||
#endif
|
||||
case BX_INSTR_SHL8:
|
||||
if (BX_CPU_THIS_PTR oszapc.op2_8 == 1)
|
||||
of = ((BX_CPU_THIS_PTR oszapc.op1_8 ^
|
||||
BX_CPU_THIS_PTR oszapc.result_8) & 0x80) > 0;
|
||||
of = ((BX_CPU_THIS_PTR oszapc.op1_8 ^ result_8) & 0x80) > 0;
|
||||
else
|
||||
of = (((BX_CPU_THIS_PTR oszapc.op1_8 <<
|
||||
(BX_CPU_THIS_PTR oszapc.op2_8 - 1)) ^
|
||||
BX_CPU_THIS_PTR oszapc.result_8) & 0x80) > 0;
|
||||
(BX_CPU_THIS_PTR oszapc.op2_8 - 1)) ^ result_8) & 0x80) > 0;
|
||||
break;
|
||||
case BX_INSTR_SHL16:
|
||||
if (BX_CPU_THIS_PTR oszapc.op2_16 == 1)
|
||||
of = ((BX_CPU_THIS_PTR oszapc.op1_16 ^
|
||||
BX_CPU_THIS_PTR oszapc.result_16) & 0x8000) > 0;
|
||||
of = ((BX_CPU_THIS_PTR oszapc.op1_16 ^ result_16) & 0x8000) > 0;
|
||||
else
|
||||
of = (((BX_CPU_THIS_PTR oszapc.op1_16 <<
|
||||
(BX_CPU_THIS_PTR oszapc.op2_16 - 1)) ^
|
||||
BX_CPU_THIS_PTR oszapc.result_16) & 0x8000) > 0;
|
||||
(BX_CPU_THIS_PTR oszapc.op2_16 - 1)) ^ result_16) & 0x8000) > 0;
|
||||
break;
|
||||
case BX_INSTR_SHL32:
|
||||
if (BX_CPU_THIS_PTR oszapc.op2_32 == 1)
|
||||
of = ((BX_CPU_THIS_PTR oszapc.op1_32 ^
|
||||
BX_CPU_THIS_PTR oszapc.result_32) & 0x80000000) > 0;
|
||||
of = ((BX_CPU_THIS_PTR oszapc.op1_32 ^ result_32) & 0x80000000) > 0;
|
||||
else
|
||||
of = (((BX_CPU_THIS_PTR oszapc.op1_32 <<
|
||||
(BX_CPU_THIS_PTR oszapc.op2_32 - 1)) ^
|
||||
BX_CPU_THIS_PTR oszapc.result_32) & 0x80000000) > 0;
|
||||
(BX_CPU_THIS_PTR oszapc.op2_32 - 1)) ^ result_32) & 0x80000000) > 0;
|
||||
break;
|
||||
#if BX_SUPPORT_X86_64
|
||||
case BX_INSTR_SHL64:
|
||||
if (BX_CPU_THIS_PTR oszapc.op2_64 == 1)
|
||||
of = ((BX_CPU_THIS_PTR oszapc.op1_64 ^
|
||||
BX_CPU_THIS_PTR oszapc.result_64) & BX_CONST64(0x8000000000000000)) > 0;
|
||||
of = ((BX_CPU_THIS_PTR oszapc.op1_64 ^ result_64) & BX_CONST64(0x8000000000000000)) > 0;
|
||||
else
|
||||
of = (((BX_CPU_THIS_PTR oszapc.op1_64 <<
|
||||
(BX_CPU_THIS_PTR oszapc.op2_64 - 1)) ^
|
||||
BX_CPU_THIS_PTR oszapc.result_64) & BX_CONST64(0x8000000000000000)) > 0;
|
||||
(BX_CPU_THIS_PTR oszapc.op2_64 - 1)) ^ result_64) & BX_CONST64(0x8000000000000000)) > 0;
|
||||
break;
|
||||
#endif
|
||||
case BX_INSTR_IMUL8:
|
||||
of = ! ((BX_CPU_THIS_PTR oszapc.result_8 < 0x80 &&
|
||||
of = ! ((result_8 < 0x80 &&
|
||||
BX_CPU_THIS_PTR oszapc.op2_8 == 0) ||
|
||||
((BX_CPU_THIS_PTR oszapc.result_8 & 0x80) &&
|
||||
((result_8 & 0x80) &&
|
||||
BX_CPU_THIS_PTR oszapc.op2_8 == 0xff));
|
||||
break;
|
||||
case BX_INSTR_IMUL16:
|
||||
of = ! ((BX_CPU_THIS_PTR oszapc.result_16 < 0x8000 &&
|
||||
of = ! ((result_16 < 0x8000 &&
|
||||
BX_CPU_THIS_PTR oszapc.op2_16 == 0) ||
|
||||
((BX_CPU_THIS_PTR oszapc.result_16 & 0x8000) &&
|
||||
((result_16 & 0x8000) &&
|
||||
BX_CPU_THIS_PTR oszapc.op2_16 == 0xffff));
|
||||
break;
|
||||
case BX_INSTR_IMUL32:
|
||||
of = ! ((BX_CPU_THIS_PTR oszapc.result_32 < 0x80000000 &&
|
||||
of = ! ((result_32 < 0x80000000 &&
|
||||
BX_CPU_THIS_PTR oszapc.op2_32 == 0) ||
|
||||
((BX_CPU_THIS_PTR oszapc.result_32 & 0x80000000) &&
|
||||
((result_32 & 0x80000000) &&
|
||||
BX_CPU_THIS_PTR oszapc.op2_32 == 0xffffffff));
|
||||
break;
|
||||
#if BX_SUPPORT_X86_64
|
||||
case BX_INSTR_IMUL64:
|
||||
of = ! ((BX_CPU_THIS_PTR oszapc.result_64 < BX_CONST64(0x8000000000000000) &&
|
||||
of = ! ((result_64 < BX_CONST64(0x8000000000000000) &&
|
||||
BX_CPU_THIS_PTR oszapc.op2_64 == 0) ||
|
||||
((BX_CPU_THIS_PTR oszapc.result_64 & BX_CONST64(0x8000000000000000)) &&
|
||||
((result_64 & BX_CONST64(0x8000000000000000)) &&
|
||||
BX_CPU_THIS_PTR oszapc.op2_64 == BX_CONST64(0xffffffffffffffff)));
|
||||
break;
|
||||
#endif
|
||||
@ -789,126 +571,45 @@ bx_bool BX_CPU_C::get_OFLazy(void)
|
||||
#endif
|
||||
case BX_INSTR_NEG8:
|
||||
case BX_INSTR_INC8:
|
||||
of = (BX_CPU_THIS_PTR oszapc.result_8 == 0x80);
|
||||
of = (result_8 == 0x80);
|
||||
break;
|
||||
case BX_INSTR_NEG16:
|
||||
case BX_INSTR_INC16:
|
||||
of = (BX_CPU_THIS_PTR oszapc.result_16 == 0x8000);
|
||||
of = (result_16 == 0x8000);
|
||||
break;
|
||||
case BX_INSTR_NEG32:
|
||||
case BX_INSTR_INC32:
|
||||
of = (BX_CPU_THIS_PTR oszapc.result_32 == 0x80000000);
|
||||
of = (result_32 == 0x80000000);
|
||||
break;
|
||||
#if BX_SUPPORT_X86_64
|
||||
case BX_INSTR_NEG64:
|
||||
case BX_INSTR_INC64:
|
||||
of = (BX_CPU_THIS_PTR oszapc.result_64 == BX_CONST64(0x8000000000000000));
|
||||
of = (result_64 == BX_CONST64(0x8000000000000000));
|
||||
break;
|
||||
#endif
|
||||
case BX_INSTR_DEC8:
|
||||
of = (BX_CPU_THIS_PTR oszapc.result_8 == 0x7F);
|
||||
of = (result_8 == 0x7F);
|
||||
break;
|
||||
case BX_INSTR_DEC16:
|
||||
of = (BX_CPU_THIS_PTR oszapc.result_16 == 0x7FFF);
|
||||
of = (result_16 == 0x7FFF);
|
||||
break;
|
||||
case BX_INSTR_DEC32:
|
||||
of = (BX_CPU_THIS_PTR oszapc.result_32 == 0x7FFFFFFF);
|
||||
of = (result_32 == 0x7FFFFFFF);
|
||||
break;
|
||||
#if BX_SUPPORT_X86_64
|
||||
case BX_INSTR_DEC64:
|
||||
of = (BX_CPU_THIS_PTR oszapc.result_64 == BX_CONST64(0x7FFFFFFFFFFFFFFF));
|
||||
of = (result_64 == BX_CONST64(0x7FFFFFFFFFFFFFFF));
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
of = 0; // Keep compiler happy.
|
||||
BX_PANIC(("get_OF: OSZAPC: unknown instr"));
|
||||
}
|
||||
#if UPDATE_EFLAGS_LAZY
|
||||
BX_CPU_THIS_PTR lf_flags_status &= ~EFlagsOFMask;
|
||||
BX_CPU_THIS_PTR eflags.val32 &= ~(1<<11);
|
||||
BX_CPU_THIS_PTR eflags.val32 |= (!!of)<<11;
|
||||
#endif
|
||||
|
||||
return(of);
|
||||
}
|
||||
|
||||
bx_bool BX_CPU_C::get_PFLazy(void)
|
||||
{
|
||||
unsigned pf;
|
||||
|
||||
switch (BX_CPU_THIS_PTR oszapc.instr) {
|
||||
case BX_INSTR_LOGIC8:
|
||||
case BX_INSTR_ADD8:
|
||||
case BX_INSTR_ADC8:
|
||||
case BX_INSTR_SUB8:
|
||||
case BX_INSTR_SBB8:
|
||||
case BX_INSTR_NEG8:
|
||||
case BX_INSTR_SAR8:
|
||||
case BX_INSTR_SHR8:
|
||||
case BX_INSTR_SHL8:
|
||||
case BX_INSTR_IMUL8:
|
||||
case BX_INSTR_MUL8:
|
||||
case BX_INSTR_INC8:
|
||||
case BX_INSTR_DEC8:
|
||||
pf = bx_parity_lookup[BX_CPU_THIS_PTR oszapc.result_8];
|
||||
break;
|
||||
case BX_INSTR_LOGIC16:
|
||||
case BX_INSTR_ADD16:
|
||||
case BX_INSTR_ADC16:
|
||||
case BX_INSTR_SUB16:
|
||||
case BX_INSTR_SBB16:
|
||||
case BX_INSTR_NEG16:
|
||||
case BX_INSTR_SAR16:
|
||||
case BX_INSTR_SHR16:
|
||||
case BX_INSTR_SHRD16:
|
||||
case BX_INSTR_SHL16:
|
||||
case BX_INSTR_IMUL16:
|
||||
case BX_INSTR_MUL16:
|
||||
case BX_INSTR_INC16:
|
||||
case BX_INSTR_DEC16:
|
||||
pf = bx_parity_lookup[(Bit8u) BX_CPU_THIS_PTR oszapc.result_16];
|
||||
break;
|
||||
case BX_INSTR_LOGIC32:
|
||||
case BX_INSTR_ADD32:
|
||||
case BX_INSTR_ADC32:
|
||||
case BX_INSTR_SUB32:
|
||||
case BX_INSTR_SBB32:
|
||||
case BX_INSTR_NEG32:
|
||||
case BX_INSTR_SAR32:
|
||||
case BX_INSTR_SHR32:
|
||||
case BX_INSTR_SHRD32:
|
||||
case BX_INSTR_SHL32:
|
||||
case BX_INSTR_IMUL32:
|
||||
case BX_INSTR_MUL32:
|
||||
case BX_INSTR_INC32:
|
||||
case BX_INSTR_DEC32:
|
||||
pf = bx_parity_lookup[(Bit8u) BX_CPU_THIS_PTR oszapc.result_32];
|
||||
break;
|
||||
#if BX_SUPPORT_X86_64
|
||||
case BX_INSTR_LOGIC64:
|
||||
case BX_INSTR_ADD64:
|
||||
case BX_INSTR_ADC64:
|
||||
case BX_INSTR_SUB64:
|
||||
case BX_INSTR_SBB64:
|
||||
case BX_INSTR_NEG64:
|
||||
case BX_INSTR_SAR64:
|
||||
case BX_INSTR_SHR64:
|
||||
case BX_INSTR_SHRD64:
|
||||
case BX_INSTR_SHL64:
|
||||
case BX_INSTR_IMUL64:
|
||||
case BX_INSTR_MUL64:
|
||||
case BX_INSTR_INC64:
|
||||
case BX_INSTR_DEC64:
|
||||
pf = bx_parity_lookup[(Bit8u) BX_CPU_THIS_PTR oszapc.result_64];
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
pf = 0; // Keep compiler quiet.
|
||||
BX_PANIC(("get_PF: OSZAPC: unknown instr"));
|
||||
}
|
||||
#if UPDATE_EFLAGS_LAZY
|
||||
BX_CPU_THIS_PTR lf_flags_status &= ~EFlagsPFMask;
|
||||
BX_CPU_THIS_PTR eflags.val32 &= ~(1<<2);
|
||||
BX_CPU_THIS_PTR eflags.val32 |= (pf)<<2; // pf is always 0 or 1 here
|
||||
#endif
|
||||
return(pf);
|
||||
return bx_parity_lookup[(Bit8u) BX_CPU_THIS_PTR oszapc.result];
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
// $Id: lazy_flags.h,v 1.26 2007-12-04 19:27:23 sshwarts Exp $
|
||||
// $Id: lazy_flags.h,v 1.27 2007-12-05 06:17:09 sshwarts Exp $
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2001 MandrakeSoft S.A.
|
||||
@ -111,31 +111,27 @@
|
||||
|
||||
#if BX_SUPPORT_X86_64
|
||||
#define BX_LF_SIGN_BIT 63
|
||||
#define BX_LF_SIGN_MASK BX_CONST64(0x8000000000000000)
|
||||
#else
|
||||
#define BX_LF_SIGN_BIT 31
|
||||
#define BX_LF_SIGN_MASK 0x80000000
|
||||
#endif
|
||||
|
||||
typedef struct {
|
||||
Bit8u op1_8;
|
||||
Bit8u op2_8;
|
||||
Bit8u result_8;
|
||||
|
||||
Bit16u op1_16;
|
||||
Bit16u op2_16;
|
||||
Bit16u result_16;
|
||||
|
||||
Bit32u op1_32;
|
||||
Bit32u op2_32;
|
||||
Bit32u result_32;
|
||||
|
||||
#if BX_SUPPORT_X86_64
|
||||
Bit64u op1_64;
|
||||
Bit64u op2_64;
|
||||
Bit64u result_64;
|
||||
#endif
|
||||
|
||||
bx_address result;
|
||||
|
||||
unsigned instr;
|
||||
} bx_lf_flags_entry;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user