[PicForth] Re: picforth conditionals
Samuel Tardieu
sam at rfc1149.net
Tue Mar 9 19:26:41 CET 2004
>>>>> "Jamie" == Jamie Lawson <jlawson at ces.uoguelph.ca> writes:
Jamie> I am just starting to use Forth and in particular picforth-0.29
Jamie> and was wondering why the following statement does not seem to
Jamie> work.
Jamie> I'm waiting for a pin (sDATA) to go low or SW_Timer0 to reach
Jamie> zero.
Jamie> \*****************************
Jamie> 1 pin-b sDATA variable SW_Timer0
Jamie> begin sDATA bit-set? SW_Timer0 @ 0 <> and while repeat
Jamie> \***************************
You may have hit a bug.
I haven't looked at the generated code yet, but I am sure that the
following will be more efficient: (speed and code space)
: waitforcond ( -- )
begin
sDATA bit-clr? if exit then
SW_Timer0 0= if exit then
again;
This has the advantage of not requiring a boolean normalization --
status bits can be used directly, as in your example a normalization
to 0 or $FF is needed in order to perform the "and" operation.
Sam
--
Samuel Tardieu -- sam at rfc1149.net -- http://www.rfc1149.net/sam
More information about the PicForth
mailing list