Editor settings for the 'joe' text editor:
  ^TR 65     wrap after 64th column
  ^TI        autoindent on
  ^TT        overtype


User interface ideas
--------------------
For filling out forms, show fields as colored boxes, no border, just a
different background color (or underline) to make them stand out.  Use arrow
keys to move between fields, or Alt-A, Alt-B, Alt-1, etc. if the fields are
labeled (useful for complex forms).

Use something like FIELD-EDIT (a # w h x y - ) where (a #) is the memory
area being shown/edited, and (w h x y) is the size/location of the box.
Create a table of fields (stored temporarily in H-space if possible.)

A "spreadsheet" view could also use FIELD-EDIT.


Dictionary entry format
-----------------------
dword	PREV	Link to previous dictionary entry
dword	CFA	Code field address (Address to call)
		(Also need PFA, Parameter Field Addr...?)
byte	FLAGS	0=Immediate 1=Compile-Only 2=Compilable 3=Inlinable
		4=Optimizer-safe  5=Token-callable
cstring	NAME
--- optional parts ---
dword	VFA	View (pointer to the source code)

: VOCAB:  ( "name" - (Define a new vocabulary)
  CREATE
    0 ,   \ Section 0. Main
    0 ,   \ Section 1. Compiler (for different compiler/interpreter behavior)
  DOES>
    ( a) SET-CURRENT ;


Suggestions from R. Hohense:
----------------------------
There are necessary and specific rawrite's for NT and OS/2 on
metalab.unc.edu.


Jeremy L. St. James' dictionary format
--------------------------------------
Only store the first 4 letters (plus length), so each entry will be the same
size (5 cells).  One cell is a pointer to the full name string (for WORDS,
and for resolving ambiguities). Might be useful later on.


Forth VM Models
---------------
Threading models to consider:
STC (Subroutine Threaded) - Simpler, more 'elegant'
	Uses the "raw" CPU: code is a series of CALLs and a RET.
DTC (Direct Threaded)     - Smaller, possibly faster
	Inner loop:	W = [IP], Advance IP, JMP [W]
ITC (Indirect Threaded)   - Simpler & slower than DTC
	Inner loop:	W = [IP], Advance IP, X = [W], JMP [X]
TTC (Token Threaded)      - Lookup through a table

80386 STC model (currently used in Retro)
	TOS = EAX
	PSP = EBP		RSP = ESP
	 IP = IP		 UP = memory (in SVARS)
	  W = ESI		  X = EDI

80386 DTC model (as in Pygmy Forth)
	TOS = EBX		  W = EAX
	PSP = ESP		RSP = EBP
	 IP = ESI (NEXT is LODSD; JMP EAX)

Putting the TOS in a register has some interesting consequences, especially
on the 80386.  SWAP and NIP are each 1 instruction, while DROP is 2; an
inlined SWAP NIP is an optimal implementation of DROP.  In general,
TOS-in-register slows down stack manipulation but speeds up most everything
else.  Since good Forth coding doesn't do much stack-shuffling, I find this
a worthy tradeoff.

UVARS - user variables area (one per task)
SVARS - system variables area (just one).  Always mapped to the same
	location for every task.  Contains UP (pointer to UVARS).


MEMORY MAP (addr/size in hex)
-----------------------------
    addr size	title	purpose
-- Zero page -- Always mapped linear=physical --
?      0 400	IVT	REAL MODE Interrupt Vector Table (used in VM86 mode)
?    400 200	DATA	BIOS DATA AREA
     600 800	IDT	Interrupt Descriptor Table
     e00 100	GDT	General Descriptor Table (6 used; room for 32)
     f00 100	SVARS	System variables (preliminary location)
-- PHYSICAL MEMORY --
    7c00 100	BOOT	Boot sector - throw away
   10000 10000	KERNEL	Boot kernel (may be thrown away if replaced first)
   20000 80000  (free)
   A0000 60000	ROM	ROMs, memory-mapped I/O, etc. (partly free)
   A0000 10000	VGABUF	VGA graphics buffer
   B0000 8000	MONBUF	Mono character buffer
   B8000 8000	COLBUF	Color character buffer
   E0000 10000	BIOS	BIOS ROM is mapped here
  100000 (max)	(free)
-- LOGICAL MEMORY --
FFF00000 100000	KSPACE	Kernel space


Filesystems:
1. nonfs (BLOCKS)   *limit source code to 64 columns*
2. dosfs - for trading with other OS's
3. vocfs (VOCABULARY-based) - a cool idea to play with


BLOCK BUFFERS
circular buffer (head & tail pointers)
allocate low (<16mb) memory when using ISA DMA
table fields:
	Block#
	addr
	VFS node of parent file/device

VFS (virtual filesystem)
for starters, keep all nodes in RAM
node table fields:
	Type - ptr to Type struct
	Location - depends on type


MEMORY ALLOCATION (paging/virtual)
use bitmaps of free/used pages - simplest approach

The "right thing" wouldn't limit you to the processor's maximum addressable
space. (probably there'd be a speed tradeoff) If I implement a distributed
persistent store I'll really need this. (A paper I saw, on tForth, called
this "handle-based allocation" and referred to "Object-Oriented Forth;
Implementation of Data Structures" by Dick Pountain, Academic Press.)


PERSISTENT OBJECT STORE w/o paging hardware
An extension of the BLOCKS concept.  A BLOCK is 2^10 bytes, while an OBJECT
here is 2^N.  Requires an object table, indexed by Object#, listing the
address and/or external location of each object.  Note that N<32, so 5 bits
are sufficient.  Therefore, include those 5 bits in the Object#.  Look up
Object#'s using a tree or hash.
...This idea needs more thought.


Parsing numbers --- prefixes:  (tentative)
	Gforth	C	6811asm
hex	$	0x	$
dec	&		!
oct		0	&
bin	%		%
char	'C	'C'	'C'		(Short for CHAR/[CHAR])

	Considerations:
	! and @ prefixes might get confused with FETCH/STORE words.
	I personally like the 6811 assembler prefixes.
	Gforth's are easy to parse, and that's what Retro uses for now.


Parsing strings (PARSE, PARSE-WORD):
	string QUOTE-CHARS defaults to: '" (single & double quotes)
	Skip whitespace
	IF first char is in QUOTE-CHARS, parse till matching char
	ELSE parse till whitespace
	Also parse \ escapes...

CRC:
	An algorithm is given in the PNG spec (in my ~/dl/formats/)



Color Forth
-----------
0 BLUE	comment
1 RED	definition (": TEST" becomes "TEST" in red)
2 GREEN	compiled words (ie, everything after a red word)
3 WHITE	interpreted words (runs immediately)

Words are executed/compiled immediately when SPACE is pressed.
(Or at least look up the word, and highlight it if not found)

Color *changes* matter when parsing: 2-3 is NEXT, *-2 is :, etc.
Table lookup routine for a 4-color system:
	OLD-COLOR @  NEW-COLOR @ 2 LSHIFT  OR
	CELLS JUMP-TABLE + @ ?DUP IF EXECUTE THEN

Show all characters <32 as space, but perform an action:
  ## COLOR  ACTION
   0 BLUE   comment (until next <32 char)
   1 RED    definition
   2 GREEN  compile
   3 YELLOW interpret (run immediately)
   4 WHITE  number (next word)
  32        normal space, used in strings/comments/etc.

If there is a color for "Number", there's no need to search the dictionary
because the next word is known to be a number.


--------
If a queue is sized and aligned to 2^N, wraparound can be implemented with a
single AND instruction, no conditionals.

Check for stack overflow/underflow in the interpreter, leaving a little
breathing room above and below the stack so nothing terrible happens.
