2 * Fast486 386/486 CPU Emulation Library
5 * Copyright (C) 2014 Aleksandar Andrejevic <theflash AT sdf DOT lonestar DOT org>
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
29 /* DEFINES ********************************************************************/
31 #define FPU_CHECK() if (State->ControlRegisters[FAST486_REG_CR0] & FAST486_CR0_EM) \
33 Fast486Exception(State, FAST486_EXCEPTION_NM); \
36 #define FPU_ST(i) State->FpuRegisters[(State->FpuStatus.Top + (i)) % FAST486_NUM_FPU_REGS]
37 #define FPU_GET_TAG(i) ((State->FpuTag >> ((i) * 2)) & 3)
38 #define FPU_SET_TAG(i, t) { \
39 State->FpuTag &= ~((1 << ((i) * 2)) | (1 << (((i) * 2) + 1))); \
40 State->FpuTag |= ((t) & 3) << ((i) * 2); \
43 #define FPU_REAL4_BIAS 0x7F
44 #define FPU_REAL8_BIAS 0x3FF
45 #define FPU_REAL10_BIAS 0x3FFF
46 #define FPU_MAX_EXPONENT 0x7FFE
47 #define FPU_MANTISSA_HIGH_BIT 0x8000000000000000ULL
49 #define FPU_IS_NORMALIZED(x) (!FPU_IS_ZERO(x) && (((x)->Mantissa & FPU_MANTISSA_HIGH_BIT) != 0ULL))
50 #define FPU_IS_ZERO(x) ((x)->Mantissa == 0ULL)
51 #define FPU_IS_NAN(x) ((x)->Exponent == (FPU_MAX_EXPONENT + 1))
52 #define FPU_IS_INFINITY(x) (FPU_IS_NAN(x) && (x)->Mantissa & FPU_MANTISSA_HIGH_BIT)
53 #define FPU_IS_POS_INF(x) (FPU_IS_INFINITY(x) && !(x)->Sign)
54 #define FPU_IS_NEG_INF(x) (FPU_IS_INFINITY(x) && (x)->Sign)
58 FPU_SINGLE_PRECISION
= 0,
59 FPU_DOUBLE_PRECISION
= 2,
60 FPU_DOUBLE_EXT_PRECISION
= 3
71 FAST486_OPCODE_HANDLER(Fast486FpuOpcodeD8DC
);
72 FAST486_OPCODE_HANDLER(Fast486FpuOpcodeD9
);
73 FAST486_OPCODE_HANDLER(Fast486FpuOpcodeDA
);
74 FAST486_OPCODE_HANDLER(Fast486FpuOpcodeDB
);
75 FAST486_OPCODE_HANDLER(Fast486FpuOpcodeDD
);
76 FAST486_OPCODE_HANDLER(Fast486FpuOpcodeDE
);
77 FAST486_OPCODE_HANDLER(Fast486FpuOpcodeDF
);