Add .frt samples for Forth.

This commit is contained in:
Lars Brinkhoff
2014-09-30 07:01:35 +02:00
parent 86b4de89bd
commit 7a2be16d77
3 changed files with 23 additions and 0 deletions

8
samples/Forth/bitmap.frt Normal file
View File

@@ -0,0 +1,8 @@
\ Bit arrays.
: bits ( u1 -- u2 ) 7 + 3 rshift ;
: bitmap ( u "name" -- ) create bits here over erase allot
does> ( u -- a x ) over 3 rshift + 1 rot 7 and lshift ;
: bit@ ( a x -- f ) swap c@ and ;
: 1bit ( a x -- ) over c@ or swap c! ;
: 0bit ( a x -- ) invert over c@ and swap c! ;
: bit! ( f a x -- ) rot if 1bit else 0bit then ;