● デバッグ・ヒント

独自の演算処理との併用

floatex.dll の演算関数は、内部でレジスタスタックを使用します。そのため、呼び出し側のプログラムがレジスタスタックを多量に占有している状態で関数を使用すると、演算結果に異常が発生する事があります。

テスト.

#include <stdio.h>
#include "floatex.h"

void __cdecl    main(void)
{
    FLOATEX     v,t;
    char        buf[32];

    floatex_reset();

    _asm{
        fld1                            ; @
        fld1                            ; A
        fld1                            ; B
        fld1                            ; C
        fld1                            ; D
        fld1                            ; E
        fld1                            ; F
        fld1                            ; G
    }

    floatex_eadd(fex_const_10,fex_const_2,t);

    _asm{
        faddp           st(1),st        ; G
        faddp           st(1),st        ; F
        faddp           st(1),st        ; E
        faddp           st(1),st        ; D
        faddp           st(1),st        ; C
        faddp           st(1),st        ; B
        faddp           st(1),st        ; A
        fstp            tbyte ptr v     ; @
    }

    floatex_ldstr_ldtoa(v,buf);
    printf("%s\n",buf);

    floatex_ldstr_term();
    floatex_reset();
}

この例の場合、レジスタスタックが全て埋まった状態で floatex_eadd を呼び出しているので、スタックフォルトが発生します。マスクが掛かっているので例外は発生せず、結果は NAN が表示されます。