PSPSDK 2025-02-06
Loading...
Searching...
No Matches
pspfpu.c File Reference
#include "pspfpu.h"
Include dependency graph for pspfpu.c:

Macros

#define PSP_MATH_PI   3.14159265358979323846
 
#define PSP_MATH_TWOPI   (PSP_MATH_PI * 2.0)
 
#define PSP_MATH_SQRT2   1.41421356237309504880
 
#define PSP_MATH_LN2   0.69314718055994530942
 
#define PSP_MATH_LOG2E   1.4426950408889634074
 
#define COS_SIN_DIV   0.208
 

Functions

uint32_t pspFpuGetFCR31 (void)
 Get the current value of the control/status register.
 
void pspFpuSetFCR31 (uint32_t var)
 Set the current value of the control/status register.
 
void pspFpuSetRoundmode (enum PspFpuRoundMode mode)
 Set the current round mode.
 
enum PspFpuRoundMode pspFpuGetRoundmode (void)
 Get the current round mode.
 
uint32_t pspFpuGetFlags (void)
 Get the exception flags (set when an exception occurs but the actual exception bit is not enabled)
 
void pspFpuClearFlags (uint32_t clear)
 Clear the flags bits.
 
uint32_t pspFpuGetEnable (void)
 Get the exception enable flags.
 
void pspFpuSetEnable (uint32_t enable)
 Set the enable flags bits.
 
uint32_t pspFpuGetCause (void)
 Get the cause bits (only useful if you installed your own exception handler)
 
void pspFpuClearCause (uint32_t clear)
 Clear the cause bits.
 
