Special Feature: ColorForth Commentary

COLOR.ASM: Wordlists

Original file

NOTICE: This is a work in progress. Parts of my commentary are still very rough. However, I have it up on the web because even in this rough form it may be useful to ColorForth enthusiasts. Expect the contents of these files to change frequently.

ColorForth comes with two wordlists: FORTH and MACRO. A word in the FORTH wordlist is compiled as a CALL to the address of the word's definition in the dictionary. A word in the FORTH wordlist is executed at compile-time (the word can be green; it does not have to be yellow); it is equivalent to an "immediate" word in older versions of Forth.

Each wordlist has three parts:

PartFORTH wordlistMACRO wordlist
Word countforthsmacros
Word arrayforth0macro0
Address arrayforth2macro2

The word count indicates how many words are defined in the wordlist. The word array contains words in pre-parsed format (with color bits set to zero), and the address array contains addresses of word definitions. If you can find a given word in the word array, the offset to that word will, when applied to the address array, yield the address of that word's definition.

In addition to the words provided by the kernel, the wordlists have room for new words. The programmer can add up to 512 new words to the FORTH wordlist and up to 128 new words to the MACRO wordlist.

[In the future I will discuss the format of the pre-parsed words in the word array, with reference to the bit encoding used for the characters. Also, a table of the charset wouldn't hurt either -- char, binary value (bitmask), octal value.]

Example 1: dd 170o shl 25 -- ";" -- A semicolon is 1111 000 (170o) -- seven bits wide, so we slide it up by (32-7) or 25 bits

Example 2: dd (24o shl 5+21o) shl 22 -- "lm" -- "l" is 10100 (24o), 5 bits wide -- "m" is 10001, also 5 bits wide -- slide everything up by (32-5-5) or 22 bits

Example 3: dd ((26o shl 4+3) shl 7+141o) shl 16) -- "fov" -- "f" is 10110, "o" is 0011, "v" is 1100 001 -- slide everything up by (32-5-4-7) or 16 bits

macros
;[Refs: start1, mark, empty, mfind, macrod, variable]
	dd 0

forths
;[Refs: start1, mark, empty, find, forthd, variable]
	dd 0

macro0
;[Refs: start1, mfind, macrod, variable]
	dd 170o shl 25 ; ;
	dd ((140o shl 7+146o)shl 7+142o)shl 11 ; dup
	dd (((177o shl 7+140o)shl 7+146o)shl 7+142o)shl 4 ; ?dup
	dd (((140o shl 4+1)shl 4+3)shl 7+142o)shl 10 ; drop
	dd (((2 shl 7+144o)shl 4+4)shl 4+6)shl 13 ; then
	dd ((((143o shl 4+4)shl 5+25o)shl 4+7)shl 4+6)shl 8 ; begin

macro1
;[Refs: start1]
	dd 128 dup (0)

