Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.forth > #10299

Re: Signed and unsigned looping.

From BruceMcF <agila61@netscape.net>
Newsgroups comp.lang.forth
Subject Re: Signed and unsigned looping.
Date 2012-03-22 08:14 -0700
Organization http://groups.google.com
Message-ID <c32a9f0f-2693-4e42-bc2b-af3f4bb9bcb9@pg6g2000pbb.googlegroups.com> (permalink)
References <m1abnz.65f@spenarnc.xs4all.nl>

Show all headers | View raw


On Mar 22, 7:52 am, Albert van der Horst <alb...@spenarnc.xs4all.nl>
wrote:
> I have been thinking about how to simplify the looping in Forth.
> One of the main reasons for complexity is the fact that looping
> is at the same time for numbers (signed) and addresses (unsigned).
> But do we really a guarantee that passing from
> $7FFF,FFFF,FFFF,FFFx to $8000,0000,0000,000x succeeds?
> Unstead of the requirement that unsigned numbers could be
> handled, we could require that a range containing
> $8000 or $7FFF must be handled. This would be no restriction at
> all unless we are on a 16-bit system.

> The next biggest problem is that +LOOP may be going up or going down,
> and you don't know. Of course nobody in his right mind would ever use
> +LOOP on something other than a constant, but that doesn't help
> implementers. Occasionally going down a range by cells is useful.

But +LOOP / -LOOP are not difficult to implement with the Laxen &
Perry biased index / fixed overflow boundary approach, its just that
the straightforward implementation is not obvious from the
specification. Someone who elected to begin from an obsolete
implementation like fig-Forth full of what turned out from experience
to be design mistakes could well be confused, but someone who read
through the Moving Forth series wouldn't encounter any difficulty.

And there is no reason to restrict Forth to 32 bit and larger systems.
If a 16-bit soft stack processor core fits in a smaller FPGA
footprint, and gets the job done, a 32-bit stack processor core would
be overkill.

The only real substantial increase in implementation simplicity comes
when you go to FOR ... NEXT, the increment always counts down by one
from the starting point to 0, and the count down increment is always
available as R@. No LEAVE, if you want early termination you:
   ... RDROP EXIT

That wouldn't need standardizing because it requires knowledge of
implementation details, it would only need standardizing to reserve
the words, which means it can be standardized at the library level as
among the set of reserved words to only be available under the
reserved meaning if the library compilation constant is visible and
TRUE.

Back to comp.lang.forth | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

Signed and unsigned looping. Albert van der Horst <albert@spenarnc.xs4all.nl> - 2012-03-22 11:52 +0000
  Re: Signed and unsigned looping. BruceMcF <agila61@netscape.net> - 2012-03-22 08:14 -0700
  Re: Signed and unsigned looping. anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2012-03-22 17:33 +0000
  Re: Signed and unsigned looping. Krishna Myneni <krishna.myneni@ccreweb.org> - 2012-03-26 06:31 -0700

csiph-web