Re: Float stack gymnastic

From: Charles Melice <mail_at_forthcad.com>
Date: Sat, 29 May 1999 16:03:35 +0100

Marcel,

> Date: Fri, 28 May 1999 21:26:38 +0200 (CEST)
> From: mhx_at_iae.nl (Marcel Hendrix)
> Subject: Re: Float stack gymnastic
> > About passing floats to the OS ( or 'C' code in general ) I have send a
> > previous mail with a partial solution - only for single floats. Again
> > today, I cannot how to pass double-floats to a standard DLL!
>
> Here I have a real language problem: what do you mean by this? Did it
work
> before, but not today?
--------
I can pass single-float to the OS. I use a similar method:

        xx HERE SF! HERE @

> Passing a dfloat to the OS: xx HERE DF! HERE 2@ ( swap ) ... You have
> to push the dfloat on the integer stack. The swap *might* be needed.
--------
Thank you Marcel !

Now, I can pass double-floats, and the return value is on the hardware
stack.

Here is my test sequence in SwiftForth:

hardware stack enabled
----------------------

        requires fpmath \ hardware stack
        DLL: test.dll \ small dll with a simple 'C' function
                                \ double Test(double d)
                                \ {
                                \ if (d==3.14) MessageBox(....-
                                \ ...
                                \ return 2*d;
                                \ }

        2 import: Test ok \ 2 params for 1 double !!!!
        3.14e pad df! ok
        1e 2e pad 2@ swap Test ok \ the swap if needed
        fdepth . 3 ok \ n: 1e 2e 6.28e s: 1
        f. 6.2800000 ok
        f. f. 2.0000000 1.0000000 ok
        . 1 ok \ to drop \ always =1

software stack enabled
----------------------
Passing double is also OK.

> The real problem is when the OS / C *returns* a double float, or when you
> need a callback routine that gets dfloat parameters and returns a dfloat
> (OpenGL, FORTRAN and C numeric libraries).

But now I have the same problem as you: I cannot get the returned double
value. (where is it ? - on the hardware stack, probably)

I hope to never need returned double-floats, else I must use the hardware
stack, (then fdepth-max=8)

Regards,
Charles

.
Received on Sat May 29 1999 - 16:03:35 PDT


Subscribe to our e-mail list service. It's free for all SwiftForth and SwiftX users!

This archive was generated 09-Feb-2012. Archive updated nightly.