2001-10-03 17:10:38 +04:00
|
|
|
/////////////////////////////////////////////////////////////////////////
|
2008-03-29 21:44:13 +03:00
|
|
|
// $Id: lazy_flags.cc,v 1.45 2008-03-29 18:44:13 sshwarts Exp $
|
2001-10-03 17:10:38 +04:00
|
|
|
/////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
2001-04-10 06:20:02 +04:00
|
|
|
// Copyright (C) 2001 MandrakeSoft S.A.
|
2001-04-10 05:04:59 +04:00
|
|
|
//
|
|
|
|
// MandrakeSoft S.A.
|
|
|
|
// 43, rue d'Aboukir
|
|
|
|
// 75002 Paris - France
|
|
|
|
// http://www.linux-mandrake.com/
|
|
|
|
// http://www.mandrakesoft.com/
|
|
|
|
//
|
|
|
|
// This library is free software; you can redistribute it and/or
|
|
|
|
// modify it under the terms of the GNU Lesser General Public
|
|
|
|
// License as published by the Free Software Foundation; either
|
|
|
|
// version 2 of the License, or (at your option) any later version.
|
|
|
|
//
|
|
|
|
// This library is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
// Lesser General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU Lesser General Public
|
|
|
|
// License along with this library; if not, write to the Free Software
|
|
|
|
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
2005-10-14 00:21:35 +04:00
|
|
|
/////////////////////////////////////////////////////////////////////////
|
2001-04-10 05:04:59 +04:00
|
|
|
|
2001-05-24 22:46:34 +04:00
|
|
|
#define NEED_CPU_REG_SHORTCUTS 1
|
2001-04-10 05:04:59 +04:00
|
|
|
#include "bochs.h"
|
2006-03-07 01:03:16 +03:00
|
|
|
#include "cpu.h"
|
merge in BRANCH-io-cleanup.
To see the commit logs for this use either cvsweb or
cvs update -r BRANCH-io-cleanup and then 'cvs log' the various files.
In general this provides a generic interface for logging.
logfunctions:: is a class that is inherited by some classes, and also
. allocated as a standalone global called 'genlog'. All logging uses
. one of the ::info(), ::error(), ::ldebug(), ::panic() methods of this
. class through 'BX_INFO(), BX_ERROR(), BX_DEBUG(), BX_PANIC()' macros
. respectively.
.
. An example usage:
. BX_INFO(("Hello, World!\n"));
iofunctions:: is a class that is allocated once by default, and assigned
as the iofunction of each logfunctions instance. It is this class that
maintains the file descriptor and other output related code, at this
point using vfprintf(). At some future point, someone may choose to
write a gui 'console' for bochs to which messages would be redirected
simply by assigning a different iofunction class to the various logfunctions
objects.
More cleanup is coming, but this works for now. If you want to see alot
of debugging output, in main.cc, change onoff[LOGLEV_DEBUG]=0 to =1.
Comments, bugs, flames, to me: todd@fries.net
2001-05-15 18:49:57 +04:00
|
|
|
#define LOG_THIS BX_CPU_THIS_PTR
|
2001-04-10 05:04:59 +04:00
|
|
|
|
2005-10-20 21:33:36 +04:00
|
|
|
// This array defines a look-up table for the even parity-ness
|
|
|
|
// of an 8bit quantity, for optimal assignment of the parity bit
|
|
|
|
// in the EFLAGS register
|
|
|
|
const bx_bool bx_parity_lookup[256] = {
|
|
|
|
1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1,
|
|
|
|
0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0,
|
|
|
|
0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0,
|
|
|
|
1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1,
|
|
|
|
0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0,
|
|
|
|
1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1,
|
|
|
|
1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1,
|
|
|
|
0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0,
|
|
|
|
0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0,
|
|
|
|
1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1,
|
|
|
|
1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1,
|
|
|
|
0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0,
|
|
|
|
1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1,
|
|
|
|
0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0,
|
|
|
|
0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0,
|
|
|
|
1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1
|
|
|
|
};
|
2005-10-14 00:21:35 +04:00
|
|
|
|
2007-12-05 09:17:09 +03:00
|
|
|
#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)
|
2007-11-19 22:55:09 +03:00
|
|
|
|
2004-08-10 01:28:47 +04:00
|
|
|
bx_bool BX_CPU_C::get_CFLazy(void)
|
2001-04-10 05:04:59 +04:00
|
|
|
{
|
2002-09-08 08:08:14 +04:00
|
|
|
unsigned cf;
|
|
|
|
|
2007-03-18 22:29:17 +03:00
|
|
|
switch (BX_CPU_THIS_PTR oszapc.instr) {
|
|
|
|
case BX_INSTR_ADD8:
|
2007-12-05 09:17:09 +03:00
|
|
|
cf = (result_8 < BX_CPU_THIS_PTR oszapc.op1_8);
|
2007-03-18 22:29:17 +03:00
|
|
|
break;
|
|
|
|
case BX_INSTR_ADD16:
|
2007-12-05 09:17:09 +03:00
|
|
|
cf = (result_16 < BX_CPU_THIS_PTR oszapc.op1_16);
|
2007-03-18 22:29:17 +03:00
|
|
|
break;
|
|
|
|
case BX_INSTR_ADD32:
|
2007-12-05 09:17:09 +03:00
|
|
|
cf = (result_32 < BX_CPU_THIS_PTR oszapc.op1_32);
|
2007-03-18 22:29:17 +03:00
|
|
|
break;
|
2002-09-15 04:18:41 +04:00
|
|
|
#if BX_SUPPORT_X86_64
|
2007-03-18 22:29:17 +03:00
|
|
|
case BX_INSTR_ADD64:
|
2007-12-05 09:17:09 +03:00
|
|
|
cf = (result_64 < BX_CPU_THIS_PTR oszapc.op1_64);
|
2007-03-18 22:29:17 +03:00
|
|
|
break;
|
2002-09-15 04:18:41 +04:00
|
|
|
#endif
|
2007-03-18 22:29:17 +03:00
|
|
|
// used only if CF = 1 when executing ADC instruction
|
|
|
|
case BX_INSTR_ADC8:
|
2007-12-05 09:17:09 +03:00
|
|
|
cf = (result_8 <= BX_CPU_THIS_PTR oszapc.op1_8);
|
2007-03-18 22:29:17 +03:00
|
|
|
break;
|
|
|
|
// used only if CF = 1 when executing ADC instruction
|
|
|
|
case BX_INSTR_ADC16:
|
2007-12-05 09:17:09 +03:00
|
|
|
cf = (result_16 <= BX_CPU_THIS_PTR oszapc.op1_16);
|
2007-03-18 22:29:17 +03:00
|
|
|
break;
|
|
|
|
// used only if CF = 1 when executing ADC instruction
|
|
|
|
case BX_INSTR_ADC32:
|
2007-12-05 09:17:09 +03:00
|
|
|
cf = (result_32 <= BX_CPU_THIS_PTR oszapc.op1_32);
|
2007-03-18 22:29:17 +03:00
|
|
|
break;
|
2002-09-15 04:18:41 +04:00
|
|
|
#if BX_SUPPORT_X86_64
|
2007-03-18 22:29:17 +03:00
|
|
|
// used only if CF = 1 when executing ADC instruction
|
|
|
|
case BX_INSTR_ADC64:
|
2007-12-05 09:17:09 +03:00
|
|
|
cf = (result_64 <= BX_CPU_THIS_PTR oszapc.op1_64);
|
2007-03-18 22:29:17 +03:00
|
|
|
break;
|
2002-09-15 04:18:41 +04:00
|
|
|
#endif
|
2007-03-18 22:29:17 +03:00
|
|
|
case BX_INSTR_SUB8:
|
|
|
|
cf = (BX_CPU_THIS_PTR oszapc.op1_8 <
|
|
|
|
BX_CPU_THIS_PTR oszapc.op2_8);
|
|
|
|
break;
|
|
|
|
case BX_INSTR_SUB16:
|
|
|
|
cf = (BX_CPU_THIS_PTR oszapc.op1_16 <
|
|
|
|
BX_CPU_THIS_PTR oszapc.op2_16);
|
|
|
|
break;
|
|
|
|
case BX_INSTR_SUB32:
|
|
|
|
cf = (BX_CPU_THIS_PTR oszapc.op1_32 <
|
|
|
|
BX_CPU_THIS_PTR oszapc.op2_32);
|
|
|
|
break;
|
2002-09-15 04:18:41 +04:00
|
|
|
#if BX_SUPPORT_X86_64
|
2007-03-18 22:29:17 +03:00
|
|
|
case BX_INSTR_SUB64:
|
|
|
|
cf = (BX_CPU_THIS_PTR oszapc.op1_64 <
|
|
|
|
BX_CPU_THIS_PTR oszapc.op2_64);
|
|
|
|
break;
|
2002-09-15 04:18:41 +04:00
|
|
|
#endif
|
2007-03-18 22:29:17 +03:00
|
|
|
// used only if CF = 1 when executing SBB instruction
|
|
|
|
case BX_INSTR_SBB8:
|
2007-12-05 09:17:09 +03:00
|
|
|
cf = (BX_CPU_THIS_PTR oszapc.op1_8 < result_8) ||
|
2007-03-18 22:29:17 +03:00
|
|
|
(BX_CPU_THIS_PTR oszapc.op2_8==0xff);
|
|
|
|
break;
|
|
|
|
// used only if CF = 1 when executing SBB instruction
|
|
|
|
case BX_INSTR_SBB16:
|
2007-12-05 09:17:09 +03:00
|
|
|
cf = (BX_CPU_THIS_PTR oszapc.op1_16 < result_16) ||
|
2007-03-18 22:29:17 +03:00
|
|
|
(BX_CPU_THIS_PTR oszapc.op2_16==0xffff);
|
|
|
|
break;
|
|
|
|
// used only if CF = 1 when executing SBB instruction
|
|
|
|
case BX_INSTR_SBB32:
|
2007-12-05 09:17:09 +03:00
|
|
|
cf = (BX_CPU_THIS_PTR oszapc.op1_32 < result_32) ||
|
2007-03-18 22:29:17 +03:00
|
|
|
(BX_CPU_THIS_PTR oszapc.op2_32==0xffffffff);
|
|
|
|
break;
|
2002-09-15 04:18:41 +04:00
|
|
|
#if BX_SUPPORT_X86_64
|
2007-03-18 22:29:17 +03:00
|
|
|
// used only if CF = 1 when executing SBB instruction
|
|
|
|
case BX_INSTR_SBB64:
|
2007-12-05 09:17:09 +03:00
|
|
|
cf = (BX_CPU_THIS_PTR oszapc.op1_64 < result_64) ||
|
2007-03-18 22:29:17 +03:00
|
|
|
(BX_CPU_THIS_PTR oszapc.op2_64==BX_CONST64(0xffffffffffffffff));
|
|
|
|
break;
|
2002-09-15 04:18:41 +04:00
|
|
|
#endif
|
2007-03-18 22:29:17 +03:00
|
|
|
case BX_INSTR_NEG8:
|
2007-12-05 09:17:09 +03:00
|
|
|
cf = (result_8 != 0);
|
2007-03-18 22:29:17 +03:00
|
|
|
break;
|
|
|
|
case BX_INSTR_NEG16:
|
2007-12-05 09:17:09 +03:00
|
|
|
cf = (result_16 != 0);
|
2007-03-18 22:29:17 +03:00
|
|
|
break;
|
|
|
|
case BX_INSTR_NEG32:
|
2007-12-05 09:17:09 +03:00
|
|
|
cf = (result_32 != 0);
|
2007-03-18 22:29:17 +03:00
|
|
|
break;
|
2002-09-15 04:18:41 +04:00
|
|
|
#if BX_SUPPORT_X86_64
|
2007-03-18 22:29:17 +03:00
|
|
|
case BX_INSTR_NEG64:
|
2007-12-05 09:17:09 +03:00
|
|
|
cf = (result_64 != 0);
|
2007-03-18 22:29:17 +03:00
|
|
|
break;
|
2002-09-15 04:18:41 +04:00
|
|
|
#endif
|
2007-03-18 22:29:17 +03:00
|
|
|
case BX_INSTR_LOGIC8:
|
|
|
|
case BX_INSTR_LOGIC16:
|
|
|
|
case BX_INSTR_LOGIC32:
|
2002-09-15 04:18:41 +04:00
|
|
|
#if BX_SUPPORT_X86_64
|
2007-03-18 22:29:17 +03:00
|
|
|
case BX_INSTR_LOGIC64:
|
2002-09-15 04:18:41 +04:00
|
|
|
#endif
|
2007-03-18 22:29:17 +03:00
|
|
|
cf = 0;
|
|
|
|
break;
|
2001-04-10 05:04:59 +04:00
|
|
|
default:
|
2007-03-18 22:29:17 +03:00
|
|
|
cf = 0; // Keep compiler quiet.
|
|
|
|
BX_PANIC(("get_CF: OSZAPC: unknown instr %u",
|
|
|
|
(unsigned) BX_CPU_THIS_PTR oszapc.instr));
|
2005-10-14 00:21:35 +04:00
|
|
|
}
|
2008-02-03 00:46:54 +03:00
|
|
|
|
2007-03-18 22:29:17 +03:00
|
|
|
return(cf);
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
|
|
|
|
2004-08-10 01:28:47 +04:00
|
|
|
bx_bool BX_CPU_C::get_AFLazy(void)
|
2001-04-10 05:04:59 +04:00
|
|
|
{
|
2002-09-08 08:08:14 +04:00
|
|
|
unsigned af;
|
|
|
|
|
2007-12-04 22:27:23 +03:00
|
|
|
switch (BX_CPU_THIS_PTR oszapc.instr) {
|
|
|
|
case BX_INSTR_ADD8:
|
|
|
|
case BX_INSTR_ADC8:
|
|
|
|
case BX_INSTR_SUB8:
|
|
|
|
case BX_INSTR_SBB8:
|
|
|
|
af = ((BX_CPU_THIS_PTR oszapc.op1_8 ^
|
2007-12-05 09:17:09 +03:00
|
|
|
BX_CPU_THIS_PTR oszapc.op2_8) ^ result_8) & 0x10;
|
2007-12-04 22:27:23 +03:00
|
|
|
break;
|
|
|
|
case BX_INSTR_ADD16:
|
|
|
|
case BX_INSTR_ADC16:
|
|
|
|
case BX_INSTR_SUB16:
|
|
|
|
case BX_INSTR_SBB16:
|
|
|
|
af = ((BX_CPU_THIS_PTR oszapc.op1_16 ^
|
2007-12-05 09:17:09 +03:00
|
|
|
BX_CPU_THIS_PTR oszapc.op2_16) ^ result_16) & 0x10;
|
2007-12-04 22:27:23 +03:00
|
|
|
break;
|
|
|
|
case BX_INSTR_ADD32:
|
|
|
|
case BX_INSTR_ADC32:
|
|
|
|
case BX_INSTR_SUB32:
|
|
|
|
case BX_INSTR_SBB32:
|
|
|
|
af = ((BX_CPU_THIS_PTR oszapc.op1_32 ^
|
2007-12-05 09:17:09 +03:00
|
|
|
BX_CPU_THIS_PTR oszapc.op2_32) ^ result_32) & 0x10;
|
2007-12-04 22:27:23 +03:00
|
|
|
break;
|
2002-09-15 04:18:41 +04:00
|
|
|
#if BX_SUPPORT_X86_64
|
2007-12-04 22:27:23 +03:00
|
|
|
case BX_INSTR_ADD64:
|
|
|
|
case BX_INSTR_ADC64:
|
|
|
|
case BX_INSTR_SUB64:
|
|
|
|
case BX_INSTR_SBB64:
|
|
|
|
af = ((BX_CPU_THIS_PTR oszapc.op1_64 ^
|
2007-12-05 09:17:09 +03:00
|
|
|
BX_CPU_THIS_PTR oszapc.op2_64) ^ result_64) & 0x10;
|
2007-12-04 22:27:23 +03:00
|
|
|
break;
|
2002-09-15 04:18:41 +04:00
|
|
|
#endif
|
2007-12-04 22:27:23 +03:00
|
|
|
case BX_INSTR_NEG8:
|
|
|
|
case BX_INSTR_NEG16:
|
|
|
|
case BX_INSTR_NEG32:
|
2002-09-15 04:18:41 +04:00
|
|
|
#if BX_SUPPORT_X86_64
|
2007-12-04 22:27:23 +03:00
|
|
|
case BX_INSTR_NEG64:
|
2002-09-15 04:18:41 +04:00
|
|
|
#endif
|
2007-12-05 09:17:09 +03:00
|
|
|
af = (result_8 & 0xf) != 0;
|
2007-12-04 22:27:23 +03:00
|
|
|
break;
|
2007-12-05 09:17:09 +03:00
|
|
|
case BX_INSTR_INC8:
|
2007-12-04 22:27:23 +03:00
|
|
|
case BX_INSTR_INC16:
|
|
|
|
case BX_INSTR_INC32:
|
2002-09-15 04:18:41 +04:00
|
|
|
#if BX_SUPPORT_X86_64
|
2007-12-04 22:27:23 +03:00
|
|
|
case BX_INSTR_INC64:
|
2007-11-19 22:55:09 +03:00
|
|
|
#endif
|
2007-12-05 09:17:09 +03:00
|
|
|
af = (result_8 & 0xf) == 0;
|
2007-12-04 22:27:23 +03:00
|
|
|
break;
|
2007-12-05 09:17:09 +03:00
|
|
|
case BX_INSTR_DEC8:
|
2007-12-04 22:27:23 +03:00
|
|
|
case BX_INSTR_DEC16:
|
|
|
|
case BX_INSTR_DEC32:
|
2002-09-15 04:18:41 +04:00
|
|
|
#if BX_SUPPORT_X86_64
|
2007-12-04 22:27:23 +03:00
|
|
|
case BX_INSTR_DEC64:
|
2002-09-15 04:18:41 +04:00
|
|
|
#endif
|
2007-12-05 09:17:09 +03:00
|
|
|
af = (result_8 & 0xf) == 0xf;
|
|
|
|
break;
|
2007-12-04 22:27:23 +03:00
|
|
|
case BX_INSTR_LOGIC8:
|
|
|
|
case BX_INSTR_LOGIC16:
|
|
|
|
case BX_INSTR_LOGIC32:
|
2002-09-15 04:18:41 +04:00
|
|
|
#if BX_SUPPORT_X86_64
|
2007-12-04 22:27:23 +03:00
|
|
|
case BX_INSTR_LOGIC64:
|
2002-09-15 04:18:41 +04:00
|
|
|
#endif
|
2007-12-04 22:27:23 +03:00
|
|
|
af = 0;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
af = 0; // Keep compiler quiet.
|
|
|
|
BX_PANIC(("get_AF: OSZAPC: unknown instr %u", (unsigned) BX_CPU_THIS_PTR oszapc.instr));
|
|
|
|
}
|
2007-12-05 09:17:09 +03:00
|
|
|
|
2007-12-04 22:27:23 +03:00
|
|
|
return(af);
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
|
|
|
|
2006-05-12 21:04:19 +04:00
|
|
|
#define GET_ADD_OVERFLOW(op1, op2, result, mask) \
|
|
|
|
(((~((op1) ^ (op2)) & ((op2) ^ (result))) & (mask)) != 0)
|
|
|
|
|
|
|
|
#define GET_SUB_OVERFLOW(op1, op2, result, mask) \
|
|
|
|
(((((op1) ^ (op2)) & ((op1) ^ (result))) & (mask)) != 0)
|
|
|
|
|
2004-08-10 01:28:47 +04:00
|
|
|
bx_bool BX_CPU_C::get_OFLazy(void)
|
2001-04-10 05:04:59 +04:00
|
|
|
{
|
2002-09-08 08:08:14 +04:00
|
|
|
unsigned of;
|
2001-04-10 05:04:59 +04:00
|
|
|
|
2007-12-04 22:27:23 +03:00
|
|
|
switch (BX_CPU_THIS_PTR oszapc.instr) {
|
|
|
|
case BX_INSTR_ADD8:
|
|
|
|
case BX_INSTR_ADC8:
|
2007-12-05 09:17:09 +03:00
|
|
|
of = GET_ADD_OVERFLOW(BX_CPU_THIS_PTR oszapc.op1_8,
|
|
|
|
BX_CPU_THIS_PTR oszapc.op2_8,
|
|
|
|
result_8, 0x80);
|
2007-12-04 22:27:23 +03:00
|
|
|
break;
|
|
|
|
case BX_INSTR_ADD16:
|
|
|
|
case BX_INSTR_ADC16:
|
2007-12-05 09:17:09 +03:00
|
|
|
of = GET_ADD_OVERFLOW(BX_CPU_THIS_PTR oszapc.op1_16,
|
|
|
|
BX_CPU_THIS_PTR oszapc.op2_16,
|
|
|
|
result_16, 0x8000);
|
2007-12-04 22:27:23 +03:00
|
|
|
break;
|
|
|
|
case BX_INSTR_ADD32:
|
|
|
|
case BX_INSTR_ADC32:
|
2007-12-05 09:17:09 +03:00
|
|
|
of = GET_ADD_OVERFLOW(BX_CPU_THIS_PTR oszapc.op1_32,
|
|
|
|
BX_CPU_THIS_PTR oszapc.op2_32,
|
|
|
|
result_32, 0x80000000);
|
2007-12-04 22:27:23 +03:00
|
|
|
break;
|
2002-09-15 04:18:41 +04:00
|
|
|
#if BX_SUPPORT_X86_64
|
2007-12-04 22:27:23 +03:00
|
|
|
case BX_INSTR_ADD64:
|
|
|
|
case BX_INSTR_ADC64:
|
2007-12-05 09:17:09 +03:00
|
|
|
of = GET_ADD_OVERFLOW(BX_CPU_THIS_PTR oszapc.op1_64,
|
|
|
|
BX_CPU_THIS_PTR oszapc.op2_64,
|
|
|
|
result_64, BX_CONST64(0x8000000000000000));
|
2007-12-04 22:27:23 +03:00
|
|
|
break;
|
2002-09-15 04:18:41 +04:00
|
|
|
#endif
|
2007-12-04 22:27:23 +03:00
|
|
|
case BX_INSTR_SUB8:
|
|
|
|
case BX_INSTR_SBB8:
|
2007-12-05 09:17:09 +03:00
|
|
|
of = GET_SUB_OVERFLOW(BX_CPU_THIS_PTR oszapc.op1_8,
|
|
|
|
BX_CPU_THIS_PTR oszapc.op2_8,
|
|
|
|
result_8, 0x80);
|
2007-12-04 22:27:23 +03:00
|
|
|
break;
|
|
|
|
case BX_INSTR_SUB16:
|
|
|
|
case BX_INSTR_SBB16:
|
2007-12-05 09:17:09 +03:00
|
|
|
of = GET_SUB_OVERFLOW(BX_CPU_THIS_PTR oszapc.op1_16,
|
|
|
|
BX_CPU_THIS_PTR oszapc.op2_16,
|
|
|
|
result_16, 0x8000);
|
2007-12-04 22:27:23 +03:00
|
|
|
break;
|
|
|
|
case BX_INSTR_SUB32:
|
|
|
|
case BX_INSTR_SBB32:
|
2007-12-05 09:17:09 +03:00
|
|
|
of = GET_SUB_OVERFLOW(BX_CPU_THIS_PTR oszapc.op1_32,
|
|
|
|
BX_CPU_THIS_PTR oszapc.op2_32,
|
|
|
|
result_32, 0x80000000);
|
2007-12-04 22:27:23 +03:00
|
|
|
break;
|
2002-09-15 04:18:41 +04:00
|
|
|
#if BX_SUPPORT_X86_64
|
2007-12-04 22:27:23 +03:00
|
|
|
case BX_INSTR_SUB64:
|
|
|
|
case BX_INSTR_SBB64:
|
2007-12-05 09:17:09 +03:00
|
|
|
of = GET_SUB_OVERFLOW(BX_CPU_THIS_PTR oszapc.op1_64,
|
|
|
|
BX_CPU_THIS_PTR oszapc.op2_64,
|
|
|
|
result_64, BX_CONST64(0x8000000000000000));
|
2007-12-04 22:27:23 +03:00
|
|
|
break;
|
2002-09-15 04:18:41 +04:00
|
|
|
#endif
|
2007-12-04 22:27:23 +03:00
|
|
|
case BX_INSTR_LOGIC8:
|
|
|
|
case BX_INSTR_LOGIC16:
|
|
|
|
case BX_INSTR_LOGIC32:
|
2002-09-15 04:18:41 +04:00
|
|
|
#if BX_SUPPORT_X86_64
|
2007-12-04 22:27:23 +03:00
|
|
|
case BX_INSTR_LOGIC64:
|
2002-09-15 04:18:41 +04:00
|
|
|
#endif
|
2007-12-04 22:27:23 +03:00
|
|
|
of = 0;
|
|
|
|
break;
|
|
|
|
case BX_INSTR_NEG8:
|
|
|
|
case BX_INSTR_INC8:
|
2007-12-05 09:17:09 +03:00
|
|
|
of = (result_8 == 0x80);
|
2007-12-04 22:27:23 +03:00
|
|
|
break;
|
|
|
|
case BX_INSTR_NEG16:
|
|
|
|
case BX_INSTR_INC16:
|
2007-12-05 09:17:09 +03:00
|
|
|
of = (result_16 == 0x8000);
|
2007-12-04 22:27:23 +03:00
|
|
|
break;
|
|
|
|
case BX_INSTR_NEG32:
|
|
|
|
case BX_INSTR_INC32:
|
2007-12-05 09:17:09 +03:00
|
|
|
of = (result_32 == 0x80000000);
|
2007-12-04 22:27:23 +03:00
|
|
|
break;
|
2002-09-15 04:18:41 +04:00
|
|
|
#if BX_SUPPORT_X86_64
|
2007-12-04 22:27:23 +03:00
|
|
|
case BX_INSTR_NEG64:
|
|
|
|
case BX_INSTR_INC64:
|
2007-12-05 09:17:09 +03:00
|
|
|
of = (result_64 == BX_CONST64(0x8000000000000000));
|
2007-12-04 22:27:23 +03:00
|
|
|
break;
|
2002-09-15 04:18:41 +04:00
|
|
|
#endif
|
2007-12-04 22:27:23 +03:00
|
|
|
case BX_INSTR_DEC8:
|
2007-12-05 09:17:09 +03:00
|
|
|
of = (result_8 == 0x7F);
|
2007-12-04 22:27:23 +03:00
|
|
|
break;
|
|
|
|
case BX_INSTR_DEC16:
|
2007-12-05 09:17:09 +03:00
|
|
|
of = (result_16 == 0x7FFF);
|
2007-12-04 22:27:23 +03:00
|
|
|
break;
|
|
|
|
case BX_INSTR_DEC32:
|
2007-12-05 09:17:09 +03:00
|
|
|
of = (result_32 == 0x7FFFFFFF);
|
2007-12-04 22:27:23 +03:00
|
|
|
break;
|
2002-09-15 04:18:41 +04:00
|
|
|
#if BX_SUPPORT_X86_64
|
2007-12-04 22:27:23 +03:00
|
|
|
case BX_INSTR_DEC64:
|
2007-12-05 09:17:09 +03:00
|
|
|
of = (result_64 == BX_CONST64(0x7FFFFFFFFFFFFFFF));
|
2007-12-04 22:27:23 +03:00
|
|
|
break;
|
2002-09-15 04:18:41 +04:00
|
|
|
#endif
|
2007-12-04 22:27:23 +03:00
|
|
|
default:
|
|
|
|
of = 0; // Keep compiler happy.
|
|
|
|
BX_PANIC(("get_OF: OSZAPC: unknown instr"));
|
|
|
|
}
|
2007-12-05 09:17:09 +03:00
|
|
|
|
2007-12-04 22:27:23 +03:00
|
|
|
return(of);
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|