2001-10-03 17:10:38 +04:00
|
|
|
/////////////////////////////////////////////////////////////////////////
|
2002-09-08 08:08:14 +04:00
|
|
|
// $Id: lazy_flags.cc,v 1.7 2002-09-08 04:08:14 kevinlawton 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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Boolean
|
|
|
|
BX_CPU_C::get_CF(void)
|
|
|
|
{
|
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_KNOWN:
|
2002-09-08 08:08:14 +04:00
|
|
|
return(BX_CPU_THIS_PTR eflags.val32 & 1);
|
2001-04-10 05:04:59 +04:00
|
|
|
|
|
|
|
case BX_LF_INDEX_OSZAPC:
|
|
|
|
switch (BX_CPU_THIS_PTR oszapc.instr) {
|
|
|
|
case BX_INSTR_ADD8:
|
|
|
|
case BX_INSTR_XADD8:
|
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:
|
|
|
|
case BX_INSTR_XADD16:
|
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:
|
|
|
|
case BX_INSTR_XADD32:
|
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;
|
|
|
|
case BX_INSTR_ADC8:
|
2002-09-08 08:08:14 +04:00
|
|
|
cf =
|
2001-04-10 05:04:59 +04:00
|
|
|
(BX_CPU_THIS_PTR oszapc.result_8 <
|
|
|
|
BX_CPU_THIS_PTR oszapc.op1_8) ||
|
|
|
|
(BX_CPU_THIS_PTR oszapc.prev_CF &&
|
|
|
|
BX_CPU_THIS_PTR oszapc.result_8 ==
|
|
|
|
BX_CPU_THIS_PTR oszapc.op1_8);
|
|
|
|
break;
|
|
|
|
case BX_INSTR_ADC16:
|
2002-09-08 08:08:14 +04:00
|
|
|
cf =
|
2001-04-10 05:04:59 +04:00
|
|
|
(BX_CPU_THIS_PTR oszapc.result_16 <
|
|
|
|
BX_CPU_THIS_PTR oszapc.op1_16) ||
|
|
|
|
(BX_CPU_THIS_PTR oszapc.prev_CF &&
|
|
|
|
BX_CPU_THIS_PTR oszapc.result_16 ==
|
|
|
|
BX_CPU_THIS_PTR oszapc.op1_16);
|
|
|
|
break;
|
|
|
|
case BX_INSTR_ADC32:
|
2002-09-08 08:08:14 +04:00
|
|
|
cf =
|
2001-04-10 05:04:59 +04:00
|
|
|
(BX_CPU_THIS_PTR oszapc.result_32 <
|
|
|
|
BX_CPU_THIS_PTR oszapc.op1_32) ||
|
|
|
|
(BX_CPU_THIS_PTR oszapc.prev_CF &&
|
|
|
|
BX_CPU_THIS_PTR oszapc.result_32 ==
|
|
|
|
BX_CPU_THIS_PTR oszapc.op1_32);
|
|
|
|
break;
|
|
|
|
case BX_INSTR_SUB8:
|
|
|
|
case BX_INSTR_CMP8:
|
|
|
|
case BX_INSTR_CMPS8:
|
|
|
|
case BX_INSTR_SCAS8:
|
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:
|
|
|
|
case BX_INSTR_CMP16:
|
|
|
|
case BX_INSTR_CMPS16:
|
|
|
|
case BX_INSTR_SCAS16:
|
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:
|
|
|
|
case BX_INSTR_CMP32:
|
|
|
|
case BX_INSTR_CMPS32:
|
|
|
|
case BX_INSTR_SCAS32:
|
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;
|
|
|
|
case BX_INSTR_SBB8:
|
2002-09-08 08:08:14 +04:00
|
|
|
cf =
|
2001-04-10 05:04:59 +04:00
|
|
|
(BX_CPU_THIS_PTR oszapc.op1_8 <
|
|
|
|
BX_CPU_THIS_PTR oszapc.result_8) ||
|
|
|
|
((BX_CPU_THIS_PTR oszapc.op2_8==0xff) &&
|
|
|
|
BX_CPU_THIS_PTR oszapc.prev_CF);
|
|
|
|
break;
|
|
|
|
case BX_INSTR_SBB16:
|
2002-09-08 08:08:14 +04:00
|
|
|
cf =
|
2001-04-10 05:04:59 +04:00
|
|
|
(BX_CPU_THIS_PTR oszapc.op1_16 <
|
|
|
|
BX_CPU_THIS_PTR oszapc.result_16) ||
|
|
|
|
((BX_CPU_THIS_PTR oszapc.op2_16==0xffff) &&
|
|
|
|
BX_CPU_THIS_PTR oszapc.prev_CF);
|
|
|
|
break;
|
|
|
|
case BX_INSTR_SBB32:
|
2002-09-08 08:08:14 +04:00
|
|
|
cf =
|
2001-04-10 05:04:59 +04:00
|
|
|
(BX_CPU_THIS_PTR oszapc.op1_32 <
|
|
|
|
BX_CPU_THIS_PTR oszapc.result_32) ||
|
|
|
|
((BX_CPU_THIS_PTR oszapc.op2_32==0xffffffff) &&
|
|
|
|
BX_CPU_THIS_PTR oszapc.prev_CF);
|
|
|
|
break;
|
|
|
|
case BX_INSTR_NEG8:
|
2002-09-08 08:08:14 +04:00
|
|
|
cf =
|
2001-04-10 05:04:59 +04:00
|
|
|
BX_CPU_THIS_PTR oszapc.op1_8 != 0;
|
|
|
|
break;
|
|
|
|
case BX_INSTR_NEG16:
|
2002-09-08 08:08:14 +04:00
|
|
|
cf =
|
2001-04-10 05:04:59 +04:00
|
|
|
BX_CPU_THIS_PTR oszapc.op1_16 != 0;
|
|
|
|
break;
|
|
|
|
case BX_INSTR_NEG32:
|
2002-09-08 08:08:14 +04:00
|
|
|
cf =
|
2001-04-10 05:04:59 +04:00
|
|
|
BX_CPU_THIS_PTR oszapc.op1_32 != 0;
|
|
|
|
break;
|
|
|
|
case BX_INSTR_OR8:
|
|
|
|
case BX_INSTR_OR16:
|
|
|
|
case BX_INSTR_OR32:
|
|
|
|
case BX_INSTR_AND8:
|
|
|
|
case BX_INSTR_AND16:
|
|
|
|
case BX_INSTR_AND32:
|
|
|
|
case BX_INSTR_TEST8:
|
|
|
|
case BX_INSTR_TEST16:
|
|
|
|
case BX_INSTR_TEST32:
|
|
|
|
case BX_INSTR_XOR8:
|
|
|
|
case BX_INSTR_XOR16:
|
|
|
|
case BX_INSTR_XOR32:
|
2002-09-08 08:08:14 +04:00
|
|
|
cf = 0;
|
2001-04-10 05:04:59 +04:00
|
|
|
break;
|
|
|
|
case BX_INSTR_SHR8:
|
2002-09-08 08:08:14 +04:00
|
|
|
cf =
|
2001-04-10 05:04:59 +04:00
|
|
|
(BX_CPU_THIS_PTR oszapc.op1_8 >>
|
|
|
|
(BX_CPU_THIS_PTR oszapc.op2_8 - 1)) & 0x01;
|
|
|
|
break;
|
|
|
|
case BX_INSTR_SHR16:
|
2002-09-08 08:08:14 +04:00
|
|
|
cf =
|
2001-04-10 05:04:59 +04:00
|
|
|
(BX_CPU_THIS_PTR oszapc.op1_16 >>
|
|
|
|
(BX_CPU_THIS_PTR oszapc.op2_16 - 1)) & 0x01;
|
|
|
|
break;
|
|
|
|
case BX_INSTR_SHR32:
|
2002-09-08 08:08:14 +04:00
|
|
|
cf =
|
2001-04-10 05:04:59 +04:00
|
|
|
(BX_CPU_THIS_PTR oszapc.op1_32 >>
|
|
|
|
(BX_CPU_THIS_PTR oszapc.op2_32 - 1)) & 0x01;
|
|
|
|
break;
|
|
|
|
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;
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Boolean
|
|
|
|
BX_CPU_C::get_AF(void)
|
|
|
|
{
|
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_KNOWN:
|
2002-09-08 08:08:14 +04:00
|
|
|
return( (BX_CPU_THIS_PTR eflags.val32 >> 4) & 1);
|
2001-04-10 05:04:59 +04:00
|
|
|
|
|
|
|
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:
|
|
|
|
case BX_INSTR_CMP8:
|
|
|
|
case BX_INSTR_XADD8:
|
|
|
|
case BX_INSTR_CMPS8:
|
|
|
|
case BX_INSTR_SCAS8:
|
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:
|
|
|
|
case BX_INSTR_CMP16:
|
|
|
|
case BX_INSTR_XADD16:
|
|
|
|
case BX_INSTR_CMPS16:
|
|
|
|
case BX_INSTR_SCAS16:
|
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:
|
|
|
|
case BX_INSTR_CMP32:
|
|
|
|
case BX_INSTR_XADD32:
|
|
|
|
case BX_INSTR_CMPS32:
|
|
|
|
case BX_INSTR_SCAS32:
|
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;
|
|
|
|
case BX_INSTR_NEG8:
|
2002-09-08 08:08:14 +04:00
|
|
|
af =
|
2001-04-10 05:04:59 +04:00
|
|
|
(BX_CPU_THIS_PTR oszapc.op1_8 & 0x0f) > 0;
|
|
|
|
break;
|
|
|
|
case BX_INSTR_NEG16:
|
2002-09-08 08:08:14 +04:00
|
|
|
af =
|
2001-04-10 05:04:59 +04:00
|
|
|
(BX_CPU_THIS_PTR oszapc.op1_16 & 0x0f) > 0;
|
|
|
|
break;
|
|
|
|
case BX_INSTR_NEG32:
|
2002-09-08 08:08:14 +04:00
|
|
|
af =
|
2001-04-10 05:04:59 +04:00
|
|
|
(BX_CPU_THIS_PTR oszapc.op1_32 & 0x0f) > 0;
|
|
|
|
break;
|
|
|
|
case BX_INSTR_OR8:
|
|
|
|
case BX_INSTR_OR16:
|
|
|
|
case BX_INSTR_OR32:
|
|
|
|
case BX_INSTR_AND8:
|
|
|
|
case BX_INSTR_AND16:
|
|
|
|
case BX_INSTR_AND32:
|
|
|
|
case BX_INSTR_TEST8:
|
|
|
|
case BX_INSTR_TEST16:
|
|
|
|
case BX_INSTR_TEST32:
|
|
|
|
case BX_INSTR_XOR8:
|
|
|
|
case BX_INSTR_XOR16:
|
|
|
|
case BX_INSTR_XOR32:
|
|
|
|
case BX_INSTR_SHR8:
|
|
|
|
case BX_INSTR_SHR16:
|
|
|
|
case BX_INSTR_SHR32:
|
|
|
|
case BX_INSTR_SHL8:
|
|
|
|
case BX_INSTR_SHL16:
|
|
|
|
case BX_INSTR_SHL32:
|
2002-09-08 08:08:14 +04:00
|
|
|
af = 0;
|
2001-04-10 05:04:59 +04:00
|
|
|
/* undefined */
|
|
|
|
break;
|
|
|
|
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: 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-08 08:08:14 +04:00
|
|
|
af =
|
2001-04-10 05:04:59 +04:00
|
|
|
(BX_CPU_THIS_PTR oszap.result_8 & 0x0f) == 0;
|
|
|
|
break;
|
|
|
|
case BX_INSTR_INC16:
|
2002-09-08 08:08:14 +04:00
|
|
|
af =
|
2001-04-10 05:04:59 +04:00
|
|
|
(BX_CPU_THIS_PTR oszap.result_16 & 0x0f) == 0;
|
|
|
|
break;
|
|
|
|
case BX_INSTR_INC32:
|
2002-09-08 08:08:14 +04:00
|
|
|
af =
|
2001-04-10 05:04:59 +04:00
|
|
|
(BX_CPU_THIS_PTR oszap.result_32 & 0x0f) == 0;
|
|
|
|
break;
|
|
|
|
case BX_INSTR_DEC8:
|
2002-09-08 08:08:14 +04:00
|
|
|
af =
|
2001-04-10 05:04:59 +04:00
|
|
|
(BX_CPU_THIS_PTR oszap.result_8 & 0x0f) == 0x0f;
|
|
|
|
break;
|
|
|
|
case BX_INSTR_DEC16:
|
2002-09-08 08:08:14 +04:00
|
|
|
af =
|
2001-04-10 05:04:59 +04:00
|
|
|
(BX_CPU_THIS_PTR oszap.result_16 & 0x0f) == 0x0f;
|
|
|
|
break;
|
|
|
|
case BX_INSTR_DEC32:
|
2002-09-08 08:08:14 +04:00
|
|
|
af =
|
2001-04-10 05:04:59 +04:00
|
|
|
(BX_CPU_THIS_PTR oszap.result_32 & 0x0f) == 0x0f;
|
|
|
|
break;
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Boolean
|
|
|
|
BX_CPU_C::get_ZF(void)
|
|
|
|
{
|
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_KNOWN:
|
2002-09-08 08:08:14 +04:00
|
|
|
return( (BX_CPU_THIS_PTR eflags.val32 >> 6) & 1);
|
2001-04-10 05:04:59 +04:00
|
|
|
|
|
|
|
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:
|
|
|
|
case BX_INSTR_CMP8:
|
|
|
|
case BX_INSTR_NEG8:
|
|
|
|
case BX_INSTR_XADD8:
|
|
|
|
case BX_INSTR_OR8:
|
|
|
|
case BX_INSTR_AND8:
|
|
|
|
case BX_INSTR_TEST8:
|
|
|
|
case BX_INSTR_XOR8:
|
|
|
|
case BX_INSTR_CMPS8:
|
|
|
|
case BX_INSTR_SCAS8:
|
|
|
|
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;
|
|
|
|
case BX_INSTR_ADD16:
|
|
|
|
case BX_INSTR_ADC16:
|
|
|
|
case BX_INSTR_SUB16:
|
|
|
|
case BX_INSTR_SBB16:
|
|
|
|
case BX_INSTR_CMP16:
|
|
|
|
case BX_INSTR_NEG16:
|
|
|
|
case BX_INSTR_XADD16:
|
|
|
|
case BX_INSTR_OR16:
|
|
|
|
case BX_INSTR_AND16:
|
|
|
|
case BX_INSTR_TEST16:
|
|
|
|
case BX_INSTR_XOR16:
|
|
|
|
case BX_INSTR_CMPS16:
|
|
|
|
case BX_INSTR_SCAS16:
|
|
|
|
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;
|
|
|
|
case BX_INSTR_ADD32:
|
|
|
|
case BX_INSTR_ADC32:
|
|
|
|
case BX_INSTR_SUB32:
|
|
|
|
case BX_INSTR_SBB32:
|
|
|
|
case BX_INSTR_CMP32:
|
|
|
|
case BX_INSTR_NEG32:
|
|
|
|
case BX_INSTR_XADD32:
|
|
|
|
case BX_INSTR_OR32:
|
|
|
|
case BX_INSTR_AND32:
|
|
|
|
case BX_INSTR_TEST32:
|
|
|
|
case BX_INSTR_XOR32:
|
|
|
|
case BX_INSTR_CMPS32:
|
|
|
|
case BX_INSTR_SCAS32:
|
|
|
|
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;
|
|
|
|
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);
|
|
|
|
BX_CPU_THIS_PTR eflags.val32 |= (!!zf)<<6;
|
|
|
|
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;
|
|
|
|
default:
|
2002-09-08 08:08:14 +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);
|
|
|
|
BX_CPU_THIS_PTR eflags.val32 |= (!!zf)<<6;
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Boolean
|
|
|
|
BX_CPU_C::get_SF(void)
|
|
|
|
{
|
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_KNOWN:
|
2002-09-08 08:08:14 +04:00
|
|
|
return( (BX_CPU_THIS_PTR eflags.val32 >> 7) & 1);
|
2001-04-10 05:04:59 +04:00
|
|
|
|
|
|
|
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:
|
|
|
|
case BX_INSTR_CMP8:
|
|
|
|
case BX_INSTR_NEG8:
|
|
|
|
case BX_INSTR_XADD8:
|
|
|
|
case BX_INSTR_OR8:
|
|
|
|
case BX_INSTR_AND8:
|
|
|
|
case BX_INSTR_TEST8:
|
|
|
|
case BX_INSTR_XOR8:
|
|
|
|
case BX_INSTR_CMPS8:
|
|
|
|
case BX_INSTR_SCAS8:
|
|
|
|
case BX_INSTR_SHR8:
|
|
|
|
case BX_INSTR_SHL8:
|
2002-09-08 08:08:14 +04:00
|
|
|
sf =
|
2001-04-10 05:04:59 +04:00
|
|
|
(BX_CPU_THIS_PTR oszapc.result_8 >= 0x80);
|
|
|
|
break;
|
|
|
|
case BX_INSTR_ADD16:
|
|
|
|
case BX_INSTR_ADC16:
|
|
|
|
case BX_INSTR_SUB16:
|
|
|
|
case BX_INSTR_SBB16:
|
|
|
|
case BX_INSTR_CMP16:
|
|
|
|
case BX_INSTR_NEG16:
|
|
|
|
case BX_INSTR_XADD16:
|
|
|
|
case BX_INSTR_OR16:
|
|
|
|
case BX_INSTR_AND16:
|
|
|
|
case BX_INSTR_TEST16:
|
|
|
|
case BX_INSTR_XOR16:
|
|
|
|
case BX_INSTR_CMPS16:
|
|
|
|
case BX_INSTR_SCAS16:
|
|
|
|
case BX_INSTR_SHR16:
|
|
|
|
case BX_INSTR_SHL16:
|
2002-09-08 08:08:14 +04:00
|
|
|
sf =
|
2001-04-10 05:04:59 +04:00
|
|
|
(BX_CPU_THIS_PTR oszapc.result_16 >= 0x8000);
|
|
|
|
break;
|
|
|
|
case BX_INSTR_ADD32:
|
|
|
|
case BX_INSTR_ADC32:
|
|
|
|
case BX_INSTR_SUB32:
|
|
|
|
case BX_INSTR_SBB32:
|
|
|
|
case BX_INSTR_CMP32:
|
|
|
|
case BX_INSTR_NEG32:
|
|
|
|
case BX_INSTR_XADD32:
|
|
|
|
case BX_INSTR_OR32:
|
|
|
|
case BX_INSTR_AND32:
|
|
|
|
case BX_INSTR_TEST32:
|
|
|
|
case BX_INSTR_XOR32:
|
|
|
|
case BX_INSTR_CMPS32:
|
|
|
|
case BX_INSTR_SCAS32:
|
|
|
|
case BX_INSTR_SHR32:
|
|
|
|
case BX_INSTR_SHL32:
|
2002-09-08 08:08:14 +04:00
|
|
|
sf =
|
2001-04-10 05:04:59 +04:00
|
|
|
(BX_CPU_THIS_PTR oszapc.result_32 >= 0x80000000);
|
|
|
|
break;
|
|
|
|
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-09-08 08:08:14 +04:00
|
|
|
sf =
|
2001-04-10 05:04:59 +04:00
|
|
|
(BX_CPU_THIS_PTR oszap.result_8 >= 0x80);
|
|
|
|
break;
|
|
|
|
case BX_INSTR_INC16:
|
|
|
|
case BX_INSTR_DEC16:
|
2002-09-08 08:08:14 +04:00
|
|
|
sf =
|
2001-04-10 05:04:59 +04:00
|
|
|
(BX_CPU_THIS_PTR oszap.result_16 >= 0x8000);
|
|
|
|
break;
|
|
|
|
case BX_INSTR_INC32:
|
|
|
|
case BX_INSTR_DEC32:
|
2002-09-08 08:08:14 +04:00
|
|
|
sf =
|
2001-04-10 05:04:59 +04:00
|
|
|
(BX_CPU_THIS_PTR oszap.result_32 >= 0x80000000);
|
|
|
|
break;
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Boolean
|
|
|
|
BX_CPU_C::get_OF(void)
|
|
|
|
{
|
|
|
|
Bit8u op1_b7, op2_b7, result_b7;
|
|
|
|
Bit16u op1_b15, op2_b15, result_b15;
|
|
|
|
Bit32u op1_b31, op2_b31, result_b31;
|
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_KNOWN:
|
2002-09-08 08:08:14 +04:00
|
|
|
return( (BX_CPU_THIS_PTR eflags.val32 >> 11) & 1);
|
2001-04-10 05:04:59 +04:00
|
|
|
|
|
|
|
case BX_LF_INDEX_OSZAPC:
|
|
|
|
switch (BX_CPU_THIS_PTR oszapc.instr) {
|
|
|
|
case BX_INSTR_ADD8:
|
|
|
|
case BX_INSTR_ADC8:
|
|
|
|
case BX_INSTR_XADD8:
|
|
|
|
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;
|
|
|
|
|
2002-09-08 08:08:14 +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:
|
|
|
|
case BX_INSTR_XADD16:
|
|
|
|
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;
|
|
|
|
|
2002-09-08 08:08:14 +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:
|
|
|
|
case BX_INSTR_XADD32:
|
|
|
|
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;
|
|
|
|
|
2002-09-08 08:08:14 +04:00
|
|
|
of = (op1_b31 == op2_b31) && (result_b31 ^ op2_b31);
|
2001-04-10 05:04:59 +04:00
|
|
|
break;
|
|
|
|
case BX_INSTR_SUB8:
|
|
|
|
case BX_INSTR_SBB8:
|
|
|
|
case BX_INSTR_CMP8:
|
|
|
|
case BX_INSTR_CMPS8:
|
|
|
|
case BX_INSTR_SCAS8:
|
|
|
|
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;
|
|
|
|
|
2002-09-08 08:08:14 +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:
|
|
|
|
case BX_INSTR_CMP16:
|
|
|
|
case BX_INSTR_CMPS16:
|
|
|
|
case BX_INSTR_SCAS16:
|
|
|
|
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;
|
|
|
|
|
2002-09-08 08:08:14 +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:
|
|
|
|
case BX_INSTR_CMP32:
|
|
|
|
case BX_INSTR_CMPS32:
|
|
|
|
case BX_INSTR_SCAS32:
|
|
|
|
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;
|
|
|
|
|
2002-09-08 08:08:14 +04:00
|
|
|
of = (op1_b31 ^ op2_b31) && (op1_b31 ^ result_b31);
|
2001-04-10 05:04:59 +04:00
|
|
|
break;
|
|
|
|
case BX_INSTR_NEG8:
|
2002-09-08 08:08:14 +04:00
|
|
|
of = (BX_CPU_THIS_PTR oszapc.op1_8 == 0x80);
|
2001-04-10 05:04:59 +04:00
|
|
|
break;
|
|
|
|
case BX_INSTR_NEG16:
|
2002-09-08 08:08:14 +04:00
|
|
|
of = (BX_CPU_THIS_PTR oszapc.op1_16 == 0x8000);
|
2001-04-10 05:04:59 +04:00
|
|
|
break;
|
|
|
|
case BX_INSTR_NEG32:
|
2002-09-08 08:08:14 +04:00
|
|
|
of = (BX_CPU_THIS_PTR oszapc.op1_32 == 0x80000000);
|
2001-04-10 05:04:59 +04:00
|
|
|
break;
|
|
|
|
case BX_INSTR_OR8:
|
|
|
|
case BX_INSTR_OR16:
|
|
|
|
case BX_INSTR_OR32:
|
|
|
|
case BX_INSTR_AND8:
|
|
|
|
case BX_INSTR_AND16:
|
|
|
|
case BX_INSTR_AND32:
|
|
|
|
case BX_INSTR_TEST8:
|
|
|
|
case BX_INSTR_TEST16:
|
|
|
|
case BX_INSTR_TEST32:
|
|
|
|
case BX_INSTR_XOR8:
|
|
|
|
case BX_INSTR_XOR16:
|
|
|
|
case BX_INSTR_XOR32:
|
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
|
|
|
|
of = (BX_CPU_THIS_PTR eflags.val32 >> 11) & 1; // Old val
|
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
|
|
|
|
of = (BX_CPU_THIS_PTR eflags.val32 >> 11) & 1; // Old val
|
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
|
|
|
|
of = (BX_CPU_THIS_PTR eflags.val32 >> 11) & 1; // Old val
|
2001-04-10 05:04:59 +04:00
|
|
|
break;
|
|
|
|
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
|
|
|
|
of = (BX_CPU_THIS_PTR eflags.val32 >> 11) & 1; // Old val
|
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
|
|
|
|
of = (BX_CPU_THIS_PTR eflags.val32 >> 11) & 1; // Old val
|
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
|
|
|
|
of = (BX_CPU_THIS_PTR eflags.val32 >> 11) & 1; // Old val
|
2001-04-10 05:04:59 +04:00
|
|
|
break;
|
|
|
|
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-09-08 08:08:14 +04:00
|
|
|
of =
|
2001-04-10 05:04:59 +04:00
|
|
|
BX_CPU_THIS_PTR oszap.result_8 == 0x80;
|
|
|
|
break;
|
|
|
|
case BX_INSTR_INC16:
|
2002-09-08 08:08:14 +04:00
|
|
|
of =
|
2001-04-10 05:04:59 +04:00
|
|
|
BX_CPU_THIS_PTR oszap.result_16 == 0x8000;
|
|
|
|
break;
|
|
|
|
case BX_INSTR_INC32:
|
2002-09-08 08:08:14 +04:00
|
|
|
of =
|
2001-04-10 05:04:59 +04:00
|
|
|
BX_CPU_THIS_PTR oszap.result_32 == 0x80000000;
|
|
|
|
break;
|
|
|
|
case BX_INSTR_DEC8:
|
2002-09-08 08:08:14 +04:00
|
|
|
of =
|
2001-04-10 05:04:59 +04:00
|
|
|
BX_CPU_THIS_PTR oszap.result_8 == 0x7F;
|
|
|
|
break;
|
|
|
|
case BX_INSTR_DEC16:
|
2002-09-08 08:08:14 +04:00
|
|
|
of =
|
2001-04-10 05:04:59 +04:00
|
|
|
BX_CPU_THIS_PTR oszap.result_16 == 0x7FFF;
|
|
|
|
break;
|
|
|
|
case BX_INSTR_DEC32:
|
2002-09-08 08:08:14 +04:00
|
|
|
of =
|
2001-04-10 05:04:59 +04:00
|
|
|
BX_CPU_THIS_PTR oszap.result_32 == 0x7FFFFFFF;
|
|
|
|
break;
|
|
|
|
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: 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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Boolean
|
|
|
|
BX_CPU_C::get_PF(void)
|
|
|
|
{
|
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_KNOWN:
|
2002-09-08 08:08:14 +04:00
|
|
|
return( (BX_CPU_THIS_PTR eflags.val32 >> 2) & 1);
|
2001-04-10 05:04:59 +04:00
|
|
|
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:
|
|
|
|
case BX_INSTR_CMP8:
|
|
|
|
case BX_INSTR_NEG8:
|
|
|
|
case BX_INSTR_XADD8:
|
|
|
|
case BX_INSTR_OR8:
|
|
|
|
case BX_INSTR_AND8:
|
|
|
|
case BX_INSTR_TEST8:
|
|
|
|
case BX_INSTR_XOR8:
|
|
|
|
case BX_INSTR_CMPS8:
|
|
|
|
case BX_INSTR_SCAS8:
|
|
|
|
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;
|
|
|
|
case BX_INSTR_ADD16:
|
|
|
|
case BX_INSTR_ADC16:
|
|
|
|
case BX_INSTR_SUB16:
|
|
|
|
case BX_INSTR_SBB16:
|
|
|
|
case BX_INSTR_CMP16:
|
|
|
|
case BX_INSTR_NEG16:
|
|
|
|
case BX_INSTR_XADD16:
|
|
|
|
case BX_INSTR_OR16:
|
|
|
|
case BX_INSTR_AND16:
|
|
|
|
case BX_INSTR_TEST16:
|
|
|
|
case BX_INSTR_XOR16:
|
|
|
|
case BX_INSTR_CMPS16:
|
|
|
|
case BX_INSTR_SCAS16:
|
|
|
|
case BX_INSTR_SHR16:
|
|
|
|
case BX_INSTR_SHL16:
|
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;
|
|
|
|
case BX_INSTR_ADD32:
|
|
|
|
case BX_INSTR_ADC32:
|
|
|
|
case BX_INSTR_SUB32:
|
|
|
|
case BX_INSTR_SBB32:
|
|
|
|
case BX_INSTR_CMP32:
|
|
|
|
case BX_INSTR_NEG32:
|
|
|
|
case BX_INSTR_XADD32:
|
|
|
|
case BX_INSTR_OR32:
|
|
|
|
case BX_INSTR_AND32:
|
|
|
|
case BX_INSTR_TEST32:
|
|
|
|
case BX_INSTR_XOR32:
|
|
|
|
case BX_INSTR_CMPS32:
|
|
|
|
case BX_INSTR_SCAS32:
|
|
|
|
case BX_INSTR_SHR32:
|
|
|
|
case BX_INSTR_SHL32:
|
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;
|
|
|
|
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: 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);
|
|
|
|
BX_CPU_THIS_PTR eflags.val32 |= (!!pf)<<2;
|
|
|
|
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;
|
|
|
|
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);
|
|
|
|
BX_CPU_THIS_PTR eflags.val32 |= (!!pf)<<2;
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|