[PicForth] ANN: 'flag' - allocator for 1-bit variables

David McNab david at rebirthing.co.nz
Fri Dec 3 00:16:05 CET 2004


Hi,

I've created an allocator for 1-bit variables.

It's called 'flag', and works exactly the same as 'variable', except that:
  - it allocates data memory 1 bit at a time, not 1 byte at a time
  - you use the bit words on it (eg, 'bit-set?', 'low', etc) instead
    of the variable words (eg '!', '+!')
  - at compile-time, it keeps a cache of one byte of data mem, allocating
    bits from that byte till it runs out, then 'alloc'ing another data
    byte and so on

Example usage:
       variable var1
       flag status1
       variable var2
       flag status2
       ...
       : someword
           1 var1 !
           status1 low
           2 var2 !
           status2 high
           ...
           status1 high? if
              ...
           then
           ...
       ;

Code and regression test on wiki:
http://wiki.enst.fr/bin/view/Picforth/Libflag

-- 
Cheers
David


More information about the PicForth mailing list