Skip to content

Commit

Permalink
[FAST486]
Browse files Browse the repository at this point in the history
Update the copyright year.
Implement the first batch of FPU instructions. These are still experimental.



git-svn-id: svn://svn.reactos.org/reactos/trunk@64656 97493ccd-5924-5043-b1f5-66cb403b36ce
  • Loading branch information
aandrejevic committed Oct 10, 2014
1 parent 5e2f753 commit c6d2b35
Show file tree
Hide file tree
Showing 13 changed files with 558 additions and 50 deletions.
7 changes: 6 additions & 1 deletion reactos/include/reactos/libs/fast486/fast486.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Fast486 386/486 CPU Emulation Library
* fast486.h
*
* Copyright (C) 2013 Aleksandar Andrejevic <theflash AT sdf DOT lonestar DOT org>
* Copyright (C) 2014 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
Expand Down Expand Up @@ -91,6 +91,8 @@
#define FAST486_PREFIX_REPNZ (1 << 4)
#define FAST486_PREFIX_REP (1 << 5)

#define FAST486_FPU_DEFAULT_CONTROL 0x037F

struct _FAST486_STATE;
typedef struct _FAST486_STATE FAST486_STATE, *PFAST486_STATE;

Expand Down Expand Up @@ -420,6 +422,7 @@ typedef struct _FAST486_FPU_DATA_REG
{
ULONGLONG Mantissa;
USHORT Exponent;
UCHAR Sign;
} FAST486_FPU_DATA_REG, *PFAST486_FPU_DATA_REG;

typedef union _FAST486_FPU_STATUS_REG
Expand Down Expand Up @@ -490,10 +493,12 @@ struct _FAST486_STATE
FAST486_INT_STATUS IntStatus;
UCHAR PendingIntNum;
PULONG Tlb;
#ifndef FAST486_NO_FPU
FAST486_FPU_DATA_REG FpuRegisters[FAST486_NUM_FPU_REGS];
FAST486_FPU_STATUS_REG FpuStatus;
FAST486_FPU_CONTROL_REG FpuControl;
USHORT FpuTag;
#endif
};

/* FUNCTIONS ******************************************************************/
Expand Down
2 changes: 1 addition & 1 deletion reactos/lib/fast486/common.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Fast486 386/486 CPU Emulation Library
* common.c
*
* Copyright (C) 2013 Aleksandar Andrejevic <theflash AT sdf DOT lonestar DOT org>
* Copyright (C) 2014 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
Expand Down
2 changes: 1 addition & 1 deletion reactos/lib/fast486/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Fast486 386/486 CPU Emulation Library
* common.h
*
* Copyright (C) 2013 Aleksandar Andrejevic <theflash AT sdf DOT lonestar DOT org>
* Copyright (C) 2014 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
Expand Down
75 changes: 74 additions & 1 deletion reactos/lib/fast486/common.inl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Fast486 386/486 CPU Emulation Library
* common.inl
*
* Copyright (C) 2013 Aleksandar Andrejevic <theflash AT sdf DOT lonestar DOT org>
* Copyright (C) 2014 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
Expand All @@ -20,6 +20,7 @@
*/

#include "common.h"
#include "fpu.h"

/* PUBLIC FUNCTIONS ***********************************************************/

Expand Down Expand Up @@ -1330,4 +1331,76 @@ Fast486WriteModrmDwordOperands(PFAST486_STATE State,
return TRUE;
}

#ifndef FAST486_NO_FPU

FORCEINLINE
VOID
Fast486FpuNormalize(PFAST486_STATE State, PFAST486_FPU_DATA_REG Data)
{
UINT LeadingZeros = 0;

if (FPU_IS_NORMALIZED(Data)) return;
if (FPU_IS_ZERO(Data))
{
Data->Exponent = 0;
return;
}

/* Count the leading zeros */
while (!(Data->Mantissa & (1 << (63 - LeadingZeros)))) LeadingZeros++;

if (LeadingZeros < Data->Exponent)
{
Data->Mantissa <<= LeadingZeros;
Data->Exponent -= LeadingZeros;
}
else
{
/* Make it denormalized */
Data->Mantissa <<= Data->Exponent - 1;
Data->Exponent = 1;

/* Underflow */
State->FpuStatus.Ue = TRUE;
}
}

FORCEINLINE
USHORT
Fast486GetValueTag(PFAST486_FPU_DATA_REG Data)
{
if (FPU_IS_ZERO(Data)) return FPU_TAG_ZERO;
else if (FPU_IS_NAN(Data)) return FPU_TAG_SPECIAL;
else return FPU_TAG_VALID;
}

FORCEINLINE
VOID
Fast486FpuPush(PFAST486_STATE State,
PFAST486_FPU_DATA_REG Data)
{
State->FpuStatus.Top--;

if (FPU_GET_TAG(0) == FPU_TAG_EMPTY)
{
FPU_ST(0) = *Data;
FPU_SET_TAG(0, Fast486GetValueTag(Data));
}
else State->FpuStatus.Ie = TRUE;
}

FORCEINLINE
VOID
Fast486FpuPop(PFAST486_STATE State)
{
if (FPU_GET_TAG(0) != FPU_TAG_EMPTY)
{
FPU_SET_TAG(0, FPU_TAG_EMPTY);
State->FpuStatus.Top++;
}
else State->FpuStatus.Ie = TRUE;
}

#endif

/* EOF */
2 changes: 1 addition & 1 deletion reactos/lib/fast486/extraops.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Fast486 386/486 CPU Emulation Library
* extraops.c
*
* Copyright (C) 2013 Aleksandar Andrejevic <theflash AT sdf DOT lonestar DOT org>
* Copyright (C) 2014 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
Expand Down
2 changes: 1 addition & 1 deletion reactos/lib/fast486/extraops.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Fast486 386/486 CPU Emulation Library
* extraops.h
*
* Copyright (C) 2013 Aleksandar Andrejevic <theflash AT sdf DOT lonestar DOT org>
* Copyright (C) 2014 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
Expand Down
7 changes: 6 additions & 1 deletion reactos/lib/fast486/fast486.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Fast486 386/486 CPU Emulation Library
* fast486.c
*
* Copyright (C) 2013 Aleksandar Andrejevic <theflash AT sdf DOT lonestar DOT org>
* Copyright (C) 2014 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
Expand Down Expand Up @@ -282,6 +282,11 @@ Fast486Reset(PFAST486_STATE State)
#ifndef FAST486_NO_FPU
/* Initialize CR0 */
State->ControlRegisters[FAST486_REG_CR0] |= FAST486_CR0_ET;

/* Initialize the FPU control and tag registers */
State->FpuControl.Value = FAST486_FPU_DEFAULT_CONTROL;
State->FpuStatus.Value = 0;
State->FpuTag = 0xFFFF;
#endif

/* Restore the callbacks and TLB */
Expand Down
Loading

0 comments on commit c6d2b35

Please sign in to comment.