need optimal forth coding ideas

David McNab <[email protected]> Tue, 30 Nov 2004 03:06:58 +1300
Newsgroups gmane.comp.lang.forth.picforth
Message-ID <[email protected]>
Hi all,

I'm seeking suggestions for efficient PicForth coding.

Here's a piece of code from my parallel LCD driver:

   ::code lcd.send-nyb ( W:nyb -- )

       w>                      \ save on stack

       \ set D4-D7 low, and change to high if needed
       lcd.pin-D4  bcf
       lcd.pin-D5  bcf
       lcd.pin-D6  bcf
       lcd.pin-D7  bcf

       \ set bits needing to be set
       indf 4      btfsc
       lcd.pin-D4  bsf
       indf 5      btfsc
       lcd.pin-D5  bsf
       indf 6      btfsc
       lcd.pin-D6  bsf
       indf 7      btfsc
       lcd.pin-D7  bsf

       pop

       lcd.pulse-E goto

   end-code

Code is working fine. The issue is that I'm in a process of trying to 
translate as much assembler code as possible to PicForth.

With the above, we have LCD pins that are non-contiguous - they don't 
even necessarily belong to the same port.

My question is - how can I translate something like:

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

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

-- 
Cheers
David