Microsoft DirectX 8.0 (C++)

expp

Provides exponential 2x partial support.

expp   vDest, vSrc0

Registers

vDest
Destination register, holding the result of the operation.
vSrc0
Source register, specifying the input argument.

Operation

The following code fragment shows the operations performed by the expp instruction to write a result to the destination.

    SetDestReg();
    SetSrcReg(0);

    float w = m_Source[0].w;
    float v = (float)floor(m_Source[0].w);

    m_TmpReg.x = (float)pow(2, v);
    m_TmpReg.y = w - v;
    // Reduced precision exponent
    float tmp = (float)pow(2, w);
    DWORD tmpd = *(DWORD*)&tmp & 0xffffff00;
    m_TmpReg.z = *(float*)&tmpd;
    m_TmpReg.w = 1;

    WriteResult();

Remarks

The expp instruction produces undefined results if fed a negative value for the exponent.

This instruction provides exponential base 2 partial precision. It generates an approximate answer in vDest.z and allows for a more accurate determination of vDest.x*function(vDest.y), where function is a user approximation to 2*vDest.y over the limited range (0.0 <= vDest.y < 1.0).

This instruction accepts a scalar source, and reduced precision arithmetic is acceptable in evaluating vDest.z. However, the approximation error must be less than 1/(211) the absolute error (10-bit precision) and over the range (0.0 <= t.y < 1.0). Also, expp returns 1.0 in w.

The following example illustrates how the expp instruction might be used.

expp r5, r0