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

Re: [colorforth] ColorForth: if and -if


On an unrelated note, is there any update to the status of the new
ColorForth that Jeff Fox said was going to be released soon?

On Sun, 20 May 2007 09:12:26 -0600, "John Comeau" <jc@xxxxxxxxxxxx>
said:
> Thanks Ray! Yes, I figured those things out eventually. What do you
> mean "alive and back in the world"? Were you very ill? -- jc
> 
> On 5/20/07, Ray St. Marie <ray.stmarie@xxxxxxxxx> wrote:
> > ---------- Forwarded message ----------
> > From: Ray St. Marie <ray.stmarie@xxxxxxxxx>
> > Date: May 20, 2007 4:23 AM
> > Subject: Re: ColorForth: if and -if
> > To: Josef <josefg@xxxxxxxxx>
> >
> >
> > On 5/16/07, Josef <josefg@xxxxxxxxx> wrote:
> > > Ray,
> > >
> > > I have tried using if and -if in colorforth, but there is something I am
> > > missing.
> > >
> > > I know if checks if the zero flag is set. How do I set the zero flag?
> > >
> > > I know -if checks the sign flag. How do I set the sign flag?
> > >
> > > Thank you,
> > >
> > > Josef
> > > --
> > > Using Opera's revolutionary e-mail client: http://www.opera.com/mail/
> > >
> >
> > Hi Josef, I hope this finds you well.
> > Sorry for delay, I'm back online now. :)
> > This should help JC too, as I saw him with a similar question in the
> > FREENODE irc logs at #c4th.
> >
> >
> > IF and -IF in colorforth.
> >
> > You are correct. If and -If test flags just as you say.
> > As you may or may not know, IF and -IF in colorforth are
> > "non-consuming" meaning that they don't consume stack arguments like
> > the ANS Forth versions.  This also means that they don't contain the
> > code that would set flags, so you have to do this first, and here's
> > how...
> >
> > IF
> >
> > If we wanted to test if a value is equal to another value, say 0 in
> > this case then use this....
> >
> > ... 0 or drop if if-true-code then ....
> >
> > the OR tests the stack value with 0, consumes the 0 on the  test, sets
> > the 0 flag in the flags register and the IF tests that. The drop drops
> > the test value from the stack. You can omit the drop, or move it to
> > past the IF or past the THEN should you need to. This way you can
> > carry the stack value into the IF should you need to.
> >
> > in the case of -IF
> >
> > ... 0 + drop -IF if-true-code then ....
> >
> > In this case we are testing if the sign on the stack is neg or pos by
> > adding 0 to the stack value with the + word, which will set the sign
> > flag.
> >
> > I've defined a couple macros based on these IF "prefixes", for want of
> > a better word. Such as...
> >
> > : 0? 0 or drop ;  ( like 0= . All of those words are cyan [ with
> > exception of the last semi-colon which is green] as they are all
> > macros themselves.)
> >
> > : ?exit ( like 0; in retroforth ) 0? if ; then ;  ( you can have two
> > semi-colons in a colorforth word. They too are all cyan words [as 0?
> > is now defined] with exception of the last semi-colon which is green.
> > )
> >
> >
> > While i'm here,
> >
> > JC you may have answered this for yourself already but....
> > You wanted to know how to initialize a colorforth variable before
> > loading the block and setting the value. Try this....
> >
> > newvar 0 10 newvar ! ( where "newvar 0" is the magenta/green variable
> > being defined and "10 newvar !" is all in yellow and somewhere after
> > the define.
> >
> > Great to be alive and back in the world. Hope everyone is well!
> > BYE
> > Ray
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: colorforth-unsubscribe@xxxxxxxxxxxxxxxxxx
> > For additional commands, e-mail: colorforth-help@xxxxxxxxxxxxxxxxxx
> > Main web page - http://www.colorforth.com
> >
> >
> 
> 
> -- 
> John Comeau <jc@xxxxxxxxxxxx> http://jcomeau.unternet.net/
> "He is all he knows himself to be &#8211;
> that is the lock, as well as the key &#8211;
> the opening and the limitation." -- S. A. Moose
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: colorforth-unsubscribe@xxxxxxxxxxxxxxxxxx
> For additional commands, e-mail: colorforth-help@xxxxxxxxxxxxxxxxxx
> Main web page - http://www.colorforth.com
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: colorforth-unsubscribe@xxxxxxxxxxxxxxxxxx
For additional commands, e-mail: colorforth-help@xxxxxxxxxxxxxxxxxx
Main web page - http://www.colorforth.com