picforth conditionals

Jamie Lawson <[email protected]> Tue, 9 Mar 2004 11:37:40 -0500 (EST)
Newsgroups gmane.comp.lang.forth.picforth
Message-ID <[email protected]>
Hi,

I am just starting to use Forth and in particular picforth-0.29 and was
wondering why the following statement does not seem to work.

I'm waiting for a pin (sDATA) to go low or SW_Timer0 to reach zero.

\*****************************

  1 pin-b sDATA
  variable SW_Timer0

  begin sDATA bit-set? SW_Timer0 @ 0 <> and while repeat

\***************************

where SW_Timer is decremented by the ISR and does not decrement further
once zero is reached.

I am using the next statement instead; which does work as expected.

\**************************

    begin sDATA bit-clr? SW_Timer0 @ 0 = or until

\**************************

and the following works under gforth-5.0

\*************************

  variable SW_Timer0 ok
  variable sDATA  ok
  : t ( -- )
    begin
      sDATA @ 0 = SW_Timer0 @ 0 <> and while ST_Timer0 @ 1 - SW_Timer0 ! st @ .
    repeat ;

\************************

\ test with sDATA high and SW_Timer0 <> 0
1 sDATA !  ok
4 SW_Timer0 !  ok
t 3 2 1 0  ok \ counts down then exits

\ test with sDATA low and SW_Timer <> 0
0 sDATA !  ok
4 SW_Timer0 !  ok
t  ok  \ exits immediately


Regards,
Jamie Lawson