pack in colorForth

Mark Slicker <[email protected]>
Newsgroups gmane.comp.lang.forth.colorforth
Message-ID <[email protected]>
The following is mostly the same as 'pack' in the assembler source. 
Instead of left justifing the word after it is full of characters, I 
always keep the word justified, this makes the data flow much simpler in 
Forth.

variable bits
variable words
: 2xs for 2x next ;
: shift dup [ bits ] ! 4 + 2xs ;
: full swap 28 + shift 1 [ words ] +! ;
: chop 1 ? if drop drop full ; then 2/ 1 u+ if chop ; then swap shift nip 
nip or ;
: room negate swap over [ bits ] @ + ;
: put room -if over chop ; then shift nip or ;
: pack -16 ? if 80 + 7 put ; then 8 ? if 8 + 5 put ; then 4 put ;
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.