[FAST486]

Start implementing the FPU. Stubplement the FPU opcode handlers.


svn path=/branches/ntvdm/; revision=61141
This commit is contained in:
Aleksandar Andrejevic 2013-11-29 03:00:59 +00:00
parent 4fb7f6e1d7
commit 81c27b5b19
5 changed files with 220 additions and 9 deletions

View file

@ -34,6 +34,7 @@
#define FAST486_NUM_SEG_REGS 6
#define FAST486_NUM_CTRL_REGS 3
#define FAST486_NUM_DBG_REGS 6
#define FAST486_NUM_FPU_REGS 8
#define FAST486_CR0_PE (1 << 0)
#define FAST486_CR0_MP (1 << 1)
@ -376,6 +377,55 @@ typedef struct _FAST486_TSS
ULONG IopbOffset;
} FAST486_TSS, *PFAST486_TSS;
typedef struct _FAST486_FPU_DATA_REG
{
ULONGLONG Mantissa;
USHORT Exponent;
} FAST486_FPU_DATA_REG, *PFAST486_FPU_DATA_REG;
typedef union _FAST486_FPU_STATUS_REG
{
USHORT Value;
struct
{
ULONG Ie : 1;
ULONG De : 1;
ULONG Ze : 1;
ULONG Oe : 1;
ULONG Ue : 1;
ULONG Pe : 1;
ULONG Sf : 1;
ULONG Es : 1;
ULONG Code0 : 1;
ULONG Code1 : 1;
ULONG Code2 : 1;
ULONG Top : 3;
ULONG Code3 : 1;
ULONG Busy : 1;
};
} FAST486_FPU_STATUS_REG, *PFAST486_FPU_STATUS_REG;
typedef union _FAST486_FPU_CONTROL_REG
{
USHORT Value;
struct
{
ULONG Im : 1;
ULONG Dm : 1;
ULONG Zm : 1;
ULONG Om : 1;
ULONG Um : 1;
ULONG Pm : 1;
ULONG Reserved : 2;
ULONG Pc : 2;
ULONG Rc : 2;
ULONG Inf : 1;
// ULONG Reserved1 : 3;
};
} FAST486_FPU_CONTROL_REG, *PFAST486_FPU_CONTROL_REG;
struct _FAST486_STATE
{
FAST486_MEM_READ_PROC MemReadCallback;
@ -399,6 +449,10 @@ struct _FAST486_STATE
FAST486_INT_STATUS IntStatus;
UCHAR PendingIntNum;
PULONG Tlb;
FAST486_FPU_DATA_REG FpuRegisters[FAST486_NUM_FPU_REGS];
FAST486_FPU_STATUS_REG FpuStatus;
FAST486_FPU_CONTROL_REG FpuControl;
USHORT FpuTag;
};
/* FUNCTIONS ******************************************************************/

View file

@ -6,6 +6,7 @@ list(APPEND SOURCE
opcodes.c
opgroups.c
extraops.c
common.c)
common.c
fpu.c)
add_library(fast486 ${SOURCE})

100
lib/fast486/fpu.c Normal file
View file

