Collapse OS Documentation Browser


asm/ code/ hw/ algo.txt arch.txt avr.txt blk.txt blksrv.txt bootstrap.txt cross.txt design.txt dict.txt dis.txt drivers.txt ed.txt emul.txt faq.txt grid.txt grok.txt impl.txt intro.txt me.txt mspan.txt ps2.txt rxtx.txt sdcard.txt sega.txt selfhost.txt spi.txt usage.txt wordtbl.txt

Word tables

Word tables are arrays of pointer to words. B5 provide words
allowing to conveniently create and use these tables. These
words are:

WORDTBL x   n -- a  Initialize a word table named x witn n
:W ... ;    a -- a? Add a new anonymous word to the active tbl
'W x        a -- a? Find x in dict and add it to active tbl

The idea is that when you call WORDTBL, it becomes the active
table by pushing its first address to PS. Then, for each new
element you add, current address is increased and when all
elements are added, that address is dropped from PS. Example

: foo 42 . ;
: bar 43 . ;
3 WORDTBL w 'W foo 'W bar :W 44 . ;
w 0 WEXEC \ prints 42
w 1 WEXEC \ prints 43
w 2 WEXEC \ prints 44

When the count (3 in the example) is reached, table's address
is dropped from PS. For this reason, when you create a WORDTBL,
you have to create this exact number of words afterward. If you
create less, you have a PS leak, if you create more, a PS

Collapse OS and its documentation are created by Virgil Dupras and licensed under the GNU GPL v3.

This documentation browser by James Stanley. Please report bugs on github or to

This page generated at 2023-12-05 21:05:04 from documentation in CollapseOS snapshot 20230427.