UNIX FORTH for the PDP11 (part 2 of 7)

lwt1 at aplvax.UUCP lwt1 at aplvax.UUCP
Sat Jun 9 05:55:41 AEST 1984


Here is part 2 of the source for FORTH for the PDP-11.
Delete everything thru the "-- cut here --" line, and extract with 'sh':

	sh part1 part2 ... part7

where 'part?' are whatever you've named the files.  Note the copyright
notice at the end of README.  Please let us know how things go.  While
we can't support this software, we'll be posting bug fixes/upgrades to
net.sources as time permits.

VAX-FORTH should be 'forth'-coming {yuk-yuk} within a couple of weeks.

Have fun!



						-Lloyd W. Taylor
						 ... seismo!umcp-cs!aplvax!lwt1
---I will have had been there before, soon---

---------------------------------- cut here ----------------------------------
echo x - glossary
cat >glossary <<'+E+O+F'
!			n addr			-

n is stored at addr.
\
!SP			n			-

Parameter stack pointer is set to n.
\
"			-			addr[string]

Generates a null-terminated string.  Used in the form:
	" string"
Copies the input stream to PAD until a second " is found, places a null at
the end of the string, and returns the address of the string.
\
""			-			addr[string]

Compiling word. Generates a null-terminated string at run time. Used as:
	"" string"
Adds a counted string copied from the input stream to the dictionary. At
run-time, converts the string to a null-terminated string and returns address
of string.
\
#			d1l d1h			d2l d2h

The remainder of d1 divided by the value of BASE is converted to an
ASCII character and appended to the pictured output string growing toward
lower memory addresses.  d2 is the quotient and is maintained for further
processing.  Typically used between <# and #>.
\
#>			dl dh			addr +n

Pictured numeric output conversion is ended dropping d.  addr is the
address of the resulting output string and +n is the length of the string.
\
#S			dl dh			0 0

d is converted appending each resultant character onto the pictured
numeric output string until the quotient is zero.  A single zero is added
to the output string if d is zero.  Typically used between <# and #>.
\
'			-			cfa

Used in the form:
	' <name>
cfa is the compilation address of <name>.  A zero is returned if <name> 
could not be found in the dictionary.
\
(FIND)			addr[name] addr[dict]	0 <or> nfa

Searches the vocabulary whose latest dictionary entry nfa is pointed to
by addr[dict] for the counted string pointed to by addr[name].  Returns
the nfa of the word if found, otherwise a zero is returned.  If addr[dict]
is zero, indicating an empty vocabulary, a zero is returned.
\
(LITERAL)		-			word

Pushes the word pointed to by the IAR onto the parameter stack and adds two
to the IAR.
\
*			w1 w2			w3

w3 is the least-significant 16 bits of the arithmetic product of w1 times
w2.
\
*/			n1 n2 n3		quot

n1 is first multiplied by n2 producing an intermediate 32-bit result. quot
is the floor of the quotient of the intermediate 32-bit result divided by
the divisor n3.  The product of n1 times n2 is maintained as an intermediate 
32-bit result for greater precision than the otherwise equivalent sequence:
n1 n2 * n3 / .  An error condition results if the divisor is zero or if the
quotient falls outside the range {-32768..32767}.
\
*/MOD			n2 n3 n3		rem quot

n1 is first multiplied by n2 producing an intermediate 32-bit result.  quot
is the floor of the quotient of the intermediate 32-bit result divided by the
divisor n3.  A 32-bit intermediate product is used as for */ .  rem has the 
same sign as n3 or is zero.  An error condition results if the divisor is 
zero or if the quotient falls outside of the range {-32768..32767}.
\
+			w1 w2			w3

w3 is the arithmetic sum of w1 and w2.
\
+!			w1 addr			-

w1 is added to the contents of addr.
\
+-			n1 n2			n3

Apply the sign of n2 to n1 to obtain n3.  n3 := sign(n2) * n1.
\
+LOOP			n			-

n is added to the loop index.  If the new index was incremented across
the boundary between limit-1 and limit then the loop is terminated and
loop control parameters are discarded.  When the loop is not terminated,
execution continues just after the corresponding DO.
\
,			n			-

