FP stack size in ANS Forth
  Home FAQ Contact Sign in
comp.lang.forth only
 
Advanced search
POPULAR GROUPS

more...

comp.lang.forth Profile…
 Up
Re: FP stack size in ANS Forth         


Author: Andrew Haley
Date: Jan 11, 2007 04:31

Andreas Kochenburger nospam.com> wrote:
> Out of curiosity:
> 12.3.3 Floating-point stack
> ...
> A program that depends on the floating-point stack being larger than
> six items has an environmental dependency.
> How come that this restriction came into the standard?

The 8087. When that chip was designed, it was intended to have an
interrupt that pushed to registers on overflow, giving unlimited
floating-point stack depth, but the interrupt didn't work. So, users
of the 8087 are limited to 8 items. Forth's limit is six: the extra
two are for system overhead.

Andrew.
no comments
Re: FP stack size in ANS Forth         


Author: Bruce McFarling
Date: Jan 13, 2007 07:57

Krishna Myneni wrote:
> Today, most Forth systems appear to allow for a deep fp stack, e.g. gforth, pfe,
> iforth, ... (bigForth is an exception). This is the common practice, and hence,
> is a candidate for a new Forth standard.

ANS Forth allows implementations with a deep fp stack, and allows code
that requires a deep fp stack, so neither of those would change.

The only substantial change would therefore be to rule out
implementations with short fp stacks.

Of course, supporting small RAM microcontrollers is the most plausible
argument that has been advanced for indefinite maintenance of the
mixed-stack standard, and so ruling out short fp stacks would excise
that argument. But I don't see that as an argument in favor of any such
change.
> When I program, I don't want to worry about the fp stack depth. Recursion is not
> the only case where a deep fp stack is useful. For example, a file containing a
> hundred or so values in fp format can be loaded using INCLUDE, rather than
> having to parse the data out of the file. Of course a language standard should
> not be designed around a single peculiar application any more than being
> designed around the peculiar limitations of a single piece of hardware.
Show full article (1.91Kb)
no comments
Re: FP stack size in ANS Forth         


Author: Krishna Myneni
Date: Jan 13, 2007 09:08

Bruce McFarling wrote:
> Krishna Myneni wrote:
>
>>Today, most Forth systems appear to allow for a deep fp stack, e.g. gforth, pfe,
>>iforth, ... (bigForth is an exception). This is the common practice, and hence,
>>is a candidate for a new Forth standard.
>
>
> ANS Forth allows implementations with a deep fp stack, and allows code
> that requires a deep fp stack, so neither of those would change.
>
> The only substantial change would therefore be to rule out
> implementations with short fp stacks.
>
> Of course, supporting small RAM microcontrollers is the most plausible
> argument that has been advanced for indefinite maintenance of the
> mixed-stack standard, and so ruling out short fp stacks would excise
> that argument. But I don't see that as an argument in favor of any such
> change.
> ...
Show full article (3.02Kb)
no comments
Re: FP stack size in ANS Forth         


Author: Bruce McFarling
Date: Jan 13, 2007 13:18

Krishna Myneni wrote:
> Actually, it was my mistake to call the incorporation of a deep fp stack a new
> standard. You are right in that the existing standard allows for deep fp stacks.
> However, as the original post by Andreas shows, there is an asymmetry in how the
> data stack, return stack vs fp stack are treated in DPANS94. Please see my
> discussion with Bernd regarding the suggestion that no specific limit be imposed
> on the fp stack before declaring an environmental dependency --- that's the
> change that may be made in a new standard. The whole idea is to treat the stacks
> symmetrically.

But why change the one that is done the right way around?

For a seperate floating point stack, you have to provide a stack at
least six deep. For the data and return stack, you could provide four
each and it would still comply with the standard.
no comments
FP stack size in ANS Forth         


Author: Andreas Kochenburger
Date: Jan 11, 2007 03:16

Out of curiosity:

12.3.3 Floating-point stack
...
A program that depends on the floating-point stack being larger than
six items has an environmental dependency.

How come that this restriction came into the standard?
Many recursive algorithms require more depth.

Andreas
-------
It's never too late to have a happy childhood.
38 Comments
Re: FP stack size in ANS Forth         


Author: Andreas Kochenburger
Date: Jan 12, 2007 01:37

