( toolkit day 14.05.2001 )

: array ( n sizeof "name" )
   create
      dup w, * here over allot
      swap erase
   does> ( n addr1 -- addr2) 
      tuck w@ w* + 2+  
;

: roll  
( x0 x1 .. xn n -- x1 .. xn x0 )
  dup 1+ pick >r
  cells sp@ cell+ dup cell+ 
  rot move drop r> 
;

: place ( addr len dest )
\ Place the string str len at 
\ addr, formatting it as acounted string
   2dup c! char+ swap move ;

: +place ( addr len dest )
\ append string addr,len to counted
\ string dest
        2dup c@ + over c!
        dup c@ char+ + swap move ;

: c+! ( c addr -- )
  tuck c@ + swap c!
;

: not invert ;

: bounds ( str len -- str+len str )
\ Convert str len to range for DO-loop.
  over + swap 
;

: 3dup
   2 pick
   2 pick
   2 pick
;

: 3drop
   2drop drop
;

: andif ( p ... -- flag ) 
\ Given p ANDIF q THEN,  q will 
\ not be performed if p is false.
   s" dup if drop " evaluate
; immediate

: orif ( p ... -- flag ) 
\ Given p ORIF q THEN,  q will 
\ not be performed if p is true
  s" dup 0= if drop " evaluate
; immediate

: ++ ( addr )
\ Increment the value at addr
  1+!
;

: hiword ( xxyy -- xx ) 
\ The high half of the value
   16 rshift
;

: loword  ( xxyy -- yy ) 
\ The low half of the value
   65535 and
;

: emits ( n char )
\ Emit char n times
  swap 0 ?do  dup emit  loop drop
;

: swapa ( addr1 addr2 )
\ addr1 <-> addr2
   dup @ >r
   over @ swap !
   r> swap !
;

: >byte 8 LSHIFT ;


: #define
   nextWord
   nextWord evaluate >r
   created r> w,
   does> w@
;
