The MASM Forum
General => The Campus => Topic started by: Gunther 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 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
-
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.
-
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.
.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
-
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.