On Thu, 11 Jan 2007 12:31:53 -0000, Andrew Haley
wrote:
>> How come that this restriction came into the standard?
>
>The 8087. When that chip was designed, it was intended to have an
>interrupt that pushed to registers on overflow, giving unlimited
>floating-point stack depth, but the interrupt didn't work. So, users
>of the 8087 are limited to 8 items. Forth's limit is six: the extra
>two are for system overhead.

In other words: Intel's shortcomings became somehow the Forth
standard?

Andreas
-------
It's never too late to have a happy childhood.
31 Comments
Re: FP stack size in ANS Forth         


Author: Anton Ertl
Date: Jan 12, 2007 11:20

Andreas Kochenburger nospam.com> writes:
>I guess it was just that somebody quickly proposed his current
>implementation as new FP wordset and that there was nor enough time
>nor interest or feedback to clean it up more thoroughly.

My impression (from what I read about the standardisation effort) is
that FP was quite well prepared, building on a quasi-standard from the
"Forth Vendor's group" or somesuch.

But you can rejoice. I expect that, with AMD64 taking over from
IA-32, the 8087 stack will become less important than it has been
(with both language and hardware implementations favouring the XMM
registers), there will be more and more Forth systems offering big FP
stacks, and if there are enough people making use of that, maybe this
limit will be removed in Forth 201x.

OTOH, at least you are guaranteed 6 items for the FP stack. There is
no such guarantee for the data stack or the return stack, so a
(low-quality) system could already stop working if you need more than,
say, 4, stack items.
Show full article (1.33Kb)
3 Comments
Re: FP stack size in ANS Forth         


Author: Bernd Paysan
Date: Jan 12, 2007 09:43

Krishna Myneni wrote:
> Today, most Forth systems appear to allow for a deep fp stack, e.g.
> gforth, pfe,
> iforth, ... (bigForth is an exception). This is the common practice, and
> hence, is a candidate for a new Forth standard.

The current standard does not *force* you to have a small FP stack. It also
does not force you to write programs which only use a small stack, unless
e.g. you use bigFORTH. On the other hand, there's *no* guarantee how big
the data stack or return stack is (or at least I couldn't find it). So any
program has an environmental dependency on whatever data and return stack
depth it uses, while there are programs that have no environmental
dependency on FP stack depth, when they fit into the guaranteed 6 items.
> When I program, I don't want to worry about the fp stack depth. Recursion
> is not the only case where a deep fp stack is useful. For example, a file
> containing a hundred or so values in fp format can be loaded using
> INCLUDE, rather than having to parse the data out of the file. Of course a
> language standard should not be designed around a single peculiar
> application any more than being designed around the peculiar limitations
> of a single piece of hardware.
Show full article (2.71Kb)
3 Comments
Re: FP stack size in ANS Forth         


Author: Krishna Myneni
Date: Jan 12, 2007 13:27

Bernd Paysan wrote:
> Krishna Myneni wrote:
>
>>Today, most Forth systems appear to allow for a deep fp stack, e.g.
>>gforth, pfe,
>>iforth, ... (bigForth is an exception). This is the common practice, and
>>hence, is a candidate for a new Forth standard.
>
>
> The current standard does not *force* you to have a small FP stack. It also
> does not force you to write programs which only use a small stack, unless
> e.g. you use bigFORTH. On the other hand, there's *no* guarantee how big
> the data stack or return stack is (or at least I couldn't find it). So any
> program has an environmental dependency on whatever data and return stack
> depth it uses, while there are programs that have no environmental
> dependency on FP stack depth, when they fit into the guaranteed 6 items.
>

Hi Bernd,
Show full article (3.74Kb)
2 Comments
Re: FP stack size in ANS Forth         


Author: Bernd Paysan
Date: Jan 12, 2007 15:04

Krishna Myneni wrote:
> The same limitations on embedded processors which
> existed when DPANS94 was created may not be as relevant today.

Gforth EC for the R8C was a project that started a year ago. Small embedded
processors are still there today, and they are useful, because they are
dirt cheap.

I agree that a deep FP stack can be useful from time to time, and that in
general, a PC Forth should not impose arbitrary limitations unless there's
a good reason (in bigFORTH's case it's the tradeoff between performance and
ease of implementation). I'm not sure if your examples are good, e.g.
copying a row of a large matrix on the stack and then copying it back to
another matrix seems to be suboptimal compared to copying straight without
the stack in between. Recursion is more in the line of being useful.

--
Bernd Paysan
"If you want it done right, you have to do it yourself"
http://www.jwdt.com/~paysan/
1 Comment
1 2 3 4