uint32_t pspFpuGetFS (void)
 Get the current value of the FS bit (if FS is 0 then an exception occurs with denormalized values, if 1 then they are rewritten as 0.
 
void pspFpuSetFS (uint32_t fs)
 Set the FS bit.
 
uint32_t pspFpuGetCondbits (void)
 Get the condition flags (8 bits)
 
void pspFpuClearCondbits (uint32_t clear)
 Clear the condition bits.
 
float pspFpuAbs (float fs)
 returns absolute value
 
int pspFpuCeil (float fs)
 Round up.
 
int pspFpuFloor (float fs)
 Truncate.
 
float pspFpuMax (float fs1, float fs2)
 select maximum value
 
float pspFpuMin (float fs1, float fs2)
 select minimum value
 
float pspFpuNeg (float fs)
 Sign reversal.
 
int pspFpuRound (float fs)
 Round to nearest.
 
float pspFpuRsqrt (float fs)
 
float pspFpuSqrt (float fs)
 Square root.
 
int pspFpuTrunc (float fs)
 Round towards zero.
 
float pspFpuFmod (float fs, float fd)
 
float pspFpuFrac (float fs)
 
float pspFpuReinterpretFloat (uint32_t ui)
 
uint32_t pspFpuReinterpretUint (float fs)
 
int pspFpuIsEqual (float fs1, float fs2)
 
float pspFpuSignFloat (float fs)
 
int pspFpuSignInt (float fs)
 
float pspFpuPositiveZero (void)
 Positive zero.
 
float pspFpuNegativeZero (void)
 Negative zero.
 
int pspFpuIsZero (float f)
 Test for zero value.
 
int pspFpuIsPositiveZero (float f)
 Test for positive zero.
 
int pspFpuIsNegativeZero (float f)
 Test for negative zero.
 
int pspFpuIsDenormal (float f)
 Test for denormalized number.
 
int pspFpuIsZeroOrDenormal (float f)
 Test for zero or denormalized number.
 
float pspFpuPositiveInf (void)
 Positive infinity.
 
float pspFpuNegativeInf (void)
 Negative infinity.
 
int pspFpuIsInf (float f)
 Test for infinity.
 
float pspFpuPositiveNaN (void)
 NaN (positive SNaN)
 
float pspFpuNegativeNaN (void)
 NaN (negative SNaN)
 
float pspFpuPositiveQNaN (void)
 Quiet NaN (positive QNaN)
 
float pspFpuNegativeQNaN (void)
 Quiet NaN (positive QNaN)
 
float pspFpuPositiveSNaN (unsigned int uiSignal)
 Signaling NaN (positive SNaN)
 
float pspFpuNegativeSNaN (unsigned int uiSignal)
 Signaling NaN (negative SNaN)
 
int pspFpuIsNaN (float f)
 Test for NaN.
 
int pspFpuIsInfOrNaN (float f)
 Test for infinity or NaN.
 
float pspFpuNormalizePhase (float fs)
 
float pspFpuLog (float x)
 Natural Logarithm.
 
float pspFpuExp (float x)
 Exponential.
 
float pspFpuSin (float x)
 Sine.
 
float pspFpuCos (float x)
 Cosine.
 
float pspFpuAtan (float x)
 Arc tangent.
 
float pspFpuAsin (float x)
 ArcSin.
 
float pspFpuAcos (float x)
 ArcCos.
 

Macro Definition Documentation

◆ COS_SIN_DIV

#define COS_SIN_DIV   0.208

Referenced by pspFpuCos(), and pspFpuSin().

◆ PSP_MATH_LN2

#define PSP_MATH_LN2   0.69314718055994530942

Referenced by pspFpuExp().

◆ PSP_MATH_LOG2E

#define PSP_MATH_LOG2E   1.4426950408889634074

Referenced by pspFpuExp().

◆ PSP_MATH_PI

#define PSP_MATH_PI   3.14159265358979323846

Referenced by pspFpuAtan(), pspFpuCos(), and pspFpuSin().

◆ PSP_MATH_SQRT2

#define PSP_MATH_SQRT2   1.41421356237309504880

◆ PSP_MATH_TWOPI

#define PSP_MATH_TWOPI   (PSP_MATH_PI * 2.0)

Referenced by pspFpuNormalizePhase().

Function Documentation

◆ pspFpuAbs()

float pspFpuAbs ( float fs)

returns absolute value

◆ pspFpuAcos()

float pspFpuAcos ( float x)

ArcCos.

References pspFpuAtan(), and x.

◆ pspFpuAsin()

float pspFpuAsin ( float x)

ArcSin.

References pspFpuAtan(), and x.

◆ pspFpuAtan()

float pspFpuAtan ( float x)

Arc tangent.

References PSP_MATH_PI, and x.

Referenced by pspFpuAcos(), and pspFpuAsin().

◆ pspFpuCeil()

int pspFpuCeil ( float fs)

Round up.

◆ pspFpuClearCause()

void pspFpuClearCause ( uint32_t clear)

Clear the cause bits.

Parameters
clear- Bitmask of the bits to clear, one or more of PspFpuExceptions

References PSP_FPU_CAUSE_POS, pspFpuGetFCR31(), and pspFpuSetFCR31().

◆ pspFpuClearCondbits()

void pspFpuClearCondbits ( uint32_t clear)

Clear the condition bits.

Parameters
clear- Bitmask of the bits to clear

References PSP_FPU_CC0_POS, PSP_FPU_CC17_POS, pspFpuGetFCR31(), and pspFpuSetFCR31().

◆ pspFpuClearFlags()

void pspFpuClearFlags ( uint32_t clear)

Clear the flags bits.

Parameters
clear- Bitmask of the bits to clear, one or more of PspFpuExceptions

References PSP_FPU_FLAGS_POS, pspFpuGetFCR31(), and pspFpuSetFCR31().

◆ pspFpuCos()

float pspFpuCos ( float x)

Cosine.

References COS_SIN_DIV, PSP_MATH_PI, x, and y.

◆ pspFpuExp()

float pspFpuExp ( float x)

Exponential.

References f, i, PSP_MATH_LN2, PSP_MATH_LOG2E, x, and z.

◆ pspFpuFloor()

int pspFpuFloor ( float fs)

Truncate.

◆ pspFpuFmod()

float pspFpuFmod ( float fs,
float fd )

◆ pspFpuFrac()

float pspFpuFrac ( float fs)

◆ pspFpuGetCause()

uint32_t pspFpuGetCause ( void )

Get the cause bits (only useful if you installed your own exception handler)

Returns
Bitmask of flags, zero or more of PspFpuExceptions

References PSP_FPU_CAUSE_MASK, PSP_FPU_CAUSE_POS, and pspFpuGetFCR31().

◆ pspFpuGetCondbits()

uint32_t pspFpuGetCondbits ( void )

Get the condition flags (8 bits)

Returns
The current condition flags

References PSP_FPU_CC0_MASK, PSP_FPU_CC0_POS, PSP_FPU_CC17_MASK, PSP_FPU_CC17_POS, and pspFpuGetFCR31().

◆ pspFpuGetEnable()

uint32_t pspFpuGetEnable ( void )

Get the exception enable flags.

Returns
Bitmask of the flags, zero or more of PspFpuExceptions

References PSP_FPU_ENABLE_MASK, PSP_FPU_ENABLE_POS, and pspFpuGetFCR31().

◆ pspFpuGetFCR31()

uint32_t pspFpuGetFCR31 ( void )

Get the current value of the control/status register.

Returns
The value of the control/status register

Referenced by pspFpuClearCause(), pspFpuClearCondbits(), pspFpuClearFlags(), pspFpuGetCause(), pspFpuGetCondbits(), pspFpuGetEnable(), pspFpuGetFlags(), pspFpuGetFS(), pspFpuGetRoundmode(), pspFpuSetEnable(), pspFpuSetFS(), and pspFpuSetRoundmode().

◆ pspFpuGetFlags()

uint32_t pspFpuGetFlags ( void )

Get the exception flags (set when an exception occurs but the actual exception bit is not enabled)

Returns
Bitmask of the flags, zero or more of PspFpuExceptions

References PSP_FPU_FLAGS_MASK, PSP_FPU_FLAGS_POS, and pspFpuGetFCR31().

◆ pspFpuGetFS()

uint32_t pspFpuGetFS ( void )

Get the current value of the FS bit (if FS is 0 then an exception occurs with denormalized values, if 1 then they are rewritten as 0.

Returns
The current state of the FS bit (0 or 1)

References PSP_FPU_FS_MASK, PSP_FPU_FS_POS, and pspFpuGetFCR31().

◆ pspFpuGetRoundmode()

enum PspFpuRoundMode pspFpuGetRoundmode ( void )

Get the current round mode.

Returns
The round mode, one of PspFpuRoundMode

References PSP_FPU_RM_MASK, and pspFpuGetFCR31().

◆ pspFpuIsDenormal()

int pspFpuIsDenormal ( float f)

Test for denormalized number.

References f.

◆ pspFpuIsEqual()

int pspFpuIsEqual ( float fs1,
float fs2 )

◆ pspFpuIsInf()

int pspFpuIsInf ( float f)

Test for infinity.

References f.

◆ pspFpuIsInfOrNaN()

int pspFpuIsInfOrNaN ( float f)

Test for infinity or NaN.

References f.

◆ pspFpuIsNaN()

int pspFpuIsNaN ( float f)

Test for NaN.

References f.

◆ pspFpuIsNegativeZero()

int pspFpuIsNegativeZero ( float f)

Test for negative zero.

References f.

◆ pspFpuIsPositiveZero()

int pspFpuIsPositiveZero ( float f)

Test for positive zero.

References f.

◆ pspFpuIsZero()

int pspFpuIsZero ( float f)

Test for zero value.

References f.

◆ pspFpuIsZeroOrDenormal()

int pspFpuIsZeroOrDenormal ( float f)

Test for zero or denormalized number.

References f.

◆ pspFpuLog()

float pspFpuLog ( float x)

Natural Logarithm.

References a, b, f, i, x, y, and z.

◆ pspFpuMax()

float pspFpuMax ( float fs1,
float fs2 )

select maximum value

◆ pspFpuMin()

float pspFpuMin ( float fs1,
float fs2 )

select minimum value

◆ pspFpuNeg()

float pspFpuNeg ( float fs)

Sign reversal.

◆ pspFpuNegativeInf()

float pspFpuNegativeInf ( void )

Negative infinity.

◆ pspFpuNegativeNaN()

float pspFpuNegativeNaN ( void )

NaN (negative SNaN)

◆ pspFpuNegativeQNaN()

float pspFpuNegativeQNaN ( void )

Quiet NaN (positive QNaN)

◆ pspFpuNegativeSNaN()

float pspFpuNegativeSNaN ( unsigned int uiSignal)

Signaling NaN (negative SNaN)

◆ pspFpuNegativeZero()

float pspFpuNegativeZero ( void )

Negative zero.

◆ pspFpuNormalizePhase()

float pspFpuNormalizePhase ( float fs)

References PSP_MATH_TWOPI.

◆ pspFpuPositiveInf()

float pspFpuPositiveInf ( void )

Positive infinity.

◆ pspFpuPositiveNaN()

float pspFpuPositiveNaN ( void )

NaN (positive SNaN)

◆ pspFpuPositiveQNaN()

float pspFpuPositiveQNaN ( void )

Quiet NaN (positive QNaN)

◆ pspFpuPositiveSNaN()

float pspFpuPositiveSNaN ( unsigned int uiSignal)

Signaling NaN (positive SNaN)

◆ pspFpuPositiveZero()

float pspFpuPositiveZero ( void )

Positive zero.

◆ pspFpuReinterpretFloat()

float pspFpuReinterpretFloat ( uint32_t ui)

References ui.

◆ pspFpuReinterpretUint()

uint32_t pspFpuReinterpretUint ( float fs)

◆ pspFpuRound()

int pspFpuRound ( float fs)

Round to nearest.

◆ pspFpuRsqrt()

float pspFpuRsqrt ( float fs)

◆ pspFpuSetEnable()

void pspFpuSetEnable ( uint32_t enable)

Set the enable flags bits.

Parameters
enable- Bitmask of exceptions to enable, zero or more of PspFpuExceptions

References PSP_FPU_ENABLE_POS, pspFpuGetFCR31(), and pspFpuSetFCR31().

◆ pspFpuSetFCR31()

void pspFpuSetFCR31 ( uint32_t var)

Set the current value of the control/status register.

Parameters
var- The value to set.

Referenced by pspFpuClearCause(), pspFpuClearCondbits(), pspFpuClearFlags(), pspFpuSetEnable(), pspFpuSetFS(), and pspFpuSetRoundmode().

◆ pspFpuSetFS()

void pspFpuSetFS ( uint32_t fs)

Set the FS bit.

Parameters
fs- 0 or 1 to unset or set fs

References PSP_FPU_FS_POS, pspFpuGetFCR31(), and pspFpuSetFCR31().

◆ pspFpuSetRoundmode()

void pspFpuSetRoundmode ( enum PspFpuRoundMode mode)

Set the current round mode.

Parameters
mode- The rounding mode to set, one of PspFpuRoundMode

References PSP_FPU_RM_MASK, pspFpuGetFCR31(), and pspFpuSetFCR31().

◆ pspFpuSignFloat()

float pspFpuSignFloat ( float fs)

References fv.

◆ pspFpuSignInt()

int pspFpuSignInt ( float fs)

◆ pspFpuSin()

float pspFpuSin ( float x)

Sine.

References COS_SIN_DIV, PSP_MATH_PI, x, and y.

◆ pspFpuSqrt()

float pspFpuSqrt ( float fs)

Square root.

◆ pspFpuTrunc()

int pspFpuTrunc ( float fs)

Round towards zero.