home .. forth .. colorforth mail list archive ..

[ColorForth] More newbie questions


Leslie Snively wrote:
> one of the things colorForth
> doesn't seem to have many of are conditionals.  

Right.  Chuck's chips, and Chuck's Forths only have
two conditional branches, branch if T=0 and branch
if the most significant bit of T is false.  (on P21
and F21 the most significant bit is bit 20 which
is also carry, on P16, QSp16, P8, P24, x18, and 25x
the most significant bit is sign. 

On Chuck's chips the bit tested by -IF is carried
in stack cells so just like operations that set
all bits in T to zero.  So the bits can be set
in one place, moved around on the stacks, moved
to and from the return stack, and can be tested
later in the code.

You don't have to say  XOR IF ... and test
for T=0 directly after the operation that set T.
You can do 
XOR ( f -- ) 1 2 3 BLAH FOO STUFF ETC ( f -- ) IF ...

So I would assume that in Pentium ColorForth that
-IF tests bit 31 so that it can be set by your
logic, moved around on the stacks, then used as
a flag for -IF branching when it is placed back in T.
Someone who is actually using ColorForth can
confirm or correct my assertion as to how I would
expect it to work.

In MachineForth the conditional branch primtives
get compiled by IF -IF UNTIL -UNTIL WHILE and -WHILE
and unconditional branches get compiled by ELSE 
AGAIN and REPEAT. Chuck simplified things in
ColorForth removing UNTIL -UNTIL WHILE -WHILE ELSE
AGAIN and REPEAT.  The only conditional branches
in ColorForth are IF and -IF.  Chuck wanted to
enforce more factoring of code into smaller words
which is what you have to do with only IF and -IF.

Anything that changes T can change the bits tested 
by IF and -IF.
------------------------

To Unsubscribe from this list, send mail to Mdaemon@xxxxxxxxxxxxxxxxxx with:
unsubscribe ColorForth
as the first and only line within the message body
Problems   -   List-Admin@xxxxxxxxxxxxxxxxxx
Main ColorForth site   -   http://www.colorforth.com