ALLOT one word of space at the end of the dictionary and store n in this
space.
\
,WORD			char			-

Compile text from the input stream delimited by char into the dictionary as
a counted string.  The minimum even number of bytes that will hold the text
is ALLOTted.
\
-			w1 w2			w3

w3 is the result of subrtracting w2 from w1.
\
-1			-			-1

CONSTANT that returns -1.
\
-IMM			nfa			cfa n 

Given a name field address, returns the corresponding code field address
and a flag n which is -1 if the word is non-immediate and 1 if the word
is immediate.
\
-ROT			w1 w2 w3		w3 w1 w2

The top three stack entries are rotated, moving the top entry to the
bottom.  -ROT is the converse of ROT.
\
-TRAILING		addr +n1		addr +n2

The character count +n1 of a text string beginning at addr is adjusted to
exclude trailing spaces.  If +n1 is zero, then +n2 is zero.  If the entire
string consists of spaces, then +n2 is zero.
\
.			n			-

The absolute value of n is displayed in a free field format with leading 
minus sign if n is negative.
\
."			-			-

Compiling word used in the form:
	." cccc"
Later execution will display the character cccc up to but not including the
delimiting " (close-quote).  The blank following ." is not part of cccc.
\
.(			-			-

Immediate word used in the form:
	.( cccc)
The characters cccc up to but not including the delimiting ) (closing paren-
thesis) are displayed.  The blank following .( is not part of cccc.
\
.R			n size			-

Attempts to display n right-justified in a field of size characters.
\
/			n1 n2 			n3

n3 is the floor of the quotient of n1 divided by the divisor n2.  An
error condition results if the divisor is zero or if the quotient falls out-
side of the range {-32768..32767}.
\
/MOD			n1 n2			rem quot

rem is the remainder and quot the floor of the quotient of n1 divided by
the divisor n2.  rem has the same sign as n2 or is zero.  An error condition
results if the divisor is zero or if the quotient falls outside of the range
{-32768..32767}.
\
0			-			0

CONSTANT returns zero.
\
0<			n			flag

flag is true if n is less than zero (negative).
\
0=			n			flag

flag is true if n is zero.
\
0>			n			flag

flag is true if n is greater than zero.
\
1			-			1

CONSTANT returns 1.
\
1+			w1			w2

w2 is w1 + 1 (modulo 65536).
\
1-			w1			w2

w2 is w1 - 1 (modulo 65536).
\
2			-			2

CONSTANT returns 2.
\
2!			dl dh addr		-

Store high word dh at addr and store low word dl at addr+2.
\
2*			w1			w2

w2 is the result of shifting w1 left one bit.  A zero is shifted into the
vacated bit position.
\
2+			w1			w2

w2 is w1 + 2 (modulo 65536).
\
2-			w1			w2

w2 is w1 - 2 (modulo 65536).
\
2/			n1			n2

n2 is the result of arithmetically shifting n1 right one bit.  The sign is
included in the shift and remains unchanged.
\
2@			addr			dl dh

dh is contents of addr, dl is contents of addr+2.
\
2DROP			w1 w2			-

w1 and w2 are dropped from the stack.
\
2DUP			w1 w2			w1 w2 w1 w2

w1 and w2 are duplicated on the stack.
\
2VARIABLE		-			-

A defining word used in the form:
	2VARIABLE <name>
A dictionary entry for <name> is created and four bytes are ALLOTted in its
parameter field.  When <name> is later executed, the address of its parameter
field is placed on the stack.
\
:			-			-

A defining word used in the form:
	: <name>  ... ;
Create a definition for <name> in the compilation vocabulary and sets compil-
ation state.  The search order is changed so that the first vocabulary in the
search order is replaced by the compilation vocabulary.  The compilation
vocabulary is unchanged.  The text from the input stream is subsequently
compiled.  The newly created definition for <name> cannot be found in the
dictionary until the corresponding ; or equivalent operation is performed.
\
;			-			-

Compiling word stops compilation of a colon definition, allow the <name> to
be found in the dictionary; sets interpret state; and compiles (;), a word
functionally equivalent to EXIT.
\
<			n1 n2			flag

flag is true if n1 is less than n2.
\
<#			-			-

Initialize pictured numeric output conversion.   The words:
	# #> #S <# HOLD SIGN
can be used to specify the conversion of a double number into an ASCII text
string stored in right-to-left order.
\
<<			-			-

Immediate word to signal the beginning of a case inside the SELlect case
control structure.  See SEL for an example of how to use the case words.
\
<>			n1 n2			flag

flag is true if n1 is not equal to n2.
\
<MARK			-			addr

Used at the destination of a backward branch.  addr is typically only used
by <RESOLVE to compile a branch address.
\
<RESOLVE		addr			-

Used at the source of a backward branch after either BRANCH or ?BRANCH.
Compiles a branch address using addr as the destination address.
\
=			n1 n2			flag

flag is true if n1 equals n2.
\
==>			-			-

Immediate word separates a case structure equality test from the corresponding
case action.  See SEL for an example of how to use the case words.
\
=>			-			-

Immediate word separates a case structure test from the corresponding case
action.  See SEL for an example of how to use the case words.
\
>			n1 n2			flag

flag is true if n1 is greater than n2.
\
>>			-			-

Immediate word ends a case inside a case SEL control structure.  See SEL for
an example of how to use the case words.
\
>>RESOLVE		addr			-

Resolves a list of multiple forward references.  addr points to the first
element of a linked list.  Each link is stored in the address field of an
unresolved BRANCH or ?BRANCH instruction.  >>RESOLVE threads down the 
list pointing the BRANCHes to HERE.  A null list is indicated by addr equal
to zero.
\
>IN			-			addr

VARIABLE that conatains the present character offset within the input stream.
\
>MARK			-			addr

Used at the source of a forward branch.  Typically used after either BRANCH
or ?BRANCH.  Compiles space in ther dictionary for a branch address which will
later by resolved by >RESOLVE.
\
>R			n			-

Transfers n to the return stack.
\
>RESOLVE		addr			-

Used at the destination of a forward branch.  Places a branch address to HERE
in the space left by >MARK.
\
?			addr			-

The contents of addr are displayed in free field format with a leading minus
sign if negative.
\
?BRANCH			flag			-

When used in the form:  COMPILE ?BRANCH  a conditional branch operation is
compiled.  See BRANCH for further details.  When executed, if flag is false
the branch is performed as with BRANCH.  When flag is true execution continues
at the compilation address immediately following the branch address.
\
?DUP			n			n n <or> 0

n is duplicated if it is non-zero.
\
?STACK			-			flag

flag is true if stack has underflowed.
\
@			addr			n

n is the value at addr.
\
@SP			-			addr

addr is the address of the top stack item before @SP was executed.
\
ABORT			-			-

Clears the data stack and performs the function of QUIT.
\
ABORT"			flag 			-

Immediate word used in the form:
	flag ABORT" cccc"
When later executed, if flag is true, the characters cccc, delimited by "
(close-quote), are displayed and ABORT is executed.  If flag is false, the
flag is dropped and execution continues.  The blank following ABORT" is 
not part of cccc.  This word violates the principles of structured program-
ming and its use should be avoided.
\
ABS			n			u

u is the absolute value of n.  If n is -32768 then u is the same value.
\
AGAIN			-			-

Compiling word used in the form:
	BEGIN ... AGAIN
compiles an infinite loop.
\
ALIGN			addr1			addr2

Force word alignment of addr1.
\
ALLOT			w			-

Allocates w bytes in the dictionary.  WARNING: never ALLOT an odd number of 
bytes.
\
AND			n1 n2			n3

n3 is the bit-by-bit logical 'and' of n1 and n2.
\
BASE			-			addr

VARIABLE containing the current numeric conversion radix.
\
BEGIN			-			-

Immediate word marks the start of a word sequence for repetitive execution.
\
BRANCH			-			-

When used in the form:  COMPILE BRANCH  a conditional branch operation is
compiled.  A branch address must be compiled immediately following this
compilation address.  The branch address is typically generated by follow-
ing BRANCH with <RESOLVE, >MARK, or >>RESOLVE.
\
C!			n addr			-

The least significant 8 bits of n are stored into the byte at addr.
\
C@			addr			byte

The byte stored at addr is fetched.
\
CALL			-			-

Compile PDP-11 opcode for JSR iar,*$--- .   This word is typically used in
creating the code field of a dictionary definition.  See the defintions for
:, VARIABLE, and CONSTANT in the source code for an example its use.
\
CFIELD			nfa			cfa

Converts a name field address to the corresponding code field address.
\
CHUCKBUF		-			-

Flush rest of input buffer by moving >IN to the EOL mark.
\
CLOSE			fd			-

Close the Unix file with given file descriptor.
\
CMOVE			addr1 addr2 u		-

Move u bytes beginning at address addr1 to addr2.  The byte at addr1 is moved
first, proceeding toward high memory.  If u is zero, nothing is moved.
\
CMOVE>			addr1 addr2 u		-

Move the u bytes at address addr1 to addr2.  The move begins by moving the
byte at (addr1 + u - 1) to (addr2 + u - 1) and proceeds to successively 
lower addresses.  If u is zero nothing is moved.
\
COMPILE			-			-

Typically used in the form:
	: <name> ... COMPILE <namex> ... ;
When name is executed, COMPILE compiles the execution address of <namex> into
the dictionary.  Execution continues after <namex>.
\
CONSTANT		n			-

A defining word used in the form:
	n CONSTANT <name>
Creates a dictionary entry for <name> so that when <name> is later executed,
n will be left on the stack.
\
CONTXT			-			addr

addr is the address of a variable that points to the dictionary search
vocabulary.  This word is called CONTEXT in FORTH-83.
\
CONVERT			dl1 dh1 addr1		dl2 dh2 addr2

d2 is the result of converting the characters within the text beginning at 
addr1 + 1 into digits, using the value of BASE, and accumulating each into
d1 after multiplying d1 by the value of BASE.  Conversion continues until
an unconvertible character is encountered.  addr2 is the address of the first
unconvertivle character.
\
COUNT			addr			addr+1 n

Assumes a counted string is stored at addr.  Returns n, the byte stored
at addr, and increments addr.
\
CR			-			-

EMITs a linefeed character.
\
CREAT			addr[string] pmode	fd <or> -1

Try to create a file whose name is pointed to be addr with protection bits
pmode.  The file is opened for writing and the file descriptor is returned.
If the file already exists, its length is truncated to zero.  A -1 is returned
in the event of an error.
\
CREATE			-			-

A defining word used in the form:
	CREATE <name>
Creates a dictionary entry for <name>.  After <name> is created, the next
available dictionary location is the first byte of <name>'s parameter field.
When <name> is subsequently executed, the address of <name>'s parameter field
is left on the stack.  CREATE does not allocate space is <name>'s parameter
field.
\
CURRENT			-			addr

addr is the address of a variable pointing to the vocabulary in which new 
word definitions are appended.
\
D+			d1l d1h d2l d2h		dl3 dh3

d3 is is the arithmetic sum of d1 and d2.
\
D+-			d1l d1h n		d2l d2h

d2 is obtained by applying the sign of n to d1.  d2 := sign(n) * d1.
\
D.			dl dh			-

Print the double precision number d in free field format with a leading
minus sign if necessary.
\
D.LZ			dl dh size		-

Print the double precision number d right-justified in a field of size 
characters with leading zeros appended.
\
D.R			dl dh size		-

Print the double precision number d right-justified in a field of size
characters.
\
D<			d1l d1h d2l d2h		flag

flag is true if d1 is less than d2.
\
DABS			d1l d1h			d2l d2h

d2 is the absolute value of the double precision number d1. If d1 is equal
to -2,147,483,647 then d2 has the same value.
\
DECIMAL			-			-

Set the input-output conversion base to ten.
\
DEFINITIONS		-			-

The compilation vocabulary is changed to be the same as the search vocabulary.
\
DEPTH			-			n

N is the number of 16-bit values contained on the parameter stack before
DEPTH was executed.
\
DIGIT			char			n true <or> false

If char represents a valid digit in the current BASE, it is converted to 
the value n and true is returned.  Otherwise false is returned.
\
DNEGATE			d1l d1h			d2l d2h

d2 is the two's complement of of d1.
\
DO			n1 n2			-

Compiling word used in the form:
	DO ... LOOP  or  DO ... +LOOP
Begins a loop which terminates based on control parameters.  The loop index
begins at n2 and terminates based on the limit n1.  See LOOP and +LOOP
for details on how the loop is terminated.  The loop is always executed at
least once.
\
DOES>			-			addr

Defines the run-time action of a word created by the high-level defining
word CREATE.  Used in the form:
	: <namex> ... <create> ... DOES> ... ;
and then
	<namex> <name>
where <create> is CREATE or any user defined word which executes CREATE.
Marks the termination of the defining part of the defining word <namex>
and then begins the definition of the run-time action for words that will
later be defined by <namex>.  When <name> is later executed, the address
of <name>'s parameter field is placed on the stack and then the sequence
of words between DOES> and ; are executed.
\
DP			-			addr

VARIABLE that has the address of the first free byte at the end of the
dictionary.
\
DROP			n			-

n is DROPped from the stack.
\
DUMP			addr n			-

DUMPs n bytes of memory in pretty format starting at addr.
\
DUP			n			n n

n is DUPlicated on the stack.
\
ELSE			-			-

Immediate word used in the form:
	flag IF ... ELSE ... THEN
At run-time ELSE branches to just after the THEN.
\
EMIT			n			-

The least significant 8 bits of n are sent to the standard output.
\
ENDINTERP		-			-

Reset parameter stack pointer and throw away rest of input line.
\
ENDSEL			-			-

Immediate word ends a case control structure.  See SEL for an example
of how to use the case words.
\
EOL			-			char

CONSTANT defined as newline character (linefeed).
\
EXECUTE			cfa			-

The word definition indicated by cfa is executed.
\
EXIT			-			-

When executed inside a colon defintion, returns control to the definition
that passed control to it.  Cannot be used inside a DO ... LOOP.
\
FALSE			-			false

Places false flag (0) on the stack.
\
FEXPECT			fd addr count		actcount

Reads up to count bytes from the file denoted by file descriptor fd into
the buffer at addr.  Tabs are converted to blanks and encountering a line-
feed or and EOF will terminate the read.  The actual number of bytes read
actcount is returned.
\
FLOAD			addr[string]		-

Attempts to open the file indicated by the null-terminated string 'string'
for reading.  If successful, the text in the file is interpreted until an
EOF is encountered.  If the file can't be opened, a message is printed.
\
FQUERY			fd			actcount

FEXPECTs 120 characters from the file denoted by the file descriptor fd.
The text is placed in TIB, the text input buffer.  The actual number of bytes
read is returned.
\
FILL			addr u byte		-

u bytes of memory beginning at addr are set to byte.  No action is taken if
u is zero.
\
FIND			addr1 			addr2 n

addr1 is the address of a counted name string.  Tries to find the name in the
search vocabulary or in the compilation vocabulary.  If the word is not found, 
addr2 is the string address addr1, and n is zero.  If the word is found, addr2
is the compilation address and n is set to one of two non-zero values.  If
the word found has the immediate attribute, n is set to one.  If the word is
non-immediate, n is set to minus one.
\
FORGET			-			-

Used in the form:
	FORGET <name>
If <name> is found is the compilation vocabulary, delete <name> from the dic-
tionary and all words added to the dictionary after <name> regardless of their
vocabulary.  An error message is printed if <name> is not found.
\
FORTH			-			-

The name of the primary vocabulary.  Execution sets the search vocabulary to
FORTH.
\
HEADER			-			-

Create dictionary header in compilation vocabulary for next word in input
stream.  The header contains only the name field and link field.
\
HERE			-			addr

The address of the next available dictionary location.
\
HEX			-			-

Set the input-output conversion base to hex.
\
HLD			-			addr

VARIABLE holds the address of the last character added to the current
pictured numeric output conversion.
\
HOLD			char			-

char is inserted into a pictured numeric output string.  Typically used
between <# and #>.
\
I			-			n

n is a copy of the loop index.  May only be used in the form:
	DO ... I ... LOOP  or  DO ... I ... +LOOP
\
IF			-			-

Immediate word used in the form:
	flag IF ... ELSE ... THEN  or  flag IF ... THEN
If flag is true, the words following IF are executed and the words following
ELSE until just after THEN are skipped.  The ELSE part is optional.  If flag
is false, words from IF through ELSE, or from IF through THEN (when no ELSE
is used), are skipped.
\
INTERPRET		-			-

Interpret the text in the input buffer until an EOL is encountered.
\
J			-			n

n is a copy of the index of the next outer loop.  May only be used within
a nested DO-LOOP.
\
LATEST			-			nfa

Returns name field address of word most recently added to the compilation
vocabulary.
\
LEAVE			-			-

Transfers execution to just beyond the next LOOP or +LOOP.  The loop is
terminated and loop control parameters are discarded.  May only be used in
the form:
	DO ... LEAVE ... LOOP  or  DO ... LEAVE ... +LOOP
Leave may appear within other control structures which are nested within 
the DO-LOOP structure.  More than one LEAVE may appear within a DO-LOOP.
\
LITERAL			n			-

Immediate word typically used in the form:
	[ n ] LITERAL
compiles n as a literal.  At run-time, n will be put on the stack.
\
LOOP			-			-

Increments the DO-LOOP index by one.  If the new index was incremented 
across the boundary between limit-1 and limit, the loop is terminated and
loop control parameters are discarded.  When the loop is not terminated,
execution continues to just after the corresponding DO.
\
M*			n1 n2			dl dh

The signed numbers n1 and n2 and are multiplied to obtain the signed double
precision number d.
\
M/			dl dh divisor		rem quot

Signed mixed mode floored division. d is 32 bits.
\
M/MMOD			dl dh divisor		rem quotl quoth

unsigned mixed mode division.  Dividend and quotient are 32 bits.
\
MAX			n1 n2			n3

n3 is the greater of n1 and n2 according to the operation of >.
\
MIN			n1 n2			n3

n3 is the lesser of n1 and n2 according to the operation of <.
\
MOD			n1 n2			n3

n3 is the remainder after dividing n1 by the divisor n2.  n3 has the same
sign as n2 or is zero.  An error condition results if the divisor is zero
or if the quotient falls outside of the range {-32768..32767}.
\
NEGATE			n1			n2

n2 is the two's complement of n1.
\
NFIELD			cfa			nfa

Convert a code field address to its corresponding name field address.
\
NOT			n1			n2

n2 is the one's complement of n1.
\
NUMBER			addr			n true <or> false

addr points to a counted string.  NUMBER attempts to convert this string
to a number using the current BASE.  The converted number n and a true flag
are returned if successful.  Otherwise a false is returned.  For the con-
version to be successful, there must be a blank at the end of the string.
This is taken care of by WORD.
\
OCTAL			-			-

Set the input-output conversion base to octal.
\
OPEN			addr[string] mode	fd <or> -1

Try to open a file whose name is pointed to by addr with mode attributes.
Returns a file descriptor fd if successful, a -1 otherwise.  string is
a null terminated text string.  File modes are 0=read-only, 1=write-only,
and 2=read-write.
\
OR			n1 n2			n3

n3 is the bit-by-bit inclusive-or of n1 and n2.
\
OUTPUT			fd			-

Add file descriptor to output table used by TYPE if there is room in the table.
If there is no room, the command is ignored.
\
OVER			n1 n2			n1 n2 n1

Duplicates n1 on stack.
\
PAD			-			addr

The lower address of a scratch area used to hold data for intermediate pro-
cessing.  The address or contents of PAD may change and the data lost if the 
address of the next available dictionary location is changed.
\
PICK			n1			n2

n2 is a copy of the n1'th stack item not counting n1 itself.  0 PICK is 
equivalent to DUP, 1 PICK is equivalent to OVER, etc.
\
QUIT			-			-

Sets interpret state, accepts new input from the current input device, and
begins text interpretation.  This word diverges from the FORTH-83 word QUIT
in that it does not reset the return stack.  This may be changed in the 
future.
\
R>			-			n

n is removed from the return stack and transferred to the parameter stack.
\
R@			-			n

n is a copy of the top of the return stack.
\
READ			fd addr count		actcount

READs up to count bytes from the file denoted by file descriptor fd to
the buffer at addr.   actcount is the number of bytes actually read.
If this is not equal to count, the end of file was encountered or an error
occurred.
\
REPEAT			-			-

Immediate word used in the form:
	BEGIN ... flag WHILE ... REPEAT
At run-time, REPEAT continues execution just after the corresponding
BEGIN.
\
ROLL			n			-

The n'th stack value, not counting n itself is first removed and then trans-
ferred to the top of the stack, moving the remaining values into the vacated
position.  2 ROLL is equivalent to ROT.  0 ROLL is a null operation.
\
ROT			n1 n2 n3		n2 n3 n1

The top three stack entries are rotated, bringing the deepest to the top.
\
ROTATE			n1 nbits		n2

ROTATE n1 nbits.  If nbits is greater than zero, n1 is ROTATEd left.  If
nbits is less than zero, n1 is ROTATEd right.  If nbits is zero, nothing
happens.
\
S->D			n			dl dh

Sign extend n into a double precision number.
\
SEEK			fd offsetl offseth	-

Perform random-access seek on file denoted by file descriptor fd. offset
is a double precision number specifying a new file position offset from the
start of the file.
\
SEL			-			-

Immediate case structure word used in the form:
<selector> SEL
	      <<    1      ==> ... >>
	      <<    2      ==> ... >>
	      <<    5      ==> ... >>
	      << OTHERWISE ==> ... >>
           ENDSEL
The constants 1, 2, and 5 are just shown as an example.  Any word that leaves
one item on the stack can be used in the select field.  The action code 
symbolized by ..., can be any thing including another case structure.  The
<selector> is no longer on the stack when the action code begins execution.
The OTHERWISE clause is optional.  If none of the words in the select fields
match the <selector>, the <selector> is dropped by ENDSEL.
\
SHELL			-			-

Spawn a new sub-shell under the forth process.  Typing a ^D will cause control
to return to forth.
\
SIGN			n			-

If n is negative, an ASCII "-" is appended to the pictured numeric output
string.  Typically used between <# and #>.
\
SILENT			fd			-

Remove all instances of fd from the table used by TYPE.
\
SMUDGE			-			-

Toggle smudge bit in name field of word most recently added to the compilation
vocabulary.
\
SP0			-			addr

addr is address of 'top of stack' for an empty stack.  Used for resetting
stack pointer.
\
SPACE			-			-

EMIT an ASCII space.
\
SPACES			n			-

EMIT n ASCII spaces.  Nothing is EMITted if n is negative or zero.
\
STATE			-			addr

VARIABLE has current interpret-compile state.  0=interpret, 1=compile.
\
STDIN			-			0

CONSTANT returns file descriptor of standard input.
\
STDOUT			-			1

CONSTANT returns file descriptor of standard output.
\
STRING			addr[counted string]	addr[unix string]

Converts a counted string to a unix-style null-terminated string.  A copy of
the counted string is moved to PAD so that the conversion does not alter
the original string.
\
SWAP			n1 n2			n2 n1

The top two stack entries are exchanged.
\
SYSTEM			addr[string]		-

Spawns a sub-shell to execute the unix command string pointed to by addr.
The string must be null-terminated.  Typically used in the form:
	" cccc" SYSTEM  or inside a colon definition as:
	"" cccc" SYSTEM
\
TERMINATE		-			-

Terminate the forth process.  Returns 'good' status value.
\
THEN			-			-

Immediate word used in the form:
	flag IF ... ELSE ... THEN  or  flag IF ... THEN
THEN is the point where execution continues after ELSE, or IF when no ELSE
is present.
\
TIB			-			addr

addr is the address of the text input buffer.
\
TOGGLE			addr bits		-

The contents of addr are exclusive-or'ed with bits and the results stored
at addr.
\
TRUE			-			true

Places a true flag (-1) on the stack.
\
TYPE			addr count		-

count bytes of memory beginning at addr are sent to the standard output.
\
U.			u			-

u is displayed as an unsigned number in a free-field format.
\
U.LZ			u size			-

u is displayed as an unsigned number right-justified in a field of size 
characters with leading zeros.
\
U.R			u size			-

u is displayed as an unsigned number right-justified in a field of size
characters.
\
U<			u1 u2			flag

flag is true if the unsigned number u1 is less than the unsigned number u2.
\
U>			u1 u2			flag

flag is true if the unsigned number u1 is greater than the unsigned number n2.
\
U?			addr			-

Display the contents of addr as an unsigned number in free-field format.
\
UM*			n1 n2			ul uh

u is the 32-bit product of the unsigned multiplication of n1 and n2.
\
UM*M			u1l u1h mul		u2l u2h

u2 is the 32-bit product of the unsigned multiplication of u1 and mul.
\
UM/			ul uh div		rem quot

rem and quot are remainder and quotient of unsigned division of 31-bit u
by the unsigned divisor 'div'.
\
UM/MOD			ul uh div		rem quot

'rem' and 'quot' are remainder and quotient of unsigned division of 32-bit 'u'
by the unsigned divisor 'div'.
\
UNTIL			-			-

Immediate word used in the form:
	BEGIN ... flag UNTIL
Marks the end of a BEGIN-UNTIL loop which will terminate based on flag.  If
flag is true, the loop is terminated.  If flag is false, execution continues
just after the corresponding BEGIN.
\
VARIABLE		-			-

A defining word used in the form:
	VARIABLE <name>
A dictionary entry for <name> is created and two bytes are ALLOTted in its
parameter field.  This parameter field is to be used for the contents of the
VARIABLE.   The application is responsible for initializing the contents of 
the VARIABLE.  When <name> is later executed, the address of  its parameter
field is placed on the stack.
\
VOCABULARY		-			-

A defining word used in the form:
	VOCABULARY <name>
A dictionary entry for <name> is created.  Subsequent execution of <name> 
sets the search vocabulary to <name>.  When <name> becomes the compilation
vocabulary, new definitions will be appended to <name>'s list.
\
WHILE			-			-

Immediate word used in the form:
	BEGIN ... flag WHILE ... REPEAT
Selects conditional execution based on flag.  When flag is true, execution
continues just after the WHILE.  When flag is false, execution continues
just after the REPEAT, exiting the control structure.
\
WORD			char			addr

Generates a counted string by non-destructively accepting characters from
the input stream until the delimiting character char is found or the 
input stream is exhausted.  Leading delimiters are ignored.  The entire
character string is stored in memory beginning at addr as a sequence of
bytes.  The string is followed by a blank which is not included in the count.
The first byte of the string is the number of characters {0..255}.  If the
string is longer than 255 characters, the count is unspecified.  If the input
stream is already exhausted as WORD is called, then a zero length character
string will result.
\
WRITE			addr count fd		actcount

count bytes of memory starting at addr are sent to the file denoted by
file descritor fd.  The actual number of bytes written actcount is re-
turned.  If this number does not equal count, an error of some sort has
occurred.
\
WRN			-			addr

VARIABLE that holds the state the warning message enable/disable.  If WRN
is true, the user will be notified if he tries to add a word to the 
dictionary whose name conflicts with a word already in the dictionary.
\
XOR			n1 n2			n3

n3 is the bit-by-bit exclusive-or of n1 and n2.
\
ZEROES			n			-

EMIT n ASCII zeroes.  Nothing is EMITted if n is zero or negative.
\
[			-			-

Immediate word that sets the interpretation state to interpret.
\
[']			-			addr

Immediate word used in the form:
	['] <name>
Compiles the compilation address of <name> as a literal.  At run-time
the cfa of <name> is put on the stack.  If <name> is not found in the
dictionary, a literal zero is compiled.
\
[COMPILE]		-		-

Immediate word used in the form:
	[COMPILE] <name>
Forces compilation of the following word <name>.  This allow compilation of
an immediate word when it would otherwise have been executed.
\
]			-		-

Sets interpretation state to compile.  The text from the input stream is
subsequently compiled.
\
+E+O+F



More information about the Comp.sources.unix mailing list