forth0
;[Refs: start1, find, forthd, var1, variable]
	dd (((143o shl 4+3)shl 4+3)shl 4+2)shl 13 ; boot
	dd (((27o shl 4+5)shl 4+1)shl 5+21o)shl 14 ; warm
	dd ((((142o shl 4+5)shl 7+146o)shl 5+20o)shl 4+4)shl 5 ; pause
	dd ((((21o shl 4+5)shl 5+22o)shl 4+1)shl 4+3)shl 10 ; macro
	dd ((((26o shl 4+3)shl 4+1)shl 4+2)shl 7+144o)shl 8 ; forth
	dd 22o shl 27 ; c
	dd (((20o shl 4+2)shl 4+3)shl 7+142o)shl 12 ; stop
	dd (((1 shl 4+4)shl 4+5)shl 7+140o)shl 13 ; read
	dd ((((27o shl 4+1)shl 4+7)shl 4+2)shl 4+4)shl 11 ; write
	dd (6 shl 5+22o)shl 23 ; nc
	dd (((((22o shl 4+3)shl 5+21o)shl 5+21o)shl 4+5)shl 4+6)shl 5; comman d
	dd (((20o shl 4+4)shl 4+4)shl 7+164o)shl 12 ; seek
	dd ((((1 shl 4+4)shl 4+5)shl 7+140o)shl 5+23o)shl 8 ; ready
	dd ((5 shl 5+22o)shl 4+2)shl 19 ; act
	dd (((20o shl 7+144o)shl 4+3) shl 5+27o)shl 11 ; show
	dd (((24o shl 4+3)shl 4+5)shl 7+140o)shl 12 ; load
	dd (((144o shl 4+4)shl 4+1)shl 4+4)shl 13 ; here
	dd (((177o shl 5+24o)shl 4+7)shl 4+2)shl 12 ; ?lit
	dd (153o shl 7+176o) shl 18 ; 3,
	dd (152o shl 7+176o) shl 18 ; 2,
	dd (151o shl 7+176o) shl 18 ; 1,
	dd 176o shl 25 ; ,
	dd (((24o shl 4+4)shl 5+20o)shl 5+20o)shl 13 ; less
	dd (((162o shl 7+146o)shl 5+21o)shl 7+142o)shl 6 ; jump
	dd (((((5 shl 5+22o)shl 5+22o)shl 4+4)shl 7+142o)shl 4+2)shl 3 ; accept
	dd ((142o shl 4+5)shl 7+140o)shl 14 ; pad
	dd ((((4 shl 4+1)shl 4+5)shl 5+20o)shl 4+4)shl 11 ; erase
	dd (((22o shl 4+3)shl 7+142o)shl 5+23o)shl 11 ; copy
	dd (((21o shl 4+5)shl 4+1)shl 7+164o)shl 12 ; mark
	dd (((4 shl 5+21o)shl 7+142o)shl 4+2)shl 12 ; empt
	dd (((4 shl 5+21o)shl 4+7)shl 4+2)shl 15 ; emit
	dd ((((140o shl 4+7)shl 5+25o)shl 4+7)shl 4+2)shl 8 ; digit
	dd ((((152o shl 4+4)shl 5+21o)shl 4+7)shl 4+2)shl 8 ; 2emit
	dd 165o shl 25 ; .
	dd (144o shl 7+165o)shl 18 ; h.
	dd ((144o shl 7+165o)shl 4+6)shl 14 ; h.n
	dd (22o shl 4+1)shl 23 ; cr
	dd ((((20o shl 7+142o)shl 4+5)shl 5+22o)shl 4+4)shl 7 ; space
	dd (((140o shl 4+3)shl 5+27o)shl 4+6)shl 12 ; down
	dd (((4 shl 7+140o)shl 4+7)shl 4+2)shl 13 ; edit
	dd 4 shl 28 ; e
	dd (24o shl 5+21o)shl 22 ; lm
	dd (1 shl 5+21o)shl 23 ; rm
	dd ((((25o shl 4+1)shl 4+5)shl 7+142o)shl 7+144o)shl 5 ; graph ic
	dd (((2 shl 4+4)shl 7+145o)shl 4+2)shl 13 ; text
	dd ((((164o shl 4+4)shl 5+23o)shl 7+143o)shl 4+3)shl 5 ; keybo ard
	dd (((140o shl 4+4)shl 7+143o)shl 7+146o)shl 7 ; debu g
	dd (5 shl 4+2)shl 24 ; at
	dd ((173o shl 4+5)shl 4+2)shl 17 ; +at
	dd (145o shl 5+23o)shl 20 ; xy
	dd ((26o shl 4+3)shl 7+141o)shl 16 ; fov
	dd (((26o shl 4+7)shl 5+26o)shl 4+3)shl 14 ; fifo
	dd ((143o shl 4+3)shl 7+145o)shl 14 ; box
	dd (((24o shl 4+7)shl 4+6)shl 4+4)shl 15 ; line
	dd ((((22o shl 4+3)shl 5+24o)shl 4+3)shl 4+1)shl 10 ; color
	dd (((((3 shl 5+22o)shl 4+2)shl 4+5)shl 4+6)shl 4+2)shl 7 ; octant
	dd (20o shl 7+142o)shl 20 ; sp
	dd (((24o shl 4+5)shl 5+20o)shl 4+2)shl 14 ; last
	dd (((((146o shl 4+6)shl 7+142o)shl 4+5)shl 5+22o))shl 5 ; unpac k

forth1
;[Refs: start1]
	dd 512 dup (0)

macro2
;[Refs: qcompile, compile]
	dd offset semi
	dd offset cdup
	dd offset qdup
	dd offset cdrop
	dd offset then
	dd offset begin
	dd 128 dup (0)

forth2
;[Refs: ex1, ex2, forthd, variable, qcompile]
	dd offset boot
	dd offset warm
	dd offset pause
	dd offset macro_
	dd offset forth
	dd offset c_
	dd offset stop
	dd offset readf
	dd offset writef
	dd offset nc_
	dd offset cmdf
	dd offset seekf
	dd offset readyf
	dd offset act
	dd offset show
	dd offset load
	dd offset here
	dd offset qlit
	dd offset comma3
	dd offset comma2
	dd offset comma1
	dd offset comma
	dd offset less
	dd offset jump
	dd offset accept
	dd offset pad
	dd offset erase
	dd offset copy
	dd offset mark
	dd offset empty
	dd offset emit
	dd offset edig
	dd offset emit2
	dd offset dot10
	dd offset hdot
	dd offset hdotn
	dd offset cr
	dd offset space
	dd offset down
	dd offset edit
	dd offset e
	dd offset lms
	dd offset rms
	dd offset graphic
	dd offset text1
	dd offset keyboard
	dd offset debug
	dd offset at
	dd offset pat
	dd offset xy_
	dd offset fov_
	dd offset fifof
	dd offset box
	dd offset line
	dd offset color
	dd offset octant
	dd offset sps
	dd offset last_
	dd offset unpack
	dd 512 dup (0)

Check the index for other entries.