Question

I am writing a program that calculate arctan function.
Function that does all work works fine, but when i try get bcd-value fbstp command store weird value and fstp store right value.

segment data 
result:  resb 10
tmp_val: dd 000000000h
precs:   dq 03a83126fh ; 0.001
arg:     dd 03f800000h ; 0.7

segment code
..start:

mov ax,data
mov ds, ax
finit

call calc_value
fst dword[tmp_val]
fbstp tword [result]

mov ax, 4C00h
int 21h

And after execution in memory at tmp_val: 0x3f490edb (0.785383)
and at result: 0x0000000000000000001

And i write this for DOS

Was it helpful?

Solution

The intel instruction set reference says this for fbstp:

If the source value is a non-integral value, it is rounded to an integer value, according to rounding mode specified by the RC field of the FPU control word.

As such, a result of 1 sounds right.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top