2001-10-03 17:10:38 +04:00
|
|
|
/////////////////////////////////////////////////////////////////////////
|
2004-09-04 14:21:28 +04:00
|
|
|
// $Id: lazy_flags.cc,v 1.27 2004-09-04 10:21:15 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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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"
|
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
|
|
|
|
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;
|
|
|
|
|
2001-04-10 05:04:59 +04:00
|
|
|
switch ( BX_CPU_THIS_PTR lf_flags_status & 0x00000f ) {
|
|
|
|
case BX_LF_INDEX_OSZAPC:
|
|
|
|
switch (BX_CPU_THIS_PTR oszapc.instr) {
|
|
|
|
case BX_INSTR_ADD8:
|
2002-09-08 08:08:14 +04:00
|
|
|
cf = (BX_CPU_THIS_PTR oszapc.result_8 <
|
2001-04-10 05:04:59 +04:00
|
|
|
BX_CPU_THIS_PTR oszapc.op1_8);
|
|
|
|
break;
|
|
|
|
case BX_INSTR_ADD16:
|
2002-09-08 08:08:14 +04:00
|
|
|
cf = (BX_CPU_THIS_PTR oszapc.result_16 <
|
2001-04-10 05:04:59 +04:00
|
|
|
BX_CPU_THIS_PTR oszapc.op1_16);
|
|
|
|
break;
|
|
|
|
case BX_INSTR_ADD32:
|
2002-09-08 08:08:14 +04:00
|
|
|
cf = (BX_CPU_THIS_PTR oszapc.result_32 <
|
2001-04-10 05:04:59 +04:00
|
|
|
BX_CPU_THIS_PTR oszapc.op1_32);
|
|
|
|
break;
|
2002-09-15 04:18:41 +04:00
|
|
|
#if BX_SUPPORT_X86_64
|
|
|
|
case BX_INSTR_ADD64:
|
|
|
|
cf = (BX_CPU_THIS_PTR oszapc.result_64 <
|
|
|
|
BX_CPU_THIS_PTR oszapc.op1_64);
|
|
|
|
break;
|
|
|
|
#endif
|
2004-08-19 00:49:31 +04:00
|
|
|
// used only if CF = 1 when executing ADC instruction
|
2001-04-10 05:04:59 +04:00
|
|
|
case BX_INSTR_ADC8:
|
2004-08-19 00:47:35 +04:00
|
|
|
cf = (BX_CPU_THIS_PTR oszapc.result_8 <=
|
|
|
|
BX_CPU_THIS_PTR oszapc.op1_8);
|
2001-04-10 05:04:59 +04:00
|
|
|
break;
|
2004-08-19 00:49:31 +04:00
|
|
|
// used only if CF = 1 when executing ADC instruction
|
2001-04-10 05:04:59 +04:00
|
|
|
case BX_INSTR_ADC16:
|
2004-08-19 00:47:35 +04:00
|
|
|
cf = (BX_CPU_THIS_PTR oszapc.result_16 <=
|
|
|
|
BX_CPU_THIS_PTR oszapc.op1_16);
|
2001-04-10 05:04:59 +04:00
|
|
|
break;
|
2004-08-19 00:49:31 +04:00
|
|
|
// used only if CF = 1 when executing ADC instruction
|
2001-04-10 05:04:59 +04:00
|
|
|
case BX_INSTR_ADC32:
|
2004-08-19 00:47:35 +04:00
|
|
|
cf = (BX_CPU_THIS_PTR oszapc.result_32 <=
|
|
|
|
BX_CPU_THIS_PTR oszapc.op1_32);
|
2001-04-10 05:04:59 +04:00
|
|
|
break;
|
2002-09-15 04:18:41 +04:00
|
|
|
#if BX_SUPPORT_X86_64
|
2004-08-19 00:49:31 +04:00
|
|
|
// used only if CF = 1 when executing ADC instruction
|
2002-09-15 04:18:41 +04:00
|
|
|
case BX_INSTR_ADC64:
|
2004-08-19 00:47:35 +04:00
|
|
|
cf = (BX_CPU_THIS_PTR oszapc.result_64 <=
|
|
|
|
BX_CPU_THIS_PTR oszapc.op1_64);
|
2002-09-15 04:18:41 +04:00
|
|
|
break;
|
|
|
|
#endif
|
2001-04-10 05:04:59 +04:00
|
|
|
case BX_INSTR_SUB8:
|
2002-09-08 08:08:14 +04:00
|
|
|
cf = (BX_CPU_THIS_PTR oszapc.op1_8 <
|
2001-04-10 05:04:59 +04:00
|
|
|
BX_CPU_THIS_PTR oszapc.op2_8);
|
|
|
|
break;
|
|
|
|
case BX_INSTR_SUB16:
|
2002-09-08 08:08:14 +04:00
|
|
|
cf = (BX_CPU_THIS_PTR oszapc.op1_16 <
|
2001-04-10 05:04:59 +04:00
|
|
|
BX_CPU_THIS_PTR oszapc.op2_16);
|
|
|
|
break;
|
|
|
|
case BX_INSTR_SUB32:
|
2002-09-08 08:08:14 +04:00
|
|
|
cf = (BX_CPU_THIS_PTR oszapc.op1_32 <
|
2001-04-10 05:04:59 +04:00
|
|
|
BX_CPU_THIS_PTR oszapc.op2_32);
|
|
|
|
break;
|
2002-09-15 04:18:41 +04:00
|
|
|
#if BX_SUPPORT_X86_64
|
|
|
|
case BX_INSTR_SUB64:
|
|
|
|
cf = (BX_CPU_THIS_PTR oszapc.op1_64 <
|
|
|
|
BX_CPU_THIS_PTR oszapc.op2_64);
|
|
|
|
break;
|
|
|
|
#endif
|
2004-08-19 00:49:31 +04:00
|
|
|
// used only if CF = 1 when executing SBB instruction
|
2001-04-10 05:04:59 +04:00
|
|
|
case BX_INSTR_SBB8:
|
2002-09-08 08:08:14 +04:00
|
|
|
cf =
|
2004-08-19 00:47:35 +04:00
|
|
|
(BX_CPU_THIS_PTR oszapc.op1_8 < BX_CPU_THIS_PTR oszapc.result_8) ||
|
|
|
|
(BX_CPU_THIS_PTR oszapc.op2_8==0xff);
|
2001-04-10 05:04:59 +04:00
|
|
|
break;
|
2004-08-19 00:49:31 +04:00
|
|
|
// used only if CF = 1 when executing SBB instruction
|
2001-04-10 05:04:59 +04:00
|
|
|
case BX_INSTR_SBB16:
|
2002-09-15 04:18:41 +04:00
|
|
|
cf =
|
2004-08-19 00:47:35 +04:00
|
|
|
(BX_CPU_THIS_PTR oszapc.op1_16 < BX_CPU_THIS_PTR oszapc.result_16) ||
|
|
|
|
(BX_CPU_THIS_PTR oszapc.op2_16==0xffff);
|
2001-04-10 05:04:59 +04:00
|
|
|
break;
|
2004-08-19 00:49:31 +04:00
|
|
|
// used only if CF = 1 when executing SBB instruction
|
2001-04-10 05:04:59 +04:00
|
|
|
case BX_INSTR_SBB32:
|
2002-09-15 04:18:41 +04:00
|
|
|
cf =
|
2004-08-19 00:47:35 +04:00
|
|
|
(BX_CPU_THIS_PTR oszapc.op1_32 < BX_CPU_THIS_PTR oszapc.result_32) ||
|
|
|
|
(BX_CPU_THIS_PTR oszapc.op2_32==0xffffffff);
|
2001-04-10 05:04:59 +04:00
|
|
|
break;
|
2002-09-15 04:18:41 +04:00
|
|
|
#if BX_SUPPORT_X86_64
|
2004-08-19 00:49:31 +04:00
|
|
|
// used only if CF = 1 when executing SBB instruction
|
2002-09-15 04:18:41 +04:00
|
|
|
case BX_INSTR_SBB64:
|
|
|
|
cf =
|
2004-08-19 00:47:35 +04:00
|
|
|
(BX_CPU_THIS_PTR oszapc.op1_64 < BX_CPU_THIS_PTR oszapc.result_64) ||
|
|
|
|
(BX_CPU_THIS_PTR oszapc.op2_64==BX_CONST64(0xffffffffffffffff));
|
2002-09-15 04:18:41 +04:00
|
|
|
break;
|
|
|
|
#endif
|
2001-04-10 05:04:59 +04:00
|
|
|
case BX_INSTR_NEG8:
|
2004-08-17 21:34:47 +04:00
|
|
|
cf = BX_CPU_THIS_PTR oszapc.result_8 != 0;
|
2001-04-10 05:04:59 +04:00
|
|
|
break;
|
|
|
|
case BX_INSTR_NEG16:
|
2004-08-17 21:34:47 +04:00
|
|
|
cf = BX_CPU_THIS_PTR oszapc.result_16 != 0;
|
2001-04-10 05:04:59 +04:00
|
|
|
break;
|
|
|
|
case BX_INSTR_NEG32:
|
2004-08-17 21:34:47 +04:00
|
|
|
cf = BX_CPU_THIS_PTR oszapc.result_32 != 0;
|
2002-09-15 04:18:41 +04:00
|
|
|
break;
|
|
|
|
#if BX_SUPPORT_X86_64
|
|
|
|
case BX_INSTR_NEG64:
|
2004-08-17 21:34:47 +04:00
|
|
|
cf = BX_CPU_THIS_PTR oszapc.result_64 != 0;
|
2001-04-10 05:04:59 +04:00
|
|
|
break;
|
2002-09-15 04:18:41 +04:00
|
|
|
#endif
|
2004-08-10 01:28:47 +04:00
|
|
|
case BX_INSTR_LOGIC8:
|
|
|
|
case BX_INSTR_LOGIC16:
|
|
|
|
case BX_INSTR_LOGIC32:
|
2004-08-14 23:34:02 +04:00
|
|
|
case BX_INSTR_BITSCAN16:
|
|
|
|
case BX_INSTR_BITSCAN32:
|
2002-09-15 04:18:41 +04:00
|
|
|
#if BX_SUPPORT_X86_64
|
2004-08-10 01:28:47 +04:00
|
|
|
case BX_INSTR_LOGIC64:
|
2004-08-14 23:34:02 +04:00
|
|
|
case BX_INSTR_BITSCAN64:
|
2002-09-15 04:18:41 +04:00
|
|
|
#endif
|
2002-09-08 08:08:14 +04:00
|
|
|
cf = 0;
|
2001-04-10 05:04:59 +04:00
|
|
|
break;
|
2004-08-16 00:12:05 +04:00
|
|
|
case BX_INSTR_SAR8:
|
2004-08-16 00:31:27 +04:00
|
|
|
if (BX_CPU_THIS_PTR oszapc.op2_8 < 8) {
|
|
|
|
cf =
|
|
|
|
(BX_CPU_THIS_PTR oszapc.op1_8 >>
|
|
|
|
(BX_CPU_THIS_PTR oszapc.op2_8 - 1)) & 0x01;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
cf = (BX_CPU_THIS_PTR oszapc.op1_8 & 0x80) > 0;
|
|
|
|
}
|
|
|
|
break;
|
2001-04-10 05:04:59 +04:00
|
|
|
case BX_INSTR_SHR8:
|
2004-08-16 00:31:27 +04:00
|
|
|
cf =
|
|
|
|
(BX_CPU_THIS_PTR oszapc.op1_8 >>
|
|
|
|
(BX_CPU_THIS_PTR oszapc.op2_8 - 1)) & 0x01;
|
2001-04-10 05:04:59 +04:00
|
|
|
break;
|
2004-08-16 00:12:05 +04:00
|
|
|
case BX_INSTR_SAR16:
|
2004-08-16 00:31:27 +04:00
|
|
|
if (BX_CPU_THIS_PTR oszapc.op2_16 < 16) {
|
|
|
|
cf =
|
|
|
|
(BX_CPU_THIS_PTR oszapc.op1_16 >>
|
|
|
|
(BX_CPU_THIS_PTR oszapc.op2_16 - 1)) & 0x01;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
cf = (BX_CPU_THIS_PTR oszapc.op1_16 & 0x8000) > 0;
|
|
|
|
}
|
|
|
|
break;
|
2001-04-10 05:04:59 +04:00
|
|
|
case BX_INSTR_SHR16:
|
2004-08-16 00:31:27 +04:00
|
|
|
cf =
|
|
|
|
(BX_CPU_THIS_PTR oszapc.op1_16 >>
|
|
|
|
(BX_CPU_THIS_PTR oszapc.op2_16 - 1)) & 0x01;
|
2001-04-10 05:04:59 +04:00
|
|
|
break;
|
2004-08-16 00:12:05 +04:00
|
|
|
case BX_INSTR_SAR32:
|
2001-04-10 05:04:59 +04:00
|
|
|
case BX_INSTR_SHR32:
|
2004-08-16 00:31:27 +04:00
|
|
|
cf =
|
|
|
|
(BX_CPU_THIS_PTR oszapc.op1_32 >>
|
|
|
|
(BX_CPU_THIS_PTR oszapc.op2_32 - 1)) & 0x01;
|
2001-04-10 05:04:59 +04:00
|
|
|
break;
|
2002-09-15 04:18:41 +04:00
|
|
|
#if BX_SUPPORT_X86_64
|
2004-08-16 00:12:05 +04:00
|
|
|
case BX_INSTR_SAR64:
|
2002-09-15 04:18:41 +04:00
|
|
|
case BX_INSTR_SHR64:
|
2004-08-16 00:31:27 +04:00
|
|
|
cf =
|
|
|
|
(BX_CPU_THIS_PTR oszapc.op1_64 >>
|
|
|
|
(BX_CPU_THIS_PTR oszapc.op2_64 - 1)) & 0x01;
|
2002-09-15 04:18:41 +04:00
|
|
|
break;
|
|
|
|
#endif
|
2001-04-10 05:04:59 +04:00
|
|
|
case BX_INSTR_SHL8:
|
|
|
|
if (BX_CPU_THIS_PTR oszapc.op2_8 <= 8) {
|
2002-09-08 08:08:14 +04:00
|
|
|
cf =
|
2001-04-10 05:04:59 +04:00
|
|
|
(BX_CPU_THIS_PTR oszapc.op1_8 >>
|
|
|
|
(8 - BX_CPU_THIS_PTR oszapc.op2_8)) & 0x01;
|
|
|
|
}
|
|
|
|
else {
|
2002-09-08 08:08:14 +04:00
|
|
|
cf = 0;
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case BX_INSTR_SHL16:
|
|
|
|
if (BX_CPU_THIS_PTR oszapc.op2_16 <= 16) {
|
2002-09-08 08:08:14 +04:00
|
|
|
cf =
|
2001-04-10 05:04:59 +04:00
|
|
|
(BX_CPU_THIS_PTR oszapc.op1_16 >>
|
|
|
|
(16 - BX_CPU_THIS_PTR oszapc.op2_16)) & 0x01;
|
|
|
|
}
|
|
|
|
else {
|
2002-09-08 08:08:14 +04:00
|
|
|
cf = 0;
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case BX_INSTR_SHL32:
|
2002-09-08 08:08:14 +04:00
|
|
|
cf =
|
2001-04-10 05:04:59 +04:00
|
|
|
(BX_CPU_THIS_PTR oszapc.op1_32 >>
|
|
|
|
(32 - BX_CPU_THIS_PTR oszapc.op2_32)) & 0x01;
|
|
|
|
break;
|
2002-09-15 04:18:41 +04:00
|
|
|
#if BX_SUPPORT_X86_64
|
|
|
|
case BX_INSTR_SHL64:
|
|
|
|
cf =
|
|
|
|
(BX_CPU_THIS_PTR oszapc.op1_64 >>
|
2004-08-14 23:34:02 +04:00
|
|
|
(64 - BX_CPU_THIS_PTR oszapc.op2_64)) & 0x01;
|
2002-09-15 04:18:41 +04:00
|
|
|
break;
|
2004-08-27 00:37:50 +04:00
|
|
|
#endif
|
2004-08-31 23:43:58 +04:00
|
|
|
case BX_INSTR_IMUL8:
|
2004-08-31 01:47:24 +04:00
|
|
|
cf = ! ((BX_CPU_THIS_PTR oszapc.op1_8 < 0x80 &&
|
|
|
|
BX_CPU_THIS_PTR oszapc.op2_8 == 0) ||
|
|
|
|
((BX_CPU_THIS_PTR oszapc.op1_8 & 0x80) &&
|
|
|
|
BX_CPU_THIS_PTR oszapc.op2_8 == 0xff));
|
|
|
|
break;
|
|
|
|
case BX_INSTR_IMUL16:
|
|
|
|
cf = ! ((BX_CPU_THIS_PTR oszapc.op1_16 < 0x8000 &&
|
|
|
|
BX_CPU_THIS_PTR oszapc.op2_16 == 0) ||
|
|
|
|
((BX_CPU_THIS_PTR oszapc.op1_16 & 0x8000) &&
|
|
|
|
BX_CPU_THIS_PTR oszapc.op2_16 == 0xffff));
|
|
|
|
break;
|
|
|
|
case BX_INSTR_IMUL32:
|
|
|
|
cf = ! ((BX_CPU_THIS_PTR oszapc.op1_32 < 0x80000000 &&
|
|
|
|
BX_CPU_THIS_PTR oszapc.op2_32 == 0) ||
|
|
|
|
((BX_CPU_THIS_PTR oszapc.op1_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.op1_64 < BX_CONST64(0x8000000000000000) &&
|
|
|
|
BX_CPU_THIS_PTR oszapc.op2_64 == 0) ||
|
|
|
|
((BX_CPU_THIS_PTR oszapc.op1_64 & BX_CONST64(0x8000000000000000)) &&
|
|
|
|
BX_CPU_THIS_PTR oszapc.op2_64 == BX_CONST64(0xffffffffffffffff)));
|
|
|
|
break;
|
|
|
|
#endif
|
2004-08-31 23:43:58 +04:00
|
|
|
case BX_INSTR_MUL8:
|
2004-08-27 00:37:50 +04:00
|
|
|
cf = (BX_CPU_THIS_PTR oszapc.op2_8 != 0);
|
|
|
|
break;
|
2004-08-31 23:43:58 +04:00
|
|
|
case BX_INSTR_MUL16:
|
2004-08-27 00:37:50 +04:00
|
|
|
cf = (BX_CPU_THIS_PTR oszapc.op2_16 != 0);
|
|
|
|
break;
|
2004-08-31 23:43:58 +04:00
|
|
|
case BX_INSTR_MUL32:
|
2004-08-27 00:37:50 +04:00
|
|
|
cf = (BX_CPU_THIS_PTR oszapc.op2_32 != 0);
|
|
|
|
break;
|
|
|
|
#if BX_SUPPORT_X86_64
|
2004-08-31 23:43:58 +04:00
|
|
|
case BX_INSTR_MUL64:
|
2004-08-27 00:37:50 +04:00
|
|
|
cf = (BX_CPU_THIS_PTR oszapc.op2_64 != 0);
|
|
|
|
break;
|
2002-09-15 04:18:41 +04:00
|
|
|
#endif
|
2001-04-10 05:04:59 +04:00
|
|
|
default:
|
2002-09-08 08:08:14 +04:00
|
|
|
cf = 0; // Keep compiler quiet.
|
2001-05-30 22:56:02 +04:00
|
|
|
BX_PANIC(("get_CF: OSZAPC: unknown instr %u",
|
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
|
|
|
(unsigned) BX_CPU_THIS_PTR oszapc.instr));
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
|
|
|
BX_CPU_THIS_PTR lf_flags_status &= 0xfffff0;
|
2002-09-08 08:08:14 +04:00
|
|
|
BX_CPU_THIS_PTR eflags.val32 &= ~(1<<0);
|
|
|
|
BX_CPU_THIS_PTR eflags.val32 |= (!!cf)<<0;
|
|
|
|
return(cf);
|
2001-04-10 05:04:59 +04:00
|
|
|
|
|
|
|
default:
|
2001-05-30 22:56:02 +04:00
|
|
|
BX_PANIC(("get_CF: unknown case"));
|
2001-04-10 05:04:59 +04:00
|
|
|
return(0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
|
2001-04-10 05:04:59 +04:00
|
|
|
switch ( (BX_CPU_THIS_PTR lf_flags_status>>8) & 0x00000f ) {
|
|
|
|
case BX_LF_INDEX_OSZAPC:
|
|
|
|
switch (BX_CPU_THIS_PTR oszapc.instr) {
|
|
|
|
case BX_INSTR_ADD8:
|
|
|
|
case BX_INSTR_ADC8:
|
|
|
|
case BX_INSTR_SUB8:
|
|
|
|
case BX_INSTR_SBB8:
|
2002-09-08 08:08:14 +04:00
|
|
|
af =
|
2001-04-10 05:04:59 +04:00
|
|
|
((BX_CPU_THIS_PTR oszapc.op1_8 ^
|
|
|
|
BX_CPU_THIS_PTR oszapc.op2_8) ^
|
|
|
|
BX_CPU_THIS_PTR oszapc.result_8) & 0x10;
|
|
|
|
break;
|
|
|
|
case BX_INSTR_ADD16:
|
|
|
|
case BX_INSTR_ADC16:
|
|
|
|
case BX_INSTR_SUB16:
|
|
|
|
case BX_INSTR_SBB16:
|
2002-09-08 08:08:14 +04:00
|
|
|
af =
|
2001-04-10 05:04:59 +04:00
|
|
|
((BX_CPU_THIS_PTR oszapc.op1_16 ^
|
|
|
|
BX_CPU_THIS_PTR oszapc.op2_16) ^
|
|
|
|
BX_CPU_THIS_PTR oszapc.result_16) & 0x10;
|
|
|
|
break;
|
|
|
|
case BX_INSTR_ADD32:
|
|
|
|
case BX_INSTR_ADC32:
|
|
|
|
case BX_INSTR_SUB32:
|
|
|
|
case BX_INSTR_SBB32:
|
2002-09-08 08:08:14 +04:00
|
|
|
af =
|
2001-04-10 05:04:59 +04:00
|
|
|
((BX_CPU_THIS_PTR oszapc.op1_32 ^
|
|
|
|
BX_CPU_THIS_PTR oszapc.op2_32) ^
|
|
|
|
BX_CPU_THIS_PTR oszapc.result_32) & 0x10;
|
|
|
|
break;
|
2002-09-15 04:18:41 +04:00
|
|
|
#if BX_SUPPORT_X86_64
|
|
|
|
case BX_INSTR_ADD64:
|
|
|
|
case BX_INSTR_ADC64:
|
|
|
|
case BX_INSTR_SUB64:
|
|
|
|
case BX_INSTR_SBB64:
|
2002-09-08 08:08:14 +04:00
|
|
|
af =
|
2002-09-15 04:18:41 +04:00
|
|
|
((BX_CPU_THIS_PTR oszapc.op1_64 ^
|
|
|
|
BX_CPU_THIS_PTR oszapc.op2_64) ^
|
|
|
|
BX_CPU_THIS_PTR oszapc.result_64) & 0x10;
|
|
|
|
break;
|
|
|
|
#endif
|
|
|
|
case BX_INSTR_NEG8:
|
2004-08-17 21:34:47 +04:00
|
|
|
af = (BX_CPU_THIS_PTR oszapc.result_8 & 0x0f) != 0;
|
2001-04-10 05:04:59 +04:00
|
|
|
break;
|
|
|
|
case BX_INSTR_NEG16:
|
2004-08-17 21:34:47 +04:00
|
|
|
af = (BX_CPU_THIS_PTR oszapc.result_16 & 0x0f) != 0;
|
2001-04-10 05:04:59 +04:00
|
|
|
break;
|
|
|
|
case BX_INSTR_NEG32:
|
2004-08-17 21:34:47 +04:00
|
|
|
af = (BX_CPU_THIS_PTR oszapc.result_32 & 0x0f) != 0;
|
2001-04-10 05:04:59 +04:00
|
|
|
break;
|
2002-09-15 04:18:41 +04:00
|
|
|
#if BX_SUPPORT_X86_64
|
|
|
|
case BX_INSTR_NEG64:
|
2004-08-17 21:34:47 +04:00
|
|
|
af = (BX_CPU_THIS_PTR oszapc.result_64 & 0x0f) != 0;
|
2002-09-15 04:18:41 +04:00
|
|
|
break;
|
|
|
|
#endif
|
2004-08-10 01:28:47 +04:00
|
|
|
case BX_INSTR_LOGIC8:
|
|
|
|
case BX_INSTR_LOGIC16:
|
|
|
|
case BX_INSTR_LOGIC32:
|
2004-08-14 23:34:02 +04:00
|
|
|
case BX_INSTR_BITSCAN16:
|
|
|
|
case BX_INSTR_BITSCAN32:
|
2002-09-15 04:18:41 +04:00
|
|
|
#if BX_SUPPORT_X86_64
|
2004-08-10 01:28:47 +04:00
|
|
|
case BX_INSTR_LOGIC64:
|
2004-08-14 23:34:02 +04:00
|
|
|
case BX_INSTR_BITSCAN64:
|
2004-08-16 00:12:05 +04:00
|
|
|
case BX_INSTR_SAR64:
|
2002-09-15 04:18:41 +04:00
|
|
|
case BX_INSTR_SHR64:
|
|
|
|
case BX_INSTR_SHL64:
|
2004-08-31 01:47:24 +04:00
|
|
|
case BX_INSTR_IMUL64:
|
2004-08-31 23:43:58 +04:00
|
|
|
case BX_INSTR_MUL64:
|
2002-09-15 04:18:41 +04:00
|
|
|
#endif
|
2004-08-16 00:12:05 +04:00
|
|
|
case BX_INSTR_SAR8:
|
|
|
|
case BX_INSTR_SAR16:
|
|
|
|
case BX_INSTR_SAR32:
|
2001-04-10 05:04:59 +04:00
|
|
|
case BX_INSTR_SHR8:
|
|
|
|
case BX_INSTR_SHR16:
|
|
|
|
case BX_INSTR_SHR32:
|
|
|
|
case BX_INSTR_SHL8:
|
|
|
|
case BX_INSTR_SHL16:
|
|
|
|
case BX_INSTR_SHL32:
|
2004-08-31 23:43:58 +04:00
|
|
|
case BX_INSTR_IMUL8:
|
2004-08-31 01:47:24 +04:00
|
|
|
case BX_INSTR_IMUL16:
|
|
|
|
case BX_INSTR_IMUL32:
|
2004-08-31 23:43:58 +04:00
|
|
|
case BX_INSTR_MUL8:
|
|
|
|
case BX_INSTR_MUL16:
|
|
|
|
case BX_INSTR_MUL32:
|
2002-09-08 08:08:14 +04:00
|
|
|
af = 0;
|
2001-04-10 05:04:59 +04:00
|
|
|
break;
|
|
|
|
default:
|
2002-10-04 21:04:33 +04:00
|
|
|
af = 0; // Keep compiler quiet.
|
2001-05-30 22:56:02 +04:00
|
|
|
BX_PANIC(("get_AF: OSZAPC: unknown instr %u",
|
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
|
|
|
(unsigned) BX_CPU_THIS_PTR oszapc.instr));
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
|
|
|
BX_CPU_THIS_PTR lf_flags_status &= 0xfff0ff;
|
2002-09-08 08:08:14 +04:00
|
|
|
BX_CPU_THIS_PTR eflags.val32 &= ~(1<<4);
|
|
|
|
BX_CPU_THIS_PTR eflags.val32 |= (!!af)<<4;
|
|
|
|
return(af);
|
2001-04-10 05:04:59 +04:00
|
|
|
|
|
|
|
case BX_LF_INDEX_OSZAP:
|
|
|
|
switch (BX_CPU_THIS_PTR oszap.instr) {
|
|
|
|
case BX_INSTR_INC8:
|
2002-09-15 04:18:41 +04:00
|
|
|
af = (BX_CPU_THIS_PTR oszap.result_8 & 0x0f) == 0;
|
2001-04-10 05:04:59 +04:00
|
|
|
break;
|
|
|
|
case BX_INSTR_INC16:
|
2002-09-15 04:18:41 +04:00
|
|
|
af = (BX_CPU_THIS_PTR oszap.result_16 & 0x0f) == 0;
|
2001-04-10 05:04:59 +04:00
|
|
|
break;
|
|
|
|
case BX_INSTR_INC32:
|
2002-10-04 21:04:33 +04:00
|
|
|
af = (BX_CPU_THIS_PTR oszap.result_32 & 0x0f) == 0;
|
2001-04-10 05:04:59 +04:00
|
|
|
break;
|
2002-09-15 04:18:41 +04:00
|
|
|
#if BX_SUPPORT_X86_64
|
|
|
|
case BX_INSTR_INC64:
|
2002-10-04 21:04:33 +04:00
|
|
|
af = (BX_CPU_THIS_PTR oszap.result_64 & 0x0f) == 0;
|
2002-09-15 04:18:41 +04:00
|
|
|
break;
|
|
|
|
#endif
|
2001-04-10 05:04:59 +04:00
|
|
|
case BX_INSTR_DEC8:
|
2002-10-04 21:04:33 +04:00
|
|
|
af = (BX_CPU_THIS_PTR oszap.result_8 & 0x0f) == 0x0f;
|
2001-04-10 05:04:59 +04:00
|
|
|
break;
|
|
|
|
case BX_INSTR_DEC16:
|
2002-10-04 21:04:33 +04:00
|
|
|
af = (BX_CPU_THIS_PTR oszap.result_16 & 0x0f) == 0x0f;
|
2001-04-10 05:04:59 +04:00
|
|
|
break;
|
|
|
|
case BX_INSTR_DEC32:
|
2002-10-04 21:04:33 +04:00
|
|
|
af = (BX_CPU_THIS_PTR oszap.result_32 & 0x0f) == 0x0f;
|
2002-09-15 04:18:41 +04:00
|
|
|
break;
|
|
|
|
#if BX_SUPPORT_X86_64
|
|
|
|
case BX_INSTR_DEC64:
|
2002-10-04 21:04:33 +04:00
|
|
|
af = (BX_CPU_THIS_PTR oszap.result_64 & 0x0f) == 0x0f;
|
2001-04-10 05:04:59 +04:00
|
|
|
break;
|
2002-09-15 04:18:41 +04:00
|
|
|
#endif
|
2001-04-10 05:04:59 +04:00
|
|
|
default:
|
2002-09-08 08:08:14 +04:00
|
|
|
af = 0; // Keep compiler quiet.
|
2001-05-30 22:56:02 +04:00
|
|
|
BX_PANIC(("get_AF: OSZAP: unknown instr %u",
|
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
|
|
|
(unsigned) BX_CPU_THIS_PTR oszap.instr));
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
|
|
|
BX_CPU_THIS_PTR lf_flags_status &= 0xfff0ff;
|
2002-09-08 08:08:14 +04:00
|
|
|
BX_CPU_THIS_PTR eflags.val32 &= ~(1<<4);
|
|
|
|
BX_CPU_THIS_PTR eflags.val32 |= (!!af)<<4;
|
|
|
|
return(af);
|
2001-04-10 05:04:59 +04:00
|
|
|
|
|
|
|
default:
|
2001-05-30 22:56:02 +04:00
|
|
|
BX_PANIC(("get_AF: unknown case"));
|
2001-04-10 05:04:59 +04:00
|
|
|
return(0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-08-10 01:28:47 +04:00
|
|
|
bx_bool BX_CPU_C::get_ZFLazy(void)
|
2001-04-10 05:04:59 +04:00
|
|
|
{
|
2002-09-08 08:08:14 +04:00
|
|
|
unsigned zf;
|
|
|
|
|
2001-04-10 05:04:59 +04:00
|
|
|
switch ( (BX_CPU_THIS_PTR lf_flags_status>>12) & 0x00000f ) {
|
|
|
|
case BX_LF_INDEX_OSZAPC:
|
|
|
|
switch (BX_CPU_THIS_PTR oszapc.instr) {
|
2004-08-10 01:28:47 +04:00
|
|
|
case BX_INSTR_LOGIC8:
|
2001-04-10 05:04:59 +04:00
|
|
|
case BX_INSTR_ADD8:
|
|
|
|
case BX_INSTR_ADC8:
|
|
|
|
case BX_INSTR_SUB8:
|
|
|
|
case BX_INSTR_SBB8:
|
|
|
|
case BX_INSTR_NEG8:
|
2004-08-16 00:12:05 +04:00
|
|
|
case BX_INSTR_SAR8:
|
2001-04-10 05:04:59 +04:00
|
|
|
case BX_INSTR_SHR8:
|
|
|
|
case BX_INSTR_SHL8:
|
2002-09-08 08:08:14 +04:00
|
|
|
zf = (BX_CPU_THIS_PTR oszapc.result_8 == 0);
|
2001-04-10 05:04:59 +04:00
|
|
|
break;
|
2004-08-10 01:28:47 +04:00
|
|
|
case BX_INSTR_LOGIC16:
|
2001-04-10 05:04:59 +04:00
|
|
|
case BX_INSTR_ADD16:
|
|
|
|
case BX_INSTR_ADC16:
|
|
|
|
case BX_INSTR_SUB16:
|
|
|
|
case BX_INSTR_SBB16:
|
|
|
|
case BX_INSTR_NEG16:
|
2004-08-16 00:12:05 +04:00
|
|
|
case BX_INSTR_SAR16:
|
2001-04-10 05:04:59 +04:00
|
|
|
case BX_INSTR_SHR16:
|
|
|
|
case BX_INSTR_SHL16:
|
2002-09-08 08:08:14 +04:00
|
|
|
zf = (BX_CPU_THIS_PTR oszapc.result_16 == 0);
|
2001-04-10 05:04:59 +04:00
|
|
|
break;
|
2004-08-10 01:28:47 +04:00
|
|
|
case BX_INSTR_LOGIC32:
|
2001-04-10 05:04:59 +04:00
|
|
|
case BX_INSTR_ADD32:
|
|
|
|
case BX_INSTR_ADC32:
|
|
|
|
case BX_INSTR_SUB32:
|
|
|
|
case BX_INSTR_SBB32:
|
|
|
|
case BX_INSTR_NEG32:
|
2004-08-16 00:12:05 +04:00
|
|
|
case BX_INSTR_SAR32:
|
2001-04-10 05:04:59 +04:00
|
|
|
case BX_INSTR_SHR32:
|
|
|
|
case BX_INSTR_SHL32:
|
2002-09-08 08:08:14 +04:00
|
|
|
zf = (BX_CPU_THIS_PTR oszapc.result_32 == 0);
|
2001-04-10 05:04:59 +04:00
|
|
|
break;
|
2002-09-15 04:18:41 +04:00
|
|
|
#if BX_SUPPORT_X86_64
|
2004-08-10 01:28:47 +04:00
|
|
|
case BX_INSTR_LOGIC64:
|
2002-09-15 04:18:41 +04:00
|
|
|
case BX_INSTR_ADD64:
|
|
|
|
case BX_INSTR_ADC64:
|
|
|
|
case BX_INSTR_SUB64:
|
|
|
|
case BX_INSTR_SBB64:
|
|
|
|
case BX_INSTR_NEG64:
|
2004-08-16 00:12:05 +04:00
|
|
|
case BX_INSTR_SAR64:
|
2002-09-15 04:18:41 +04:00
|
|
|
case BX_INSTR_SHR64:
|
|
|
|
case BX_INSTR_SHL64:
|
|
|
|
zf = (BX_CPU_THIS_PTR oszapc.result_64 == 0);
|
|
|
|
break;
|
2004-08-27 00:37:50 +04:00
|
|
|
#endif
|
2004-08-31 23:43:58 +04:00
|
|
|
case BX_INSTR_IMUL8:
|
|
|
|
case BX_INSTR_MUL8:
|
|
|
|
zf = (BX_CPU_THIS_PTR oszapc.op1_8 == 0);
|
2004-08-27 00:37:50 +04:00
|
|
|
break;
|
2004-08-31 01:47:24 +04:00
|
|
|
case BX_INSTR_IMUL16:
|
2004-08-31 23:43:58 +04:00
|
|
|
case BX_INSTR_MUL16:
|
2004-08-31 01:47:24 +04:00
|
|
|
zf = (BX_CPU_THIS_PTR oszapc.op1_16 == 0);
|
|
|
|
break;
|
|
|
|
case BX_INSTR_IMUL32:
|
2004-08-31 23:43:58 +04:00
|
|
|
case BX_INSTR_MUL32:
|
2004-08-31 01:47:24 +04:00
|
|
|
zf = (BX_CPU_THIS_PTR oszapc.op1_32 == 0);
|
|
|
|
break;
|
|
|
|
#if BX_SUPPORT_X86_64
|
|
|
|
case BX_INSTR_IMUL64:
|
2004-08-31 23:43:58 +04:00
|
|
|
case BX_INSTR_MUL64:
|
2004-08-31 01:47:24 +04:00
|
|
|
zf = (BX_CPU_THIS_PTR oszapc.op1_64 == 0);
|
|
|
|
break;
|
2002-09-15 04:18:41 +04:00
|
|
|
#endif
|
2004-08-14 23:34:02 +04:00
|
|
|
case BX_INSTR_BITSCAN16:
|
|
|
|
case BX_INSTR_BITSCAN32:
|
|
|
|
#if BX_SUPPORT_X86_64
|
|
|
|
case BX_INSTR_BITSCAN64:
|
|
|
|
#endif
|
|
|
|
zf = 0;
|
|
|
|
break;
|
2001-04-10 05:04:59 +04:00
|
|
|
default:
|
2002-09-08 08:08:14 +04:00
|
|
|
zf = 0;
|
2001-05-30 22:56:02 +04:00
|
|
|
BX_PANIC(("get_ZF: OSZAPC: unknown instr"));
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
|
|
|
BX_CPU_THIS_PTR lf_flags_status &= 0xff0fff;
|
2002-09-08 08:08:14 +04:00
|
|
|
BX_CPU_THIS_PTR eflags.val32 &= ~(1<<6);
|
2002-09-22 22:22:24 +04:00
|
|
|
BX_CPU_THIS_PTR eflags.val32 |= zf<<6; // zf always exactly 0 or 1.
|
2002-09-08 08:08:14 +04:00
|
|
|
return(zf);
|
2001-04-10 05:04:59 +04:00
|
|
|
|
|
|
|
case BX_LF_INDEX_OSZAP:
|
|
|
|
switch (BX_CPU_THIS_PTR oszap.instr) {
|
|
|
|
case BX_INSTR_INC8:
|
|
|
|
case BX_INSTR_DEC8:
|
2002-09-08 08:08:14 +04:00
|
|
|
zf = (BX_CPU_THIS_PTR oszap.result_8 == 0);
|
2001-04-10 05:04:59 +04:00
|
|
|
break;
|
|
|
|
case BX_INSTR_INC16:
|
|
|
|
case BX_INSTR_DEC16:
|
2002-09-08 08:08:14 +04:00
|
|
|
zf = (BX_CPU_THIS_PTR oszap.result_16 == 0);
|
2001-04-10 05:04:59 +04:00
|
|
|
break;
|
|
|
|
case BX_INSTR_INC32:
|
|
|
|
case BX_INSTR_DEC32:
|
2002-09-08 08:08:14 +04:00
|
|
|
zf = (BX_CPU_THIS_PTR oszap.result_32 == 0);
|
2001-04-10 05:04:59 +04:00
|
|
|
break;
|
2002-09-15 04:18:41 +04:00
|
|
|
#if BX_SUPPORT_X86_64
|
|
|
|
case BX_INSTR_INC64:
|
|
|
|
case BX_INSTR_DEC64:
|
|
|
|
zf = (BX_CPU_THIS_PTR oszap.result_64 == 0);
|
|
|
|
break;
|
|
|
|
#endif
|
2001-04-10 05:04:59 +04:00
|
|
|
default:
|
2002-10-04 21:04:33 +04:00
|
|
|
zf = 0;
|
2001-05-30 22:56:02 +04:00
|
|
|
BX_PANIC(("get_ZF: OSZAP: unknown instr"));
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
|
|
|
BX_CPU_THIS_PTR lf_flags_status &= 0xff0fff;
|
2002-09-08 08:08:14 +04:00
|
|
|
BX_CPU_THIS_PTR eflags.val32 &= ~(1<<6);
|
2002-09-22 22:22:24 +04:00
|
|
|
BX_CPU_THIS_PTR eflags.val32 |= zf<<6; // zf always exactly 0 or 1.
|
2002-09-08 08:08:14 +04:00
|
|
|
return(zf);
|
2001-04-10 05:04:59 +04:00
|
|
|
|
|
|
|
default:
|
2001-05-30 22:56:02 +04:00
|
|
|
BX_PANIC(("get_ZF: unknown case"));
|
2001-04-10 05:04:59 +04:00
|
|
|
return(0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-08-10 01:28:47 +04:00
|
|
|
bx_bool BX_CPU_C::get_SFLazy(void)
|
2001-04-10 05:04:59 +04:00
|
|
|
{
|
2002-09-08 08:08:14 +04:00
|
|
|
unsigned sf;
|
|
|
|
|
2001-04-10 05:04:59 +04:00
|
|
|
switch ( (BX_CPU_THIS_PTR lf_flags_status>>16) & 0x00000f ) {
|
|
|
|
case BX_LF_INDEX_OSZAPC:
|
|
|
|
switch (BX_CPU_THIS_PTR oszapc.instr) {
|
2004-08-10 01:28:47 +04:00
|
|
|
case BX_INSTR_LOGIC8:
|
2001-04-10 05:04:59 +04:00
|
|
|
case BX_INSTR_ADD8:
|
|
|
|
case BX_INSTR_ADC8:
|
|
|
|
case BX_INSTR_SUB8:
|
|
|
|
case BX_INSTR_SBB8:
|
|
|
|
case BX_INSTR_NEG8:
|
2004-08-16 00:12:05 +04:00
|
|
|
case BX_INSTR_SAR8:
|
2001-04-10 05:04:59 +04:00
|
|
|
case BX_INSTR_SHR8:
|
|
|
|
case BX_INSTR_SHL8:
|
2002-09-15 04:18:41 +04:00
|
|
|
sf = (BX_CPU_THIS_PTR oszapc.result_8 >= 0x80);
|
2001-04-10 05:04:59 +04:00
|
|
|
break;
|
2004-08-10 01:28:47 +04:00
|
|
|
case BX_INSTR_LOGIC16:
|
2001-04-10 05:04:59 +04:00
|
|
|
case BX_INSTR_ADD16:
|
|
|
|
case BX_INSTR_ADC16:
|
|
|
|
case BX_INSTR_SUB16:
|
|
|
|
case BX_INSTR_SBB16:
|
|
|
|
case BX_INSTR_NEG16:
|
2004-08-16 00:12:05 +04:00
|
|
|
case BX_INSTR_SAR16:
|
2001-04-10 05:04:59 +04:00
|
|
|
case BX_INSTR_SHR16:
|
|
|
|
case BX_INSTR_SHL16:
|
2004-08-14 23:34:02 +04:00
|
|
|
case BX_INSTR_BITSCAN16:
|
2002-09-15 04:18:41 +04:00
|
|
|
sf = (BX_CPU_THIS_PTR oszapc.result_16 >= 0x8000);
|
2001-04-10 05:04:59 +04:00
|
|
|
break;
|
2004-08-10 01:28:47 +04:00
|
|
|
case BX_INSTR_LOGIC32:
|
2001-04-10 05:04:59 +04:00
|
|
|
case BX_INSTR_ADD32:
|
|
|
|
case BX_INSTR_ADC32:
|
|
|
|
case BX_INSTR_SUB32:
|
|
|
|
case BX_INSTR_SBB32:
|
|
|
|
case BX_INSTR_NEG32:
|
2004-08-16 00:12:05 +04:00
|
|
|
case BX_INSTR_SAR32:
|
2001-04-10 05:04:59 +04:00
|
|
|
case BX_INSTR_SHR32:
|
|
|
|
case BX_INSTR_SHL32:
|
2004-08-14 23:34:02 +04:00
|
|
|
case BX_INSTR_BITSCAN32:
|
2002-09-15 04:18:41 +04:00
|
|
|
sf = (BX_CPU_THIS_PTR oszapc.result_32 >= 0x80000000);
|
|
|
|
break;
|
|
|
|
#if BX_SUPPORT_X86_64
|
2004-08-10 01:28:47 +04:00
|
|
|
case BX_INSTR_LOGIC64:
|
2002-09-15 04:18:41 +04:00
|
|
|
case BX_INSTR_ADD64:
|
|
|
|
case BX_INSTR_ADC64:
|
|
|
|
case BX_INSTR_SUB64:
|
|
|
|
case BX_INSTR_SBB64:
|
|
|
|
case BX_INSTR_NEG64:
|
2004-08-16 00:12:05 +04:00
|
|
|
case BX_INSTR_SAR64:
|
2002-09-15 04:18:41 +04:00
|
|
|
case BX_INSTR_SHR64:
|
|
|
|
case BX_INSTR_SHL64:
|
2004-08-14 23:34:02 +04:00
|
|
|
case BX_INSTR_BITSCAN64:
|
2002-09-15 04:18:41 +04:00
|
|
|
sf = (BX_CPU_THIS_PTR oszapc.result_64 >= BX_CONST64(0x8000000000000000));
|
|
|
|
break;
|
2004-08-27 00:37:50 +04:00
|
|
|
#endif
|
2004-08-31 23:43:58 +04:00
|
|
|
case BX_INSTR_IMUL8:
|
|
|
|
case BX_INSTR_MUL8:
|
|
|
|
sf = (BX_CPU_THIS_PTR oszapc.op1_8 >= 0x80);
|
2004-08-27 00:37:50 +04:00
|
|
|
break;
|
2004-08-31 01:47:24 +04:00
|
|
|
case BX_INSTR_IMUL16:
|
2004-08-31 23:43:58 +04:00
|
|
|
case BX_INSTR_MUL16:
|
2004-08-31 01:47:24 +04:00
|
|
|
sf = (BX_CPU_THIS_PTR oszapc.op1_16 >= 0x8000);
|
|
|
|
break;
|
|
|
|
case BX_INSTR_IMUL32:
|
2004-08-31 23:43:58 +04:00
|
|
|
case BX_INSTR_MUL32:
|
2004-08-31 01:47:24 +04:00
|
|
|
sf = (BX_CPU_THIS_PTR oszapc.op1_32 >= 0x80000000);
|
|
|
|
break;
|
|
|
|
#if BX_SUPPORT_X86_64
|
|
|
|
case BX_INSTR_IMUL64:
|
2004-08-31 23:43:58 +04:00
|
|
|
case BX_INSTR_MUL64:
|
2004-08-31 01:47:24 +04:00
|
|
|
sf = (BX_CPU_THIS_PTR oszapc.op1_64 >= BX_CONST64(0x8000000000000000));
|
|
|
|
break;
|
2002-09-15 04:18:41 +04:00
|
|
|
#endif
|
2001-04-10 05:04:59 +04:00
|
|
|
default:
|
2002-09-08 08:08:14 +04:00
|
|
|
sf = 0; // Keep compiler quiet.
|
2001-05-30 22:56:02 +04:00
|
|
|
BX_PANIC(("get_SF: OSZAPC: unknown instr"));
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
|
|
|
BX_CPU_THIS_PTR lf_flags_status &= 0xf0ffff;
|
2002-09-08 08:08:14 +04:00
|
|
|
BX_CPU_THIS_PTR eflags.val32 &= ~(1<<7);
|
|
|
|
BX_CPU_THIS_PTR eflags.val32 |= (!!sf)<<7;
|
|
|
|
return(sf);
|
2001-04-10 05:04:59 +04:00
|
|
|
|
|
|
|
case BX_LF_INDEX_OSZAP:
|
|
|
|
switch (BX_CPU_THIS_PTR oszap.instr) {
|
|
|
|
case BX_INSTR_INC8:
|
|
|
|
case BX_INSTR_DEC8:
|
2002-10-04 21:04:33 +04:00
|
|
|
sf = (BX_CPU_THIS_PTR oszap.result_8 >= 0x80);
|
2001-04-10 05:04:59 +04:00
|
|
|
break;
|
|
|
|
case BX_INSTR_INC16:
|
|
|
|
case BX_INSTR_DEC16:
|
2002-10-04 21:04:33 +04:00
|
|
|
sf = (BX_CPU_THIS_PTR oszap.result_16 >= 0x8000);
|
2001-04-10 05:04:59 +04:00
|
|
|
break;
|
|
|
|
case BX_INSTR_INC32:
|
|
|
|
case BX_INSTR_DEC32:
|
2002-10-04 21:04:33 +04:00
|
|
|
sf = (BX_CPU_THIS_PTR oszap.result_32 >= 0x80000000);
|
2001-04-10 05:04:59 +04:00
|
|
|
break;
|
2002-09-15 04:18:41 +04:00
|
|
|
#if BX_SUPPORT_X86_64
|
|
|
|
case BX_INSTR_INC64:
|
|
|
|
case BX_INSTR_DEC64:
|
2002-10-04 21:04:33 +04:00
|
|
|
sf = (BX_CPU_THIS_PTR oszap.result_64 >= BX_CONST64(0x8000000000000000));
|
2002-09-15 04:18:41 +04:00
|
|
|
break;
|
|
|
|
#endif
|
2001-04-10 05:04:59 +04:00
|
|
|
default:
|
2002-09-08 08:08:14 +04:00
|
|
|
sf = 0; // Keep compiler quiet.
|
2001-05-30 22:56:02 +04:00
|
|
|
BX_PANIC(("get_SF: OSZAP: unknown instr"));
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
|
|
|
BX_CPU_THIS_PTR lf_flags_status &= 0xf0ffff;
|
2002-09-08 08:08:14 +04:00
|
|
|
BX_CPU_THIS_PTR eflags.val32 &= ~(1<<7);
|
|
|
|
BX_CPU_THIS_PTR eflags.val32 |= (!!sf)<<7;
|
|
|
|
return(sf);
|
2001-04-10 05:04:59 +04:00
|
|
|
|
|
|
|
default:
|
2001-05-30 22:56:02 +04:00
|
|
|
BX_PANIC(("get_SF: unknown case"));
|
2001-04-10 05:04:59 +04:00
|
|
|
return(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
|
|
|
{
|
|
|
|
Bit8u op1_b7, op2_b7, result_b7;
|
|
|
|
Bit16u op1_b15, op2_b15, result_b15;
|
|
|
|
Bit32u op1_b31, op2_b31, result_b31;
|
2002-09-15 04:18:41 +04:00
|
|
|
#if BX_SUPPORT_X86_64
|
|
|
|
Bit64u op1_b63, op2_b63, result_b63;
|
|
|
|
#endif
|
2002-09-08 08:08:14 +04:00
|
|
|
unsigned of;
|
2001-04-10 05:04:59 +04:00
|
|
|
|
|
|
|
switch ( (BX_CPU_THIS_PTR lf_flags_status>>20) & 0x00000f ) {
|
|
|
|
case BX_LF_INDEX_OSZAPC:
|
|
|
|
switch (BX_CPU_THIS_PTR oszapc.instr) {
|
|
|
|
case BX_INSTR_ADD8:
|
|
|
|
case BX_INSTR_ADC8:
|
|
|
|
op1_b7 = BX_CPU_THIS_PTR oszapc.op1_8 & 0x80;
|
|
|
|
op2_b7 = BX_CPU_THIS_PTR oszapc.op2_8 & 0x80;
|
|
|
|
result_b7 = BX_CPU_THIS_PTR oszapc.result_8 & 0x80;
|
2004-08-15 00:44:48 +04:00
|
|
|
of = (op1_b7 == op2_b7) && (result_b7 ^ op2_b7);
|
2001-04-10 05:04:59 +04:00
|
|
|
break;
|
|
|
|
case BX_INSTR_ADD16:
|
|
|
|
case BX_INSTR_ADC16:
|
|
|
|
op1_b15 = BX_CPU_THIS_PTR oszapc.op1_16 & 0x8000;
|
|
|
|
op2_b15 = BX_CPU_THIS_PTR oszapc.op2_16 & 0x8000;
|
|
|
|
result_b15 = BX_CPU_THIS_PTR oszapc.result_16 & 0x8000;
|
2004-08-15 00:44:48 +04:00
|
|
|
of = (op1_b15 == op2_b15) && (result_b15 ^ op2_b15);
|
2001-04-10 05:04:59 +04:00
|
|
|
break;
|
|
|
|
case BX_INSTR_ADD32:
|
|
|
|
case BX_INSTR_ADC32:
|
|
|
|
op1_b31 = BX_CPU_THIS_PTR oszapc.op1_32 & 0x80000000;
|
|
|
|
op2_b31 = BX_CPU_THIS_PTR oszapc.op2_32 & 0x80000000;
|
|
|
|
result_b31 = BX_CPU_THIS_PTR oszapc.result_32 & 0x80000000;
|
2004-08-15 00:44:48 +04:00
|
|
|
of = (op1_b31 == op2_b31) && (result_b31 ^ op2_b31);
|
2001-04-10 05:04:59 +04:00
|
|
|
break;
|
2002-09-15 04:18:41 +04:00
|
|
|
#if BX_SUPPORT_X86_64
|
|
|
|
case BX_INSTR_ADD64:
|
|
|
|
case BX_INSTR_ADC64:
|
|
|
|
op1_b63 = BX_CPU_THIS_PTR oszapc.op1_64 & BX_CONST64(0x8000000000000000);
|
|
|
|
op2_b63 = BX_CPU_THIS_PTR oszapc.op2_64 & BX_CONST64(0x8000000000000000);
|
|
|
|
result_b63 = BX_CPU_THIS_PTR oszapc.result_64 & BX_CONST64(0x8000000000000000);
|
2004-08-15 00:44:48 +04:00
|
|
|
of = (op1_b63 == op2_b63) && (result_b63 ^ op2_b63);
|
2002-09-15 04:18:41 +04:00
|
|
|
break;
|
|
|
|
#endif
|
2001-04-10 05:04:59 +04:00
|
|
|
case BX_INSTR_SUB8:
|
|
|
|
case BX_INSTR_SBB8:
|
|
|
|
op1_b7 = BX_CPU_THIS_PTR oszapc.op1_8 & 0x80;
|
|
|
|
op2_b7 = BX_CPU_THIS_PTR oszapc.op2_8 & 0x80;
|
|
|
|
result_b7 = BX_CPU_THIS_PTR oszapc.result_8 & 0x80;
|
2004-08-15 00:44:48 +04:00
|
|
|
of = (op1_b7 ^ op2_b7) && (op1_b7 ^ result_b7);
|
2001-04-10 05:04:59 +04:00
|
|
|
break;
|
|
|
|
case BX_INSTR_SUB16:
|
|
|
|
case BX_INSTR_SBB16:
|
|
|
|
op1_b15 = BX_CPU_THIS_PTR oszapc.op1_16 & 0x8000;
|
|
|
|
op2_b15 = BX_CPU_THIS_PTR oszapc.op2_16 & 0x8000;
|
|
|
|
result_b15 = BX_CPU_THIS_PTR oszapc.result_16 & 0x8000;
|
2004-08-15 00:44:48 +04:00
|
|
|
of = (op1_b15 ^ op2_b15) && (op1_b15 ^ result_b15);
|
2001-04-10 05:04:59 +04:00
|
|
|
break;
|
|
|
|
case BX_INSTR_SUB32:
|
|
|
|
case BX_INSTR_SBB32:
|
|
|
|
op1_b31 = BX_CPU_THIS_PTR oszapc.op1_32 & 0x80000000;
|
|
|
|
op2_b31 = BX_CPU_THIS_PTR oszapc.op2_32 & 0x80000000;
|
|
|
|
result_b31 = BX_CPU_THIS_PTR oszapc.result_32 & 0x80000000;
|
2004-08-15 00:44:48 +04:00
|
|
|
of = (op1_b31 ^ op2_b31) && (op1_b31 ^ result_b31);
|
2001-04-10 05:04:59 +04:00
|
|
|
break;
|
2002-09-15 04:18:41 +04:00
|
|
|
#if BX_SUPPORT_X86_64
|
|
|
|
case BX_INSTR_SUB64:
|
|
|
|
case BX_INSTR_SBB64:
|
|
|
|
op1_b63 = BX_CPU_THIS_PTR oszapc.op1_64 & BX_CONST64(0x8000000000000000);
|
|
|
|
op2_b63 = BX_CPU_THIS_PTR oszapc.op2_64 & BX_CONST64(0x8000000000000000);
|
|
|
|
result_b63 = BX_CPU_THIS_PTR oszapc.result_64 & BX_CONST64(0x8000000000000000);
|
2004-08-15 00:44:48 +04:00
|
|
|
of = (op1_b63 ^ op2_b63) && (op1_b63 ^ result_b63);
|
2002-09-15 04:18:41 +04:00
|
|
|
break;
|
|
|
|
#endif
|
2001-04-10 05:04:59 +04:00
|
|
|
case BX_INSTR_NEG8:
|
2004-08-17 21:34:47 +04:00
|
|
|
of = (BX_CPU_THIS_PTR oszapc.result_8 == 0x80);
|
2001-04-10 05:04:59 +04:00
|
|
|
break;
|
|
|
|
case BX_INSTR_NEG16:
|
2004-08-17 21:34:47 +04:00
|
|
|
of = (BX_CPU_THIS_PTR oszapc.result_16 == 0x8000);
|
2001-04-10 05:04:59 +04:00
|
|
|
break;
|
|
|
|
case BX_INSTR_NEG32:
|
2004-08-17 21:34:47 +04:00
|
|
|
of = (BX_CPU_THIS_PTR oszapc.result_32 == 0x80000000);
|
2001-04-10 05:04:59 +04:00
|
|
|
break;
|
2002-09-15 04:18:41 +04:00
|
|
|
#if BX_SUPPORT_X86_64
|
|
|
|
case BX_INSTR_NEG64:
|
2004-08-17 21:34:47 +04:00
|
|
|
of = (BX_CPU_THIS_PTR oszapc.result_64 == BX_CONST64(0x8000000000000000));
|
2002-09-15 04:18:41 +04:00
|
|
|
break;
|
|
|
|
#endif
|
2004-08-10 01:28:47 +04:00
|
|
|
case BX_INSTR_LOGIC8:
|
|
|
|
case BX_INSTR_LOGIC16:
|
|
|
|
case BX_INSTR_LOGIC32:
|
2004-08-14 23:34:02 +04:00
|
|
|
case BX_INSTR_BITSCAN16:
|
|
|
|
case BX_INSTR_BITSCAN32:
|
2004-08-16 00:12:05 +04:00
|
|
|
case BX_INSTR_SAR8:
|
|
|
|
case BX_INSTR_SAR16:
|
|
|
|
case BX_INSTR_SAR32:
|
2002-09-15 04:18:41 +04:00
|
|
|
#if BX_SUPPORT_X86_64
|
2004-08-10 01:28:47 +04:00
|
|
|
case BX_INSTR_LOGIC64:
|
2004-08-14 23:34:02 +04:00
|
|
|
case BX_INSTR_BITSCAN64:
|
2004-08-16 00:12:05 +04:00
|
|
|
case BX_INSTR_SAR64:
|
2002-09-15 04:18:41 +04:00
|
|
|
#endif
|
2002-09-08 08:08:14 +04:00
|
|
|
of = 0;
|
2001-04-10 05:04:59 +04:00
|
|
|
break;
|
|
|
|
case BX_INSTR_SHR8:
|
|
|
|
if (BX_CPU_THIS_PTR oszapc.op2_8 == 1)
|
2002-09-08 08:08:14 +04:00
|
|
|
of = (BX_CPU_THIS_PTR oszapc.op1_8 >= 0x80);
|
|
|
|
else
|
2004-08-14 23:34:02 +04:00
|
|
|
of = 0; /* undocumented, but hardware really does it */
|
2001-04-10 05:04:59 +04:00
|
|
|
break;
|
|
|
|
case BX_INSTR_SHR16:
|
|
|
|
if (BX_CPU_THIS_PTR oszapc.op2_16 == 1)
|
2002-09-08 08:08:14 +04:00
|
|
|
of = (BX_CPU_THIS_PTR oszapc.op1_16 >= 0x8000);
|
|
|
|
else
|
2004-08-14 23:34:02 +04:00
|
|
|
of = 0; /* undocumented, but hardware really does it */
|
2001-04-10 05:04:59 +04:00
|
|
|
break;
|
|
|
|
case BX_INSTR_SHR32:
|
|
|
|
if (BX_CPU_THIS_PTR oszapc.op2_32 == 1)
|
2002-09-08 08:08:14 +04:00
|
|
|
of = (BX_CPU_THIS_PTR oszapc.op1_32 >= 0x80000000);
|
|
|
|
else
|
2004-08-14 23:34:02 +04:00
|
|
|
of = 0; /* undocumented, but hardware really does it */
|
2001-04-10 05:04:59 +04:00
|
|
|
break;
|
2002-09-15 04:18:41 +04:00
|
|
|
#if BX_SUPPORT_X86_64
|
|
|
|
case BX_INSTR_SHR64:
|
|
|
|
if (BX_CPU_THIS_PTR oszapc.op2_64 == 1)
|
|
|
|
of = (BX_CPU_THIS_PTR oszapc.op1_64 >= BX_CONST64(0x8000000000000000));
|
2002-10-04 21:04:33 +04:00
|
|
|
else
|
2004-08-14 23:34:02 +04:00
|
|
|
of = 0; /* undocumented, but hardware really does it */
|
2002-09-15 04:18:41 +04:00
|
|
|
break;
|
|
|
|
#endif
|
2001-04-10 05:04:59 +04:00
|
|
|
case BX_INSTR_SHL8:
|
|
|
|
if (BX_CPU_THIS_PTR oszapc.op2_8 == 1)
|
2002-09-08 08:08:14 +04:00
|
|
|
of = ((BX_CPU_THIS_PTR oszapc.op1_8 ^
|
2001-04-10 05:04:59 +04:00
|
|
|
BX_CPU_THIS_PTR oszapc.result_8) & 0x80) > 0;
|
2002-09-08 08:08:14 +04:00
|
|
|
else
|
2004-08-27 22:43:23 +04:00
|
|
|
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;
|
2001-04-10 05:04:59 +04:00
|
|
|
break;
|
|
|
|
case BX_INSTR_SHL16:
|
|
|
|
if (BX_CPU_THIS_PTR oszapc.op2_16 == 1)
|
2002-09-08 08:08:14 +04:00
|
|
|
of = ((BX_CPU_THIS_PTR oszapc.op1_16 ^
|
2001-04-10 05:04:59 +04:00
|
|
|
BX_CPU_THIS_PTR oszapc.result_16) & 0x8000) > 0;
|
2002-09-08 08:08:14 +04:00
|
|
|
else
|
2004-08-27 22:43:23 +04:00
|
|
|
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;
|
2001-04-10 05:04:59 +04:00
|
|
|
break;
|
|
|
|
case BX_INSTR_SHL32:
|
|
|
|
if (BX_CPU_THIS_PTR oszapc.op2_32 == 1)
|
2002-09-08 08:08:14 +04:00
|
|
|
of = ((BX_CPU_THIS_PTR oszapc.op1_32 ^
|
2001-04-10 05:04:59 +04:00
|
|
|
BX_CPU_THIS_PTR oszapc.result_32) & 0x80000000) > 0;
|
2002-09-08 08:08:14 +04:00
|
|
|
else
|
2004-08-27 22:43:23 +04:00
|
|
|
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;
|
2001-04-10 05:04:59 +04:00
|
|
|
break;
|
2002-09-15 04:18:41 +04:00
|
|
|
#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;
|
2002-10-04 21:04:33 +04:00
|
|
|
else
|
2004-08-27 22:43:23 +04:00
|
|
|
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;
|
2002-09-15 04:18:41 +04:00
|
|
|
break;
|
2004-08-27 00:37:50 +04:00
|
|
|
#endif
|
2004-08-31 23:43:58 +04:00
|
|
|
case BX_INSTR_IMUL8:
|
2004-08-31 01:47:24 +04:00
|
|
|
of = ! ((BX_CPU_THIS_PTR oszapc.op1_8 < 0x80 &&
|
|
|
|
BX_CPU_THIS_PTR oszapc.op2_8 == 0) ||
|
|
|
|
((BX_CPU_THIS_PTR oszapc.op1_8 & 0x80) &&
|
|
|
|
BX_CPU_THIS_PTR oszapc.op2_8 == 0xff));
|
|
|
|
break;
|
|
|
|
case BX_INSTR_IMUL16:
|
|
|
|
of = ! ((BX_CPU_THIS_PTR oszapc.op1_16 < 0x8000 &&
|
|
|
|
BX_CPU_THIS_PTR oszapc.op2_16 == 0) ||
|
|
|
|
((BX_CPU_THIS_PTR oszapc.op1_16 & 0x8000) &&
|
|
|
|
BX_CPU_THIS_PTR oszapc.op2_16 == 0xffff));
|
|
|
|
break;
|
|
|
|
case BX_INSTR_IMUL32:
|
|
|
|
of = ! ((BX_CPU_THIS_PTR oszapc.op1_32 < 0x80000000 &&
|
|
|
|
BX_CPU_THIS_PTR oszapc.op2_32 == 0) ||
|
|
|
|
((BX_CPU_THIS_PTR oszapc.op1_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.op1_64 < BX_CONST64(0x8000000000000000) &&
|
|
|
|
BX_CPU_THIS_PTR oszapc.op2_64 == 0) ||
|
|
|
|
((BX_CPU_THIS_PTR oszapc.op1_64 & BX_CONST64(0x8000000000000000)) &&
|
|
|
|
BX_CPU_THIS_PTR oszapc.op2_64 == BX_CONST64(0xffffffffffffffff)));
|
|
|
|
break;
|
|
|
|
#endif
|
2004-08-31 23:43:58 +04:00
|
|
|
case BX_INSTR_MUL8:
|
2004-08-27 00:37:50 +04:00
|
|
|
of = (BX_CPU_THIS_PTR oszapc.op2_8 != 0);
|
|
|
|
break;
|
2004-08-31 23:43:58 +04:00
|
|
|
case BX_INSTR_MUL16:
|
2004-08-27 00:37:50 +04:00
|
|
|
of = (BX_CPU_THIS_PTR oszapc.op2_16 != 0);
|
|
|
|
break;
|
2004-08-31 23:43:58 +04:00
|
|
|
case BX_INSTR_MUL32:
|
2004-08-27 00:37:50 +04:00
|
|
|
of = (BX_CPU_THIS_PTR oszapc.op2_32 != 0);
|
|
|
|
break;
|
|
|
|
#if BX_SUPPORT_X86_64
|
2004-08-31 23:43:58 +04:00
|
|
|
case BX_INSTR_MUL64:
|
2004-08-27 00:37:50 +04:00
|
|
|
of = (BX_CPU_THIS_PTR oszapc.op2_64 != 0);
|
|
|
|
break;
|
2002-09-15 04:18:41 +04:00
|
|
|
#endif
|
2001-04-10 05:04:59 +04:00
|
|
|
default:
|
2002-09-08 08:08:14 +04:00
|
|
|
of = 0; // Keep compiler happy.
|
2001-05-30 22:56:02 +04:00
|
|
|
BX_PANIC(("get_OF: OSZAPC: unknown instr"));
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
|
|
|
BX_CPU_THIS_PTR lf_flags_status &= 0x0fffff;
|
2002-09-08 08:08:14 +04:00
|
|
|
BX_CPU_THIS_PTR eflags.val32 &= ~(1<<11);
|
|
|
|
BX_CPU_THIS_PTR eflags.val32 |= (!!of)<<11;
|
|
|
|
return(of);
|
2001-04-10 05:04:59 +04:00
|
|
|
|
|
|
|
case BX_LF_INDEX_OSZAP:
|
|
|
|
switch (BX_CPU_THIS_PTR oszap.instr) {
|
|
|
|
case BX_INSTR_INC8:
|
2002-10-04 21:04:33 +04:00
|
|
|
of = BX_CPU_THIS_PTR oszap.result_8 == 0x80;
|
2001-04-10 05:04:59 +04:00
|
|
|
break;
|
|
|
|
case BX_INSTR_INC16:
|
2002-10-04 21:04:33 +04:00
|
|
|
of = BX_CPU_THIS_PTR oszap.result_16 == 0x8000;
|
2001-04-10 05:04:59 +04:00
|
|
|
break;
|
|
|
|
case BX_INSTR_INC32:
|
2002-10-04 21:04:33 +04:00
|
|
|
of = BX_CPU_THIS_PTR oszap.result_32 == 0x80000000;
|
2002-09-15 04:18:41 +04:00
|
|
|
break;
|
|
|
|
#if BX_SUPPORT_X86_64
|
|
|
|
case BX_INSTR_INC64:
|
2002-10-04 21:04:33 +04:00
|
|
|
of = BX_CPU_THIS_PTR oszap.result_64 == BX_CONST64(0x8000000000000000);
|
2001-04-10 05:04:59 +04:00
|
|
|
break;
|
2002-09-15 04:18:41 +04:00
|
|
|
#endif
|
2001-04-10 05:04:59 +04:00
|
|
|
case BX_INSTR_DEC8:
|
2002-10-04 21:04:33 +04:00
|
|
|
of = BX_CPU_THIS_PTR oszap.result_8 == 0x7F;
|
2001-04-10 05:04:59 +04:00
|
|
|
break;
|
|
|
|
case BX_INSTR_DEC16:
|
2002-10-04 21:04:33 +04:00
|
|
|
of = BX_CPU_THIS_PTR oszap.result_16 == 0x7FFF;
|
2001-04-10 05:04:59 +04:00
|
|
|
break;
|
|
|
|
case BX_INSTR_DEC32:
|
2002-10-04 21:04:33 +04:00
|
|
|
of = BX_CPU_THIS_PTR oszap.result_32 == 0x7FFFFFFF;
|
2002-09-15 04:18:41 +04:00
|
|
|
break;
|
|
|
|
#if BX_SUPPORT_X86_64
|
|
|
|
case BX_INSTR_DEC64:
|
2002-10-04 21:04:33 +04:00
|
|
|
of = BX_CPU_THIS_PTR oszap.result_64 == BX_CONST64(0x7FFFFFFFFFFFFFFF);
|
2001-04-10 05:04:59 +04:00
|
|
|
break;
|
2002-09-15 04:18:41 +04:00
|
|
|
#endif
|
2001-04-10 05:04:59 +04:00
|
|
|
default:
|
2002-10-04 21:04:33 +04:00
|
|
|
of = 0; // Keep compiler happy.
|
2001-05-30 22:56:02 +04:00
|
|
|
BX_PANIC(("get_OF: OSZAP: unknown instr"));
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
|
|
|
BX_CPU_THIS_PTR lf_flags_status &= 0x0fffff;
|
2002-09-08 08:08:14 +04:00
|
|
|
BX_CPU_THIS_PTR eflags.val32 &= ~(1<<11);
|
|
|
|
BX_CPU_THIS_PTR eflags.val32 |= (!!of)<<11;
|
|
|
|
return(of);
|
2001-04-10 05:04:59 +04:00
|
|
|
|
|
|
|
default:
|
2001-05-30 22:56:02 +04:00
|
|
|
BX_PANIC(("get_OF: unknown case"));
|
2001-04-10 05:04:59 +04:00
|
|
|
return(0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-08-10 01:28:47 +04:00
|
|
|
bx_bool BX_CPU_C::get_PFLazy(void)
|
2001-04-10 05:04:59 +04:00
|
|
|
{
|
2002-09-08 08:08:14 +04:00
|
|
|
unsigned pf;
|
|
|
|
|
2001-04-10 05:04:59 +04:00
|
|
|
switch ( (BX_CPU_THIS_PTR lf_flags_status>>4) & 0x00000f ) {
|
|
|
|
case BX_LF_INDEX_OSZAPC:
|
|
|
|
switch (BX_CPU_THIS_PTR oszapc.instr) {
|
2004-08-10 01:28:47 +04:00
|
|
|
case BX_INSTR_LOGIC8:
|
2001-04-10 05:04:59 +04:00
|
|
|
case BX_INSTR_ADD8:
|
|
|
|
case BX_INSTR_ADC8:
|
|
|
|
case BX_INSTR_SUB8:
|
|
|
|
case BX_INSTR_SBB8:
|
|
|
|
case BX_INSTR_NEG8:
|
2004-08-16 00:12:05 +04:00
|
|
|
case BX_INSTR_SAR8:
|
2001-04-10 05:04:59 +04:00
|
|
|
case BX_INSTR_SHR8:
|
|
|
|
case BX_INSTR_SHL8:
|
2002-09-08 08:08:14 +04:00
|
|
|
pf = bx_parity_lookup[BX_CPU_THIS_PTR oszapc.result_8];
|
2001-04-10 05:04:59 +04:00
|
|
|
break;
|
2004-08-10 01:28:47 +04:00
|
|
|
case BX_INSTR_LOGIC16:
|
2001-04-10 05:04:59 +04:00
|
|
|
case BX_INSTR_ADD16:
|
|
|
|
case BX_INSTR_ADC16:
|
|
|
|
case BX_INSTR_SUB16:
|
|
|
|
case BX_INSTR_SBB16:
|
|
|
|
case BX_INSTR_NEG16:
|
2004-08-16 00:12:05 +04:00
|
|
|
case BX_INSTR_SAR16:
|
2001-04-10 05:04:59 +04:00
|
|
|
case BX_INSTR_SHR16:
|
|
|
|
case BX_INSTR_SHL16:
|
2004-08-14 23:34:02 +04:00
|
|
|
case BX_INSTR_BITSCAN16:
|
2002-09-08 08:08:14 +04:00
|
|
|
pf = bx_parity_lookup[(Bit8u) BX_CPU_THIS_PTR oszapc.result_16];
|
2001-04-10 05:04:59 +04:00
|
|
|
break;
|
2004-08-10 01:28:47 +04:00
|
|
|
case BX_INSTR_LOGIC32:
|
2001-04-10 05:04:59 +04:00
|
|
|
case BX_INSTR_ADD32:
|
|
|
|
case BX_INSTR_ADC32:
|
|
|
|
case BX_INSTR_SUB32:
|
|
|
|
case BX_INSTR_SBB32:
|
|
|
|
case BX_INSTR_NEG32:
|
2004-08-16 00:12:05 +04:00
|
|
|
case BX_INSTR_SAR32:
|
2001-04-10 05:04:59 +04:00
|
|
|
case BX_INSTR_SHR32:
|
|
|
|
case BX_INSTR_SHL32:
|
2004-08-14 23:34:02 +04:00
|
|
|
case BX_INSTR_BITSCAN32:
|
2002-09-08 08:08:14 +04:00
|
|
|
pf = bx_parity_lookup[(Bit8u) BX_CPU_THIS_PTR oszapc.result_32];
|
2001-04-10 05:04:59 +04:00
|
|
|
break;
|
2002-09-15 04:18:41 +04:00
|
|
|
#if BX_SUPPORT_X86_64
|
2004-08-10 01:28:47 +04:00
|
|
|
case BX_INSTR_LOGIC64:
|
2002-09-15 04:18:41 +04:00
|
|
|
case BX_INSTR_ADD64:
|
|
|
|
case BX_INSTR_ADC64:
|
|
|
|
case BX_INSTR_SUB64:
|
|
|
|
case BX_INSTR_SBB64:
|
|
|
|
case BX_INSTR_NEG64:
|
2004-08-16 00:12:05 +04:00
|
|
|
case BX_INSTR_SAR64:
|
2002-09-15 04:18:41 +04:00
|
|
|
case BX_INSTR_SHR64:
|
|
|
|
case BX_INSTR_SHL64:
|
2004-08-14 23:34:02 +04:00
|
|
|
case BX_INSTR_BITSCAN64:
|
2002-09-15 04:18:41 +04:00
|
|
|
pf = bx_parity_lookup[(Bit8u) BX_CPU_THIS_PTR oszapc.result_64];
|
|
|
|
break;
|
2004-08-27 00:37:50 +04:00
|
|
|
#endif
|
2004-08-31 23:43:58 +04:00
|
|
|
case BX_INSTR_IMUL8:
|
|
|
|
case BX_INSTR_MUL8:
|
2004-08-27 00:37:50 +04:00
|
|
|
pf = bx_parity_lookup[BX_CPU_THIS_PTR oszapc.op1_8];
|
|
|
|
break;
|
2004-08-31 01:47:24 +04:00
|
|
|
case BX_INSTR_IMUL16:
|
2004-08-31 23:43:58 +04:00
|
|
|
case BX_INSTR_MUL16:
|
2004-08-27 00:37:50 +04:00
|
|
|
pf = bx_parity_lookup[(Bit8u) BX_CPU_THIS_PTR oszapc.op1_16];
|
|
|
|
break;
|
2004-08-31 01:47:24 +04:00
|
|
|
case BX_INSTR_IMUL32:
|
2004-08-31 23:43:58 +04:00
|
|
|
case BX_INSTR_MUL32:
|
2004-08-31 01:47:24 +04:00
|
|
|
pf = bx_parity_lookup[(Bit8u) BX_CPU_THIS_PTR oszapc.op1_32];
|
2004-08-27 00:37:50 +04:00
|
|
|
break;
|
|
|
|
#if BX_SUPPORT_X86_64
|
2004-08-31 01:47:24 +04:00
|
|
|
case BX_INSTR_IMUL64:
|
2004-08-31 23:43:58 +04:00
|
|
|
case BX_INSTR_MUL64:
|
2004-08-27 00:37:50 +04:00
|
|
|
pf = bx_parity_lookup[(Bit8u) BX_CPU_THIS_PTR oszapc.op1_64];
|
|
|
|
break;
|
2002-09-15 04:18:41 +04:00
|
|
|
#endif
|
2001-04-10 05:04:59 +04:00
|
|
|
default:
|
2002-10-04 21:04:33 +04:00
|
|
|
pf = 0; // Keep compiler quiet.
|
2001-05-30 22:56:02 +04:00
|
|
|
BX_PANIC(("get_PF: OSZAPC: unknown instr"));
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
|
|
|
BX_CPU_THIS_PTR lf_flags_status &= 0xffff0f;
|
2002-09-08 08:08:14 +04:00
|
|
|
BX_CPU_THIS_PTR eflags.val32 &= ~(1<<2);
|
2004-08-19 00:47:35 +04:00
|
|
|
BX_CPU_THIS_PTR eflags.val32 |= (pf)<<2; // pf is always 0 or 1 here
|
2002-09-08 08:08:14 +04:00
|
|
|
return(pf);
|
2001-04-10 05:04:59 +04:00
|
|
|
|
|
|
|
case BX_LF_INDEX_OSZAP:
|
|
|
|
switch (BX_CPU_THIS_PTR oszap.instr) {
|
|
|
|
case BX_INSTR_INC8:
|
|
|
|
case BX_INSTR_DEC8:
|
2002-09-08 08:08:14 +04:00
|
|
|
pf = bx_parity_lookup[BX_CPU_THIS_PTR oszap.result_8];
|
2001-04-10 05:04:59 +04:00
|
|
|
break;
|
|
|
|
case BX_INSTR_INC16:
|
|
|
|
case BX_INSTR_DEC16:
|
2002-09-08 08:08:14 +04:00
|
|
|
pf = bx_parity_lookup[(Bit8u) BX_CPU_THIS_PTR oszap.result_16];
|
2001-04-10 05:04:59 +04:00
|
|
|
break;
|
|
|
|
case BX_INSTR_INC32:
|
|
|
|
case BX_INSTR_DEC32:
|
2002-09-08 08:08:14 +04:00
|
|
|
pf = bx_parity_lookup[(Bit8u) BX_CPU_THIS_PTR oszap.result_32];
|
2001-04-10 05:04:59 +04:00
|
|
|
break;
|
2002-09-15 04:18:41 +04:00
|
|
|
#if BX_SUPPORT_X86_64
|
|
|
|
case BX_INSTR_INC64:
|
|
|
|
case BX_INSTR_DEC64:
|
|
|
|
pf = bx_parity_lookup[(Bit8u) BX_CPU_THIS_PTR oszap.result_64];
|
|
|
|
break;
|
|
|
|
#endif
|
2001-04-10 05:04:59 +04:00
|
|
|
default:
|
2002-09-08 08:08:14 +04:00
|
|
|
pf = 0; // Keep compiler quiet.
|
2001-05-30 22:56:02 +04:00
|
|
|
BX_PANIC(("get_PF: OSZAP: unknown instr"));
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
|
|
|
BX_CPU_THIS_PTR lf_flags_status &= 0xffff0f;
|
2002-09-08 08:08:14 +04:00
|
|
|
BX_CPU_THIS_PTR eflags.val32 &= ~(1<<2);
|
2004-08-19 00:47:35 +04:00
|
|
|
BX_CPU_THIS_PTR eflags.val32 |= (pf)<<2; // pf is always 0 or 1 here
|
2002-09-08 08:08:14 +04:00
|
|
|
return(pf);
|
2001-04-10 05:04:59 +04:00
|
|
|
|
|
|
|
default:
|
2001-05-30 22:56:02 +04:00
|
|
|
BX_PANIC(("get_PF: unknown case"));
|
2001-04-10 05:04:59 +04:00
|
|
|
return(0);
|
|
|
|
}
|
|
|
|
}
|