improve lazy flags after ADD instruction

This commit is contained in:
Stanislav Shwartsman 2009-03-13 18:26:10 +00:00
parent 9417cbee63
commit 10c8d8ea33
2 changed files with 28 additions and 19 deletions

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: cpu.h,v 1.582 2009-03-13 18:02:33 sshwarts Exp $
// $Id: cpu.h,v 1.583 2009-03-13 18:26:10 sshwarts Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2001 MandrakeSoft S.A.
@ -3740,14 +3740,14 @@ BX_CPP_INLINE bx_bool BX_CPU_C::get_PFLazy(void)
#endif
#define SET_FLAGS_OSZAPC_ADD_8(op1_8, op2_8, sum_8) \
SET_FLAGS_OSZAPC_8((op1_8), (op2_8), (sum_8), BX_LF_INSTR_ADD8)
SET_FLAGS_OSZAPC_S2_8((op2_8), (sum_8), BX_LF_INSTR_ADD8)
#define SET_FLAGS_OSZAPC_ADD_16(op1_16, op2_16, sum_16) \
SET_FLAGS_OSZAPC_16((op1_16), (op2_16), (sum_16), BX_LF_INSTR_ADD16)
SET_FLAGS_OSZAPC_S2_16((op2_16), (sum_16), BX_LF_INSTR_ADD16)
#define SET_FLAGS_OSZAPC_ADD_32(op1_32, op2_32, sum_32) \
SET_FLAGS_OSZAPC_32((op1_32), (op2_32), (sum_32), BX_LF_INSTR_ADD32)
SET_FLAGS_OSZAPC_S2_32((op2_32), (sum_32), BX_LF_INSTR_ADD32)
#if BX_SUPPORT_X86_64
#define SET_FLAGS_OSZAPC_ADD_64(op1_64, op2_64, sum_64) \
SET_FLAGS_OSZAPC_64((op1_64), (op2_64), (sum_64), BX_LF_INSTR_ADD64)
SET_FLAGS_OSZAPC_S2_64((op2_64), (sum_64), BX_LF_INSTR_ADD64)
#endif
#define SET_FLAGS_OSZAPC_SUB_8(op1_8, op2_8, diff_8) \

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: lazy_flags.cc,v 1.50 2009-01-16 18:18:58 sshwarts Exp $
// $Id: lazy_flags.cc,v 1.51 2009-03-13 18:26:10 sshwarts Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2001 MandrakeSoft S.A.
@ -65,9 +65,9 @@ const Bit8u bx_parity_lookup[256] = {
#define result_32 ((Bit32u)(BX_CPU_THIS_PTR oszapc.result))
#if BX_SUPPORT_X86_64
#define op1_64 ((Bit64u)(BX_CPU_THIS_PTR oszapc.op1))
#define op2_64 ((Bit64u)(BX_CPU_THIS_PTR oszapc.op2))
#define result_64 ((Bit64u)(BX_CPU_THIS_PTR oszapc.result))
#define op1_64 (BX_CPU_THIS_PTR oszapc.op1)
#define op2_64 (BX_CPU_THIS_PTR oszapc.op2)
#define result_64 (BX_CPU_THIS_PTR oszapc.result)
#endif
bx_bool BX_CPU_C::get_CFLazy(void)
@ -78,23 +78,23 @@ bx_bool BX_CPU_C::get_CFLazy(void)
case BX_LF_INSTR_ADD8:
case BX_LF_INSTR_ADD16:
case BX_LF_INSTR_ADD32:
cf = (result_32 < op1_32);
cf = (result_32 < op2_32);
break;
#if BX_SUPPORT_X86_64
case BX_LF_INSTR_ADD64:
cf = (result_64 < op1_64);
cf = (result_64 < op2_64);
break;
#endif
// used only if CF = 1 when executing ADC instruction
case BX_LF_INSTR_ADC8:
case BX_LF_INSTR_ADC16:
case BX_LF_INSTR_ADC32:
cf = (result_32 <= op1_32);
cf = (result_32 <= op2_32);
break;
#if BX_SUPPORT_X86_64
// used only if CF = 1 when executing ADC instruction
case BX_LF_INSTR_ADC64:
cf = (result_64 <= op1_64);
cf = (result_64 <= op2_64);
break;
#endif
case BX_LF_INSTR_SUB8:
@ -159,19 +159,24 @@ bx_bool BX_CPU_C::get_AFLazy(void)
switch (BX_CPU_THIS_PTR oszapc.instr) {
case BX_LF_INSTR_ADD8:
case BX_LF_INSTR_ADC8:
case BX_LF_INSTR_SUB8:
case BX_LF_INSTR_SBB8:
case BX_LF_INSTR_ADD16:
case BX_LF_INSTR_ADC16:
case BX_LF_INSTR_SUB16:
case BX_LF_INSTR_SBB16:
case BX_LF_INSTR_ADD32:
case BX_LF_INSTR_ADC32:
case BX_LF_INSTR_SUB32:
case BX_LF_INSTR_SBB32:
#if BX_SUPPORT_X86_64
case BX_LF_INSTR_ADD64:
case BX_LF_INSTR_ADC64:
#endif
BX_CPU_THIS_PTR oszapc.op1 =
BX_CPU_THIS_PTR oszapc.result - BX_CPU_THIS_PTR oszapc.op2;
// fall through
case BX_LF_INSTR_SUB8:
case BX_LF_INSTR_SBB8:
case BX_LF_INSTR_SUB16:
case BX_LF_INSTR_SBB16:
case BX_LF_INSTR_SUB32:
case BX_LF_INSTR_SBB32:
#if BX_SUPPORT_X86_64
case BX_LF_INSTR_SUB64:
case BX_LF_INSTR_SBB64:
#endif
@ -234,11 +239,15 @@ bx_bool BX_CPU_C::get_OFLazy(void)
case BX_LF_INSTR_ADC16:
case BX_LF_INSTR_ADD32:
case BX_LF_INSTR_ADC32:
BX_CPU_THIS_PTR oszapc.op1 =
BX_CPU_THIS_PTR oszapc.result - BX_CPU_THIS_PTR oszapc.op2;
of = GET_ADD_OVERFLOW(op1_32, op2_32, result_32, 0x80000000);
break;
#if BX_SUPPORT_X86_64
case BX_LF_INSTR_ADD64:
case BX_LF_INSTR_ADC64:
BX_CPU_THIS_PTR oszapc.op1 =
BX_CPU_THIS_PTR oszapc.result - BX_CPU_THIS_PTR oszapc.op2;
of = GET_ADD_OVERFLOW(op1_64, op2_64, result_64, BX_CONST64(0x8000000000000000));
break;
#endif