Author Topic: Good old FPU question  (Read 934 times)

Gunther

  • Member
  • *****
  • Posts: 4198
  • Forgive your enemies, but never forget their names
Good old FPU question
« on: May 02, 2022, 03:35:52 AM »
I'm currently experimenting with numerics for Taylor series. In this context, I need rounding by truncation. Of course, this can be achieved by modifying the control word of the FPU.
But according to the current Intel manuals, the FPU instruction FISTTP - Store Integer with Truncation is existing.

Both JWASM for DOS and TASM 4 don't know this instruction. NASM, YASM and GAS, on the other hand, translate without complaint. What does ML for DOS say about this?
You have to know the facts before you can distort them.

daydreamer

  • Member
  • *****
  • Posts: 2399
  • my kind of REAL10 Blonde
Re: Good old FPU question
« Reply #1 on: May 03, 2022, 07:22:37 AM »
You could write a macro for it,but it's later sse3 instruction so probably not supported in dos emulator
But macro that emulates it?
fadd 0.5
Fistp var
my none asm creations
http://masm32.com/board/index.php?topic=6937.msg74303#msg74303
I am an Invoker
"An Invoker is a mage who specializes in the manipulation of raw and elemental energies."
Like SIMD coding

Gunther

  • Member
  • *****
  • Posts: 4198
  • Forgive your enemies, but never forget their names
Re: Good old FPU question
« Reply #2 on: May 03, 2022, 08:24:50 AM »
Daydreamer,

You could write a macro for it,but it's later sse3 instruction so probably not supported in dos emulator

you're right. Looks like an FPU instruction, but belongs to SSE3. I'll find another solution.
You have to know the facts before you can distort them.

HSE

  • Member
  • *****
  • Posts: 2502
  • AMD 7-32 / i3 10-64
Re: Good old FPU question
« Reply #3 on: May 03, 2022, 08:52:07 AM »
fadd fsub 0.5
Fistp var

 :biggrin: That is the solution because default rounding mode is to-nearest. But it will fail if your number is already rounded.

A little perturbation can solve that, but depends what precision you need.
Code: [Select]
   .data
        uno          real8    1.0
        perturbation real8    1.0e-15
        cero5        real8    0.5
        a2           sdword   0
    .code
        fld uno
        fadd perturbation
        fsub cero5
        fistp a2
Equations in Assembly: SmplMath

Gunther

  • Member
  • *****
  • Posts: 4198
  • Forgive your enemies, but never forget their names
Re: Good old FPU question
« Reply #4 on: May 03, 2022, 09:45:25 AM »
HSE,

fadd fsub 0.5
Fistp var

 :biggrin: That is the solution because default rounding mode is to-nearest. But it will fail if your number is already rounded.

You're right. This is faster than modifying the rounding mode of the FPU.

A little perturbation can solve that, but depends what precision you need.

Excellent idea. I think for REAL4 is 1e-5 good enough.
You have to know the facts before you can distort them.