@ -0,0 +1,100 @@
/*
* Fast486 386/486 CPU Emulation Library
* fpu.c
*
* Copyright (C) 2013 Aleksandar Andrejevic <theflash AT sdf DOT lonestar DOT org>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
/* INCLUDES *******************************************************************/
#include <windef.h>
// #define NDEBUG
#include <debug.h>
#include <fast486.h>
#include "common.h"
#include "opcodes.h"
#include "fpu.h"
/* PUBLIC FUNCTIONS ***********************************************************/
FAST486_OPCODE_HANDLER(Fast486FpuOpcodeD8)
{
// TODO: NOT IMPLEMENTED
UNIMPLEMENTED;
Fast486Exception(State, FAST486_EXCEPTION_UD);
return FALSE;
}
FAST486_OPCODE_HANDLER(Fast486FpuOpcodeD9)
{
// TODO: NOT IMPLEMENTED
UNIMPLEMENTED;
Fast486Exception(State, FAST486_EXCEPTION_UD);
return FALSE;
}
FAST486_OPCODE_HANDLER(Fast486FpuOpcodeDA)
{
// TODO: NOT IMPLEMENTED
UNIMPLEMENTED;
Fast486Exception(State, FAST486_EXCEPTION_UD);
return FALSE;
}
FAST486_OPCODE_HANDLER(Fast486FpuOpcodeDB)
{
// TODO: NOT IMPLEMENTED
UNIMPLEMENTED;
Fast486Exception(State, FAST486_EXCEPTION_UD);
return FALSE;
}
FAST486_OPCODE_HANDLER(Fast486FpuOpcodeDC)
{
// TODO: NOT IMPLEMENTED
UNIMPLEMENTED;
Fast486Exception(State, FAST486_EXCEPTION_UD);
return FALSE;
}
FAST486_OPCODE_HANDLER(Fast486FpuOpcodeDD)
{
// TODO: NOT IMPLEMENTED
UNIMPLEMENTED;
Fast486Exception(State, FAST486_EXCEPTION_UD);
return FALSE;
}
FAST486_OPCODE_HANDLER(Fast486FpuOpcodeDE)
{
// TODO: NOT IMPLEMENTED
UNIMPLEMENTED;
Fast486Exception(State, FAST486_EXCEPTION_UD);
return FALSE;
}
FAST486_OPCODE_HANDLER(Fast486FpuOpcodeDF)
{
// TODO: NOT IMPLEMENTED
UNIMPLEMENTED;
Fast486Exception(State, FAST486_EXCEPTION_UD);
return FALSE;
}
/* EOF */

55
lib/fast486/fpu.h Normal file
View file

@ -0,0 +1,55 @@
/*
* Fast486 386/486 CPU Emulation Library
* fpu.h
*
* Copyright (C) 2013 Aleksandar Andrejevic <theflash AT sdf DOT lonestar DOT org>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef _FPU_H_
#define _FPU_H_
#pragma once
/* DEFINES ********************************************************************/
enum
{
FPU_SINGLE_PRECISION = 0,
FPU_DOUBLE_PRECISION = 2,
FPU_DOUBLE_EXT_PRECISION = 3
};
enum
{
FPU_TAG_VALID = 0,
FPU_TAG_ZERO = 1,
FPU_TAG_SPECIAL = 2,
FPU_TAG_EMPTY = 3
};
FAST486_OPCODE_HANDLER(Fast486FpuOpcodeD8);
FAST486_OPCODE_HANDLER(Fast486FpuOpcodeD9);
FAST486_OPCODE_HANDLER(Fast486FpuOpcodeDA);
FAST486_OPCODE_HANDLER(Fast486FpuOpcodeDB);
FAST486_OPCODE_HANDLER(Fast486FpuOpcodeDC);
FAST486_OPCODE_HANDLER(Fast486FpuOpcodeDD);
FAST486_OPCODE_HANDLER(Fast486FpuOpcodeDE);
FAST486_OPCODE_HANDLER(Fast486FpuOpcodeDF);
#endif // _FPU_H_
/* EOF */

View file

@ -31,6 +31,7 @@
#include "opgroups.h"
#include "extraops.h"
#include "common.h"
#include "fpu.h"
/* PUBLIC VARIABLES ***********************************************************/
@ -253,14 +254,14 @@ Fast486OpcodeHandlers[FAST486_NUM_OPCODE_HANDLERS] =
Fast486OpcodeAad,
Fast486OpcodeSalc,
Fast486OpcodeXlat,
NULL, // TODO: OPCODE 0xD8 NOT SUPPORTED
NULL, // TODO: OPCODE 0xD9 NOT SUPPORTED
NULL, // TODO: OPCODE 0xDA NOT SUPPORTED
NULL, // TODO: OPCODE 0xDB NOT SUPPORTED
NULL, // TODO: OPCODE 0xDC NOT SUPPORTED
NULL, // TODO: OPCODE 0xDD NOT SUPPORTED
NULL, // TODO: OPCODE 0xDE NOT SUPPORTED
NULL, // TODO: OPCODE 0xDF NOT SUPPORTED
Fast486FpuOpcodeD8,
Fast486FpuOpcodeD9,
Fast486FpuOpcodeDA,
Fast486FpuOpcodeDB,
Fast486FpuOpcodeDC,
Fast486FpuOpcodeDD,
Fast486FpuOpcodeDE,
Fast486FpuOpcodeDF,
Fast486OpcodeLoop,
Fast486OpcodeLoop,
Fast486OpcodeLoop,