                FORTH WORD SPECS

LIT
   ( ... n)
   Not used by any new words, but used by predefined system words.


EXECUTE
   (addr ... )


BRANCH
   ( ... )
   Use dependent on SPEED


0BRANCH
   (f ... )
   Use dependent on SPEED


(LOOP)
   ( ... )
   Use dependent on SPEED


(+LOOP)
   (n ... )
   Use dependent on SPEED


(DO)
   (n1\n2 ... )
   Use dependent on SPEED
   Saves old values of index and limit on rpp


I
   Imm/Comp
   ( ... n)
   Plants inline code regardless of SPEED


J
   Imm/Comp
   ( .. n)
   Plants inline code regardless of SPEED


DIGIT
   (c\n1 ... n2\tf)
   (c\n1 ... ff)


(FIND)
   (addr1\addr2 ... cfa\n\tf)
   (addr1\addr2 ... ff)
   Ignores words with smudge bit set
   Actual length of name is left on stack, not manipulated length as in a
   header


ENCLOSE
   (addr\c ... addr\n1\n2\n3)


POLL-ESCAPE
   (addr\n ... )
   Called by forth system poll routine after poll.
   addr = address of buffer used by poll
   n    = Reason code returned by Wimp_Poll in R0


<EMIT>
   (n ... )
   Nowimp EMIT
   Clears top bit of char before printing


EMIT
   ( ... )
   Vectored


<WEMIT>
   (n ... )
   Wimp EMIT
   Recognises VDU 7 and VDU 12


<KEY>
   ( ... n)
   Nowimp KEY
   Does not accept chars < &20 (except &0D), and >= &80
   If escape pressed, jump to QUIT


<WTYPE>
   (addr\n ... )
   Wimp TYPE
   Clears top bit of byte before printing each char


<WKEY>
   ( ... n)
   Wimp KEY


KEY
   ( ... )
   Vectored


?TERMINAL
   ( ... f)
   f = 1 if ESCAPE pressed
     = 0 if ESCAPE not pressed
   Only works in Nowimp mode


CR
   ( ... )
   Outputs CR then LF


CMOVE
   (addr1\addr2\n)
   Moves as bytes


U*
   (n1\n2 ... n3)
   No distinction between signed and unsigned


U/
   (n1\n2 ... n3\n4)


AND
   (n1\n2 ... n3)


OR
   (n1\n2 ... n3)


XOR
   (n1\n2 ... n3)


SP@
   ( ... addr)


SP!
   ( ... )


RP@
   ( ... addr)


RP!
   ( ... )


;S
   Imm
   ( ... )


LEAVE
   Imm/Comp
   Plants inline code regardless of SPEED


>R
   (n ... )


R>
   ( ... n)


R
   ( ... n)
   Clears flag bits before putting on stack


>R>
   (n ... n)
   Copies top of sp to rpp


N>R
   (n1\n2\... ... )
   Copies n1 items from sp to rpp
   n2 will end up on top of rpp
   Assumes n1 >= 1


R<N
   (n1\n2... ... )
   Copies n1 items from sp to rpp
   n2 is placed on rpp first, so reverse order to N>R
   Assumes n1 >= 1


0=
   (n ... f)


0<
   (n ... f)


+
   (n1\n2 ... n3)


-
   (n1\n2 ... n3)


OVER
   (n1\n2 ... n1\n2\n1)


DROP
   Imm
   (n ... )
   If executing, then drop top of stack
   If compiling, compile inline code regardless of SPEED


SWAP
   (n1\n2 ... n2\n1)


DUP
   (n1 ... n1\n1)


2DROP
   (n1\n2 ... )


NDROP
   (n1\n2... ... )
   Drops n1 items from stack


2DUP
   (n1\n2 ... n1\n2\n1\n2)


2OVER
   (n1\n2\n3\n4 ... n1\n2\n3\n4\n1\n2)


2SWAP
   (n1\n2\n3\n4 ... n3\n4\n1\n2)


+!
   (n\addr ... )


TOGGLE
   (addr\n ... )


@
   (addr ... n)
   Doesn't clear flag bits before fetching


C@
   (addr ... n)


!
   (n\addr ... )


><!
   (addr\n ... )
   Same as ! but params reversed


!++
   (n\addr1 ... addr2)
   addr2 = addr1 + 4


><!++
   (addr1\n ... addr2)
   addr2 = addr1 + 4


C!
   (n\addr ... )

><C!
   (addr\n ... )
   Same as C! but params reversed


C!++
   (n\addr1 ... addr2)
   addr2 = addr1 + 1


><C!++
   (addr1\n ... addr2)
   addr2 = addr1 + 1


:
   Imm
   ( ... )


;
   Imm
   ( ... )


R:
   Imm
   ( ... )
   Recursive :
   Same as : but smudges after to make word FINDable


R;
   Imm
   ( ... )
   Recursive ;
   Same as ; but smudges after to make word FINDable


EXIT
   Imm
   ( ... )


NOOP
   ( ... )


CONSTANT
   (n ... )


ICONSTANT
   (n\addr ... )
   Creates a constant with name of string at addr


VARIABLE
   (n ... )


IVARIABLE
   (n\addr ... )
   Creates a variable with name of string at addr


USER
   (n ... )


IUSER
   (n\addr ... )
   Creates a user variable with name of string at addr


BL
   ( ... n)


C/L
   ( ... n)


FIRST
   ( ... n)


LIMIT
   ( ... n)


B/BUF
   ( ... n)


B/SCR
   ( ... n)


S/FILE
   ( ... n)


+ORIGIN
   (n ... addr)


S0
   ( ... addr)


R0
   ( ... addr)


TIB
   ( ... addr)


WIDTH
   ( ... addr)


WARNING
   ( ... addr)


FENCE
   ( ... addr)


DP
   ( ... addr)


VOC-LINK
   ( ... addr)


BLK
   ( ... addr)


IN
   ( ... addr)


OUT
   ( ... addr)


SCR
   ( ... addr)


OFFSET
   ( ... addr)


CONTEXT
   ( ... addr)


CURRENT
   ( ... addr)


STATE
   ( ... addr)


BASE
   ( ... addr)


DPL
   ( ... addr)


FLD
   ( ... addr)


CSP
   ( ... addr)


R#
   ( ... addr)


HLD
   ( ... addr)


SPEED
   ( ... addr)


1-
   (n1 ... n2)


2-
   (n1 ... n2)


1+
   (n1 ... n2)


2+
   (n1 ... n2)


HERE
   ( ... addr)


ALLOT
   (n ... )
   Doesn't round n before allotting


,
   (n ... )


C,
   (n ... )


NEGATE
   (n1 ... n2)


=
   (n1\n2 ... f)


<
   (n1\n2 ... f)


>
   (n1\n2 ... f)


>=
   (n1\n2 ... f)


<=
   (n1\n2 ... f)


<>
   (n1\n2 ... f)


ROT
   (n1\n2\n3 ... n2\n3\n1)


PICK
   (n1 ... n2)
   n1 must be >= 1


ROLL
   (n ... )
   n must be >= 2


INSERT
   (n1\n2 ... )
   n1 = item to be inserted
   n2 = position to insert, must be >= 2


SHUFFLE
   (n1...\n2 ... )
   n1 = current position of item which will end up as top of stack
   n2 = number to shuffle
   e.g. 23 65 78 12    4 3 2 1   4 SHUFFLE
   results in
        12 78 65 23


QSHUFFLE
   (n1\n2 ... )
   n1 = shuffle position specifier (each pos is in 4 bit field)
   n2 = number to shuffle
   e.g. HEX 23 65 78 12   4321   4 QSHUFFLE
   results in
        12 78 65 23


SPACE
   ( ... )


-DUP
   (n ... n\n)
   (n ... n)


TRAVERSE
   (addr1\n ... addr2)
   addr2 = address of last byte of name
       or
         = address of nfa


LATEST
   ( ... n)


LFA
   (n1 ... n2)


CFA
   (n1 ... n2)
   No code field, so n1 = n2


NFA
   (n1 ... n2)


PFA
   (n1 ... n2)


!CSP
   ( ... )


?ERROR
   (f\n ... )


?COMP
   ( ... )


?EXEC
   ( ... )


?PAIRS
   ( ... )


?CSP
   ( ... )


?LOADING
   ( ... )


<?WKEY>
   (n ... f)
   Wimp ?KEY
   n = internal key number of key to be checked
   f = 1 if that key is pressed
     = 0 if that key is not pressed


<?KEY>
   (n .. f)
   Nowimp ?KEY
   See <?WKEY>


?KEY
   ( ... )
   Vectored


<?WKEYBOARD>
   ( ... n)
   Wimp ?KEYBOARD
   n = internal key number of key pressed (always > 0)
     = 0 if no key pressed


<?KEYBOARD>
   ( ... n)
   Nowimp ?KEYBOARD
   See <?WKEYBOARD>


?KEYBOARD
   ( ... )
   Vectored


COMPILE
   ( ... )


[
   Imm
   ( ... )


]
   ( ... )


SMUDGE
   ( ... )


HEX
   ( ... )


DECIMAL
   ( ... )


(;CODE)
   ( ... )


;CODE
   Imm
   ( ... )


<BUILDS
   ( ... )


<IBUILDS
   (addr ... )
   addr = address of string to be entered into dictionary


DOES>
   ( ... )


COUNT
   (addr1 ... addr2\n)
   n = a 32 bit length, not a byte


<TYPE>
   (addr\n ... )
   Nowimp TYPE


TYPE
   ( ... )
   Vectored


-TRAILING
   (addr\n1 ... addr\n2)
   Strips space chars only


(.")
   ( ... )


."
   Imm
   ( ... )


EXPECT
   (addr\n ... )
   Stores 2 zero bytes after string


QUERY
   ( ... )


\0
   ( ... )


FILL
   (addr\n\b ... )


ERASE
   (addr\n ... )


BLANKS
   (addr\n ... )


HOLD
   (b ... )


PAD
   ( ... )


WORD
   (b ... )


<NUMBER>
   (addr ... n)


NUMBER
   ( ... )
   Vectored


-FIND
   ( ... cfa\n\tf)
   ( ... ff)


-IFIND
   (addr ... cfa\n\tf)
   (addr ... ff)
   addr = address of string containing word to be searched for.
   String is first moved to HERE, and followed by two zero bytes.


ERROR
   (n ... )


ESCAPE
   ( ... )


ID.
   (addr ... )
   Doesn't print word if SMUDGE bit set
   Doesn't print space after word


<CREATE>
   ( ... )
   Stores a BL to next instruction


CREATE
   ( ... )
   Vectored


<ICREATE>
   (addr ... )
   addr = address of string to be created as word


ICREATE
   ( ... )
   Vectored


[COMPILE]
   Imm
   ( ... )


LITERAL
   Imm
   (n ... )


DLITERAL
   Imm
   (n ... )
   Same as LITERAL


?STACK
   ( ... )


?PARAMS
   (n ... f)
   f = 1 if req no of items are on stack
   f = 0 if req no of items are not on stack


INTERPRET
   ( ... )


IMMEDIATE
   ( ... )


VOCABULARY
   ( ... )


FORTH
   Imm
   ( ... )


DEFINITIONS
   ( ... )


(
   ( ... )


QUIT
   ( ... )
   Closes text files first


<ABORT>
   ( ... )
   Closes text files first


ABORT
   ( ... )
   Vectored


WARM
   ( ... )


COLD
   ( ... )


<<
   (n1\n2 ... n3)


>>
   (n1\n2 ... n3)


>>>
   (n1\n2 ... n3)
   Arithmetic shift


>><<
   (n1 ... n2)
   Swaps halves of a register


><
   (n1 ... n2)
   Swaps halves of a 16 bit value on stack


+-
   (n1\n2 ... n3)


D+-
   (n1\n2 ... n3)
   Same as +-


ABS
   (n1 ... n2)


DABS
   (n1 ... n2)
   Same as ABS


MIN
   (n1\n2 ... n3)


MAX
   (n1\n2 ... n3)


M*
   (n1\n2 ... n3)


M/
   (n1\n2 ... n3\n4)


*
   (n1\n2 ... n3)


2*
   (n1 ... n2)


4*
   (n1 ... n2)


/MOD
   (n1\n2 ... n3\n4)
   Same as M/


/
   (n1\n2 ... n3)


2/
   (n1 ... n2)


4/
   (n1 ... n2)


MOD
   (n1\n2 ... n3)


*/MOD
   (n1\n2\n3 ... n4\n5)


*/
   (n1\n2\n3 ... n4)


M/MOD
   (n1\n2 ... n3\n4)
   Same as U/


USE
   ( ... addr)


PREV
   ( ... addr)


+BUF
   (addr1 ... addr2\f)


<UPDATE>
   ( ... )


UPDATE
   ( ... )
   Vectored


EMPTY-BUFFERS
   ( ... )


BUFFER
   (n ... addr)


BLOCK
   (n ... addr)


(LINE)
   (n1\n2 ... addr\n3)


.LINE
   (n1\n2 ... )


<MESSAGE>
   (n ... )


MESSAGE
   ( ... )
   Vectored


LOAD
   ( n ... )


-->
   ( ... )


<R/W>
   (addr\n1\f ... )


R/W
   ( ... )
   Vectored


FLOAD
   (addr ... )
   Interprets the text file whose name is in the string at address addr


(FLOAD")
   ( ... )
   Inline string FLOAD


FLOAD"
   ( ... )
   Interprets file whose name appears immediately after in stream


'
   Imm
   ( ... )


FORGET
   ( ... )


BACK
   (addr ... )


BEGIN
   Imm/Comp
   ( ... )


ENDIF
   Imm/Comp
   (... )
   Dependent on SPEED


THEN
   Imm/Comp
   ( ... )
   Same as ENDIF


DO
   Imm/Comp
   ( ... )
   Dependent on SPEED


LOOP
   Imm/Comp
   ( ... )
   Dependent on SPEED


+LOOP
   Imm/Comp
   (n ... )
   Dependent on SPEED


UNTIL
   Imm/Comp
   (f ... )
   Dependent on SPEED


END
   Imm/Comp
   (f ... )
   Same as UNTIL


AGAIN
   Imm/Comp
   ( ... )
   Dependent on SPEED


REPEAT
   Imm/Comp
   ( ... )
   Dependent on SPEED


IF
   Imm/Comp
   (f ... )
   Dependent on SPEED


ELSE
   Imm/Comp
   ( ... )
   Dependent on SPEED


WHILE
   Imm/Comp
   ( ... )
   Dependent on SPEED


SPACES
   (n ... )


<#
   ( ... )


#>
   (n1 ... addr\n2)


SIGN
   (n1\n2 ... n2)


#
   (n1 ... n2)


#S
   (n1 ... n2)


.R
   (n1\n2 ... )


.
   (n ... )


DEC.
   (n ... )


H.
   (n ... )


DEPTH
   ( ... n)


?
   (addr ... )


LIST
   (n ... )


INDEX
   (n1\n2 ... )


TRIAD
   (n ... )


VLIST
   ( ... )
   Space pauses listing
   While paused, pressing TAB abandons listing.
   Any other key continues listing


CREATE-SCREEN
   (n ... )
   n = number of screen to be created.
   If file containing this screen does not exist it will be created,
   else read/write error


.S
   ( ... )


(OSCLI)
   ( ... )
   Inline string version of OSCLI


<WOSCLI>
   (addr\n ... )
   Wimp OSCLI
   addr = address of string
   n = length of string


<OSCLI>
   (addr\n ... )
   Nowimp OSCLI
   addr = address of string
   n = length of string


OSCLI
   ( ... )
   Vectored


OSCLI"
   Imm
   String follows immediately in input stream


EXVEC:
   Imm
   ( ... )


ASSIGN
   ( ... )


TO-DO
    (addr ... )


CASE:
   Imm
   ( ... )
   e.g.
   CASE: ROB
         ACTION0 ACTION1 ACTION2 ACTION3
   CASE;


CASE;
   Imm
   ( ... )


PCASE:
   Imm
   ( ... )
   e.g.
   PCASE: ROB
          5 ACTION1 62 ACTION2 19 ACTION3
   PCASE;


PLOT
   (n1\n2\n3 ... )


.ERROR
   (addr ... )
   Prints "Error x s"
   where x = [addr]
   s = text found at addr + 4


NOWIMPS
   ( ... )
   Enters Mode 0


WIMPS
   ( ... )
   Enters Wimp environment


.RS
   ( ... )
   Prints return stack


HIDE
   ( ... )
   Makes word appearing in input stream unFINDable by SMUDGing


CREATE-PROG
   ( ... )
   (n ... )
   (n1\n2 ... )
   (n1\n2\n3 ... )
   (n1\n2\n3\n4 ... )

   Creates a standalone program
   Top of stack is program type i.e.
   1 - normal Forth entry, icon appears on icon bar
   2 - No main window shown
       ABORT not called
       run_addr called
       stack: load_addr\run_addr
   3 - Main window shown
       ABORT not called
       run_addr called
       stack: load_addr\run_addr
   4 - normal Forth entry
       No Wimp environment
       stack: load_addr
   5 - No Wimp environment
       ABORT not called
       run_addr called
       stack: load_addr\run_addr
   6 - No Wimp environment
       normal Forth entry
       Mode init_mode
       stack: load_addr\init_mode
   7 - No Wimp environment
       ABORT not called
       run_addr called
       Mode init_mode
       stack: load_addr\init_mode\run_addr


NODEBUG
   ( ... )


DEBUG
   (n1\n2 ... )
   n2 - bit 0 = 0 hex stack print
              = 1 decimal stack print
        bit 1 = 0 no return stack print
              = 1 return stack print (hex)
        bit 2 = 1 pause after stack print for left alt key press
   n1 = delay between word prints ( 0 fastest )


TASK:
   Imm
   ( ... )
   Defines a task word
   This word contains calls to other words as normal,
   but may contain calls to PAUSE to invoke other task words


TASK;
   Imm
   ( ... )
   Paired with TASK:


TEX:
   Imm
   ( ... )
   Used to define a normal forth word which contains invocation of task words
   This word must consist of triplets, the first item being the size of
   the computation stack, the second the size of the return stack
   (both in long words), followed by the task word
   When the word defined by TEX: is executed, it starts the first task word
   defined in its body running, thereafter the execution sequence is
   determined by the bodies of the task words.


TEX;
   Imm
   ( ... )
   Paired with TEX:
   Task example

   TASK: T1 ." T1 FIRST " PAUSE ." T1 SECOND " TASK;
   TASK: T2 ." T2 FIRST " PAUSE ." T2 SECOND " TASK;
   TEX: AT 100 100 T1 100 100 T2 TEX;

   TASK: OT1 ." OT1 FIRST " AT PAUSE ." OT1 SECOND " TASK;
   TASK: OT2 ." OT2 FIRST " PAUSE ." OT2 SECOND " TASK;

   TEX: AT2 100 100 OT1 100 100 OT2 TEX;

   : TT AT2 CR ." FINISHED " CR ;


PAUSE
   ( ... )
   suspend current task and continue with next task in sequence
   if there are any.

STRING
   (n ... )
   n = max size of string in bytes
   Followed by name of string


STRING[]
   (n1\n2 ... )
   Defines two dimensional string
   n1 = number of strings
   n2 = max length of each string
   Followed by name of string


ARRAY
   (n ... )
   n = number of elements
   Followed by name of string


ARRAY[]
   (n1\n2 ... )
   Defines two dimensional array
   n1 = first dimension
   n2 = second dimension
   Followed by name of string


.STR
   (addr ... )
   addr = address of string
   Prints string at address addr


STRLEN
   (addr ... )
   addr = address of string
   Returns length of string at addr


STRCPY
   (addr1\addr2 ... )
   addr1 = address of dest string
   addr2 = address of source string
   Copies source to dest
   Does not check if string will fit


(STRCPY")
   (addr ... )
   addr = address of dest string
   Copies inline string to dest


STRCPY"
   Imm
   (addr ... )
   addr = address of dest string
   Followed by string to copy to dest


STRCAT
   (addr1\addr2 ... )
   addr1 = address of dest string
   addr2 = address of source string
   Concatenates source to dest
   Does not check if string will fit


(STRCAT")
   (addr ... )
   addr = address of dest string
   Concatenates inline string to dest


STRCAT"
   Imm
   (addr ... )
   addr = address of dest string
   Followed by string to concatenate to dest


STRCMP
   (addr1\addr2 ... f)
   addr1 = address of dest string
   addr2 = address of source string
   Compares source to dest
   f = 0 if string same
   f = 1 if strings different

(STRCAT")
   (addr ... f)
   addr = address of dest string
   Compares inline string to dest
   f = 0 if string same
   f = 1 if strings different


STRCAT"
   Imm
   (addr ... f)
   addr = address of dest string
   Followed by string to compare to dest
   f = 0 if string same
   f = 1 if strings different



