home .. forth .. colorforth mail list archive ..

[colorforth] pack in colorForth


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 ;

---------------------------------------------------------------------
To unsubscribe, e-mail: colorforth-unsubscribe@xxxxxxxxxxxxxxxxxx
For additional commands, e-mail: colorforth-help@xxxxxxxxxxxxxxxxxx
Main web page - http://www.colorforth.com