News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

How to use FST m64fp ?

Started by Bokepatza, June 26, 2009, 07:14:54 PM

Previous topic - Next topic

Bokepatza

Hi all, I'm trying to make a program in MASM32 which uses FPU, but I think I'm doing something wrong qhen I store REAL8 in memory or when I read REAL8 from memory. If someone could help me, I'll be grateful. Thanx

.586
.model flat,stdcall
option casemap:none

.data
valor      REAL8   0.01
result    REAL8   0.0
buffer          BYTE    60      Dup(0),0
.DATA?
Tabla    REAL8   100   DUP     (?)
.
.
.
finit
fld     valor
fst     Tabla[1]
fstp   Tabla[2]
invoke  FloatToStr2,Tabla[1],addr buffer
print   addr buffer
newline
invoke  FloatToStr2,Tabla[2],addr buffer
print   addr buffer
.
.
.

I got Tabla[2] value ok, but Tabla[1] wrong. If I do this with more than 2 values, there are all wrong, but the last.

Can anyone help me? Thanx

dedndave

Tabla[1] refers to "the address of Tabla+1 (byte)"

try Tabla, Tabla+8, and so on

Tabla+8 is the same as Tabla[8]

Bokepatza

Thank you very much for your quick answer. I have spent so many time trying to make this run, but I always think Tabla[1] refers to the next REAL8 value  ::)

Nice! that runs ok.

I thought Tabla[1] refers to the next REAL8

So if I declare a STRUCT like this, I shall type Bessel_Tabla[16] to access the 2nd position of the table?

Bessel_point    STRUCT
        x       REAL8   0.0
        y       REAL8   0.0
Bessel_point    ends

Bessel_Tabla    Bessel_point    10000   DUP     ({0.0},{0.0})

.
.
.
                fld     valor
                fadd    paso
                fst     valor
                fst     Bessel_Tabla[0].x
                invoke  bessj0
                fstp    Bessel_Tabla[0].y

                fld     valor
                fadd    paso
                fst     valor
                fst     Bessel_Tabla[16].x
                invoke  bessj0
                fstp    Bessel_Tabla[16].y

        invoke  FloatToStr2,Bessel_Tabla[0].x,addr buffer
        print   addr buffer
        print   addr tab
        invoke  FloatToStr2,Bessel_Tabla[0].y,addr buffer
        print   addr buffer
        newline
        invoke  FloatToStr2,Bessel_Tabla[16].x,addr buffer
        print   addr buffer
        print   addr tab
        invoke  FloatToStr2,Bessel_Tabla[16].y,addr buffer
        print   addr buffer
        newline
        getkey
.
.
.

dedndave

because you have named the structure elements, you may refer to them as:
Bessel_point.x and Bessel_point.y
(those are periods)

Bokepatza

I don't understand the last post. I'm spanish, excuse me.

In order to access the 2nd point x value, is this correct?

invoke  FloatToStr2,Bessel_Tabla[16].x,addr buffer

I tried this and runs ok

What do you mean when you say Bessel_point.x and Bessel_point.y?

Thanks again ;)

dedndave

oops
i made an error
make that

Bessel_Tabla.x and Bessel_Tabla.y

dedndave

either way will work
oh - i see - you repeated the structure 10,000 times
i am not sure about that one - lol
but, no need to make it a structure if you are not going to use it that way

just use
Bessel_Tabla real8 20000 dup(0.0)

Bokepatza

Right

Now, I will make a WHILE to fill in the 20000 entries of the table.

I suppose I'll be back asking such this easy question, but I'm not used to MASM.

Thanks again, now I can continue my application.