[PicForth] Missing word ' ::code'

David McNab david at rebirthing.co.nz
Sat Oct 30 11:07:28 CEST 2004


Hi,

I'm writing to contribute a new word.

In review:

   ':'    defines a new forth word which expects its last argument (if
          any) on TOS

   '::'   defines a new forth word which expects its last argument (if
          any) in W  (and, at its beginning, pushes W to TOS)

   'code' defines a new assembler word which expects its last arg (if
          any), on TOS.

But there wasn't the fourth option - a word which defines a new 
assembler word which expects its last arg (if any) in W.

What's worked to fill this gap for me is:

   meta
   : ::code true t-header ]asm ;
   target

Usage:

   ::code fred
        \ assembler statements...
   end-code

   : mary
       ...
       fred
       ...
   ;

Here, mary 'knows' that fred expects its last arg in W, and will obey 
this convention when compiled.

This new word '::code' helps slightly when optimising Forth words into 
assembler, and helps more so for reducing overhead in assembler words 
calling each other.

Lastly, compliments to PicForth's optimisation! I've re-coded many words 
into assembler, and in most cases barely saved 2 or 3 machine-words each 
time. Often, I'm reverting back to Forth, since in many cases 
readability is worth more than economy.

-- 
Cheers
David


More information about the PicForth mailing list