Re: need optimal forth coding ideas

Samuel Tardieu <[email protected]> 29 Nov 2004 15:34:40 +0100
Newsgroups gmane.comp.lang.forth.picforth
Organization Avian Carrier & Friends
Message-ID <[email protected]>
>>>>> "David" == David McNab <[email protected]> writes:

David> My question is - how can I translate something like:

David>        lcd.pin-D4 bcf ...  indf 4 btfsc lcd.pin-D4 bsf

David> in pure PicForth such that it still only takes three
David> machine-words?

Write it the most natural way you can think of :)

  4 portd bit pin-d4
  : x pin-d4 low dup $10 and if pin-d4 high then ;

This expands into:

          ; name: x
          ; max return-stack depth: 0
  0x0004  1208    bcf     0x08,4
  0x0005  1A00    btfsc   0x00,4
  0x0006  1608    bsf     0x08,4
  0x0007  0008    return  

Is it what you are looking for?

  Sam
-- 
Samuel Tardieu -- [email protected] -- http://www.rfc1149.net/sam