wls@astrovax.UUCP (William L. Sebok) (06/26/84)
Part 2 of 8 --------Cut here and extract with sh not csh ---------------- mkdir ./doc /bin/echo 'Extracting ./doc/forth1' sed 's/^X//' <<'//go.sysin dd *' >./doc/forth1 ! n addr --- 112 Store n at address. "store" !++ addr n --- addr2 local Store word `n' into the memory location pointed to by address `addr', leaving on the parameter stack the value of `addr' incremented by one word-length. !EXPON n fl_f --- fl2_f floating Replaces the base 2 exponent of floating point number `fl_f' with a new exponent `n'. The base 2 exponent of floating point number f is defined here as log2(f) + 1 . !LCK n --- local In a Forth kernel that supports co-processes, guarantees that the n'th most recently accessed buffer is valid. Defaults to 1. !SIGNAL addr --- local Lets one set a handler for the end-of-line, QUIT, or ABORT condition. `addr' is a pointer to a FORTH word of the sort returned by ' routine This word is executed whenever end-of-line, QUIT, or ABORT, occurs. If `addr' is 0 then the handler is removed and no special action takes place. An example of where this facility would be used would be to flush the buffered output to a graphics device, or to close files which should not be left open. This word is likely to be soon replaced by one which keeps a stack of condition handlers, with addr -SIGNAL provided to remove condition handlers from that stack. !X! addr1 addr2 --- local Exchange the contents of `addr1' and `addr2'. ![ addr len --- strings Used in definitions of the form: addr len ![ string...] The characters between but not including the necessary leading space and the trailing delimiter ( "]", right square bracket), are retrieved from the input stream and stored in the memory location of length `len' bytes starting at address `addr' (the leading space is needed as a delimiter for the forth outer interpreter). If `len' is smaller than the length of the string, the string is truncated on the right. If `len' is larger than the string, it is padded on the right with blanks. " --- string_s strings Used in definitions of the form: " string..." The characters between, but not including, the necessary leading space and the trailing delimiter (a double quote for the `"' operator, a right parenthesis for the `((' operator, or a right square bracket for the `[[' operator) are pushed as a string onto the string stack. (The leading space is needed as a delimiter for the forth outer interpreter). String constants can occur either in definitions or can be executed directly. In definitions they result in their strings being compiled for retrieval at execution time. (In this FORTH imple- mentation strings longer than 5 characters are kept on a temporary file on disk). Because of the necessity of intelligent compile-time action, the string constant operators are Immediate operators. The backslash character has been implemented as an escape character to allow the inclusion of control characters in strings. Generally the these "escape sequences" are the same as those use in the character strings of the "c" language (with some extensions). The possibilities are: \b = backspace \e = escape char (octal 033) \f = form feed \n = new line (line-feed) \r = carriage return \t = tab \? = rubout character (octal 0177) \\ = backslash character \nnn = nnn is up to 3 digit octal number. \X = X is a capital letter. Value of X with most significant 3 bits removed, (i.e. \C = "control C") all other characters following a backslash yield an undefined result. # d1_2 --- d2_2 158 Generate from an double integer `d1_2', the next ASCII character which is placed in an output string. Result `d2_2' is the quotient after division by BASE and is maintained for further processing. Used between <# and #>. pronounced "sharp" #> d_2 --- addr n 190 End pictured numeric output conversion. Drop `d_2', leaving the text address, and character count, suitable for TYPE. pronounced "sharp-greater". #DROP nn ... n3 n2 n1 n --- local Drop the top `n' items and n itself from the parameter stack. #ELSE I,cond.compilation Used outside of colon definitions in expressions of the form: #IF . . . #ELSE . . . #THEN #ELSE executes after the true clause following #IF. #ELSE forces execution to skip till just after #THEN. It has no effect on the stack. Token comparison is case independent. (See #IF) #IF flag --- I,cond. compilation Used outside of colon-definitions in expressions of 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 are skipped. The #ELSE clause is optional. If flag is false, words between #IF and #ELSE, or between #IF and #THEN (when no #ELSE is used), are skipped. #IF-#ELSE-#THEN conditionals may be nested to any level. Token comparison is case independent. #IFDEF name_s --- cond. compilation Used outside of colon-definitions in expressions of the form: name_s #IFDEF . . . #ELSE . . . #THEN or name_s #IFDEF . . . #THEN If there exists an entry named `name_s' in the dictionary, the words following #IFDEF are executed and the words following #ELSE are skipped. The #ELSE clause is optional. If there exists no such entry, words between #IFDEF and #ELSE, or between #IFDEF and #THEN (when no #ELSE is used), are skipped. #IFDEF-#ELSE-#THEN conditionals may be nested to any level. Token comparison is case independent. #IFNDEF name_s --- cond. compilation Used outside of colon-definitions in expressions of the form: name_s #IFNDEF . . . #ELSE . . . #THEN or name_s #IFNDEF . . . #THEN If there exists no entry named `name_s' in the dictionary, the words following #IFNDEF are executed and the words following #ELSE are skipped. The #ELSE clause is optional. If there exists such entry, words between #IFNDEF and #ELSE, or between #IFNDEF and #THEN (when no #ELSE is used), are skipped. #IFNDEF-#ELSE-#THEN conditionals may be nested to any level. Token comparison is case independent. #S d_2 --- 0 0 209 Convert all digits of an positive double integer, adding each digit to the pictured numeric output text, until the remainder is zero. A single zero is added to output string if the number was initially zero. Use only between <# and #> . pronounced "sharp-s" #THEN --- I,cond.compilation Used outside of colon-definition, in expressions of the form: #IF . . . #ELSE . . . #THEN or #IF . . . #THEN #THEN is the point where execution resumes after #ELSE or #IF (when no #ELSE is present). Token comparison is case independent. $CD dir_s --- unix_interface Change the current directory to `dir_s' (name passed on string stack). The error status (0 if okay) is left in user area variable ERRNO. $CHMOD fil_s mode --- unix_interface Change the protection mode of the file `fil_s' to `mode'. The error status (0 if okay) is left in user area variable ERRNO. Note that if one wants to represent the mode in the usual way (three octal digits) one has to arrange oneself to enter the number in the OCTAL base. $CLOSE fildes --- unix_interface Close the file descriptor `fildes'. The error status (0 if okay) is left in user area variable ERRNO. $CREATE fil_s mode --- fildes unix_interface Create a new file with name `fil_s', or if the file already exists truncate it to zero length. The file is created with protection mode `mode' which need not allow writing. If successful a new file descriptor is returned on the parameter stack and user area variable ERRNO is cleared. If unsuccessful, -1 is returned on the parameter stack and the unix error number is returned in user area variable ERRNO. $DUP fil1 --- fil2 unix_interface Return a file descriptor fil2 which is a duplicate of file descriptor `fil1'. On error -1 is returned. The error status (0 if okay) is left in user area variable ERRNO. $EXEC strn_s ... str2_s str1_s str0_s prog_s n --- (no return) Execute the program whose name is `prog_s'. `n' is the number of string arguments to be passed to this program, str0_s to strn_s. This does not count str0_s which is conventionally the name of the program being invoked (i.e. the same string, or an abbreviated version of, `prog_s'. The environment passed to this program is the same as that originally passed to forth. The program name `prog_s' must be a reachable path name (no $PATH environment variable searching is done, at least not yet in this implementation). If it is not able to find the program it returns with error status in user area variable ERRNO. $EXIT status --- (no return) unix_interface Exit with status (status). There is no return. No buffers are flushed. To exit flushing buffers use BYE. $FORK --- pid flag unix_interface The current process is duplicated. Two processes will return from $FORK. The `flag' of the parent will be zero, that of the child will be 1. Normally, $FORK will be followed immediately by an IF statement. The pid of the parent will be returned to the child, the pid of the child will be returned to the parent. On error `flag' is set to -1, `pid' is undefined and error status is left in user area variable ERRNO. $GETPID --- pid unix_interface The current pid (process id number) is returned. The error status if any (0 if okay) is left in user area variable ERRNO. $IOCTL argp request fildes --- ret unix_interface Do an ioctl(2) system call on the file with file descriptor `fildes'. `request' is the type of ioctl request and argp points to a buffer large enough to hold whatever (if anything) is returned by the ioctl call. For more information on ioctl calls available see the Unix manual. If successful, the number returned by the ioctl call (usually 0) is returned on the parameter stack and user area variable `errno' is cleared. If If unsuccessful, -1 is returned on the parameter stack and the unix error number is returned in user area variable ERRNO. Note: At present nothing useful is returned by an ioctl call. However since in the future something useful could (and I believe should) be returned I am making $IOCTL return the syscall results. $KILL pid signo --- unix_interface Send signal `signo' to process number `pid'. If `pid' is 0 then the signal is sent ot all other processes in the sender's process group. The error status (0 if okay) is left in user area variable ERRNO. $LENGTH fil --- len_l unix_interface Return the length in bytes of the file whose file descriptor is `fil'. The error status (0 if okay) is left in user area variable ERRNO. Note: on the Vax type _l is the same as a single integer. However for portability with machines with 16 bit stack entries one should use the words for manipulating _l type quantities to manipulate the returned length. $LSEEK offset_2 whence fildes --- loc_2 unix_interface Set a pointer within the file whose descriptor is `fildes' so that the next read or write will start from a different location within the file. If `whence' is 0 the pointer is set to `offset' bytes from the beginning of the file. If `whence' is 1 the pointer is set to its current location plus offset. If `whence' is 2 the pointer is set to the size of the file plus `offset' (`offset' bytes from the end of the file). The error status (0 if okay) is left in user area variable ERRNO. The resultant number of bytes from the binning of the file is returned on the stack as a double integer. $OPEN fil_s iomode --- fildes unix_interface Open the file named `fil_s' with iomode = 0 input, iomode = 1 output, or iomode = 2 input/output. If successful a new file descriptor is returned on the parameter stack and user area variable ERRNO is cleared. If unsuccessful, -1 is returned on the parameter stack and the unix error number is returned in user area variable ERRNO. $PIPE --- out in unix_interface Create a pipe (a pseudo i/o device in which whatever is written into the output file descriptor can latter be read from the input file descriptor. The error status (0 if okay) is left in user area variable ERRNO. $READ addr count fil --- retcount unix_interface Read `count' bytes into a buffer whose address is `addr' from file whose file descriptor is `fil'. If successful, the number of bytes read is returned on the parameter stack and user area variable ERRNO is cleared. If If unsuccessful, -1 is returned on the parameter stack and the unix error number is returned in user area variable ERRNO. $SEEK offset_l whence fildes --- loc_l unix_interface Set a pointer within the file whose descriptor is `fildes' so that the next read or write will start from a different location within the file. If `whence' is 0 the pointer is set to `offset' bytes from the beginning of the file. If `whence' is 1 the pointer is set to its current location plus offset. If `whence' is 2 the pointer is set to the size of the file plus `offset' (`offset' bytes from the end of the file). The error status (0 if okay) is left in user area variable ERRNO. The resultant number of bytes from the binning of the file is returned on the stack as a long integer. Note: on the Vax type _l is the same as a single integer. However for portability with machines with 16 bit stack entries one should use the words for manipulating _l type quantities to manipulate these numbers. $UNLINK fil_s --- unix_interface. Unlink (remove, delete) the file `fil_s' (name passed on string stack). The error status (0 if okay) is left in user area variable ERRNO. $WAIT --- proc stat unix_interface Wait for a child process to die. On successful return the pid (process id number) of the process that died is returned on the top of the stack, with its status below. The user variable ERRNO is cleared. On error return `pid' and `stat' are undefined and error status is in user area variable ERRNO. The most common error number is 9, which indicates that there was no child process on which to wait. $WRITE addr count fil --- retcount unix_interface Write `count' bytes into a buffer whose address is `addr' from file whose file descriptor is `fil'. If successful, the number of bytes written is returned on the parameter stack and user area variable ERRNO is cleared. If unsuccessful, -1 is returned on the parameter stack and the unix error number is returned in user area variable ERRNO. ' --- addr I,171 Used in the form: ' <name> If executing, leave the parameter field address of the next word from the input stream. If compiling, compile this address as a literal; later execution will place this value on the stack. An error condition exists if not found after a search of the CONTEXT and FORTH vocabularies. Within a colon-definition ' <name> is identical to [ ' <name> ] LITERAL. "tick" '.' --- local Insert a period into a pictured numeric output string. May only be used between <# and #> . 'FS --- addr floating Return the address of the current top of the floating point stack. 'R --- addr local Returns the address of the current top of the return stack. 'S --- addr local Returns the address of the current top of the parameter stack (that is, where the top of stack was before 'S is executed). 'SELF --- addr local,C Return the address of the colon definition inside which the reference to 'SELF appears. Used in self-referential constructs. 'SS --- addr strings Return the address of the top of the string stack. 'SS! addr --- strings Set the address of the top of the string stack. This must be an address within the bounds of the string stack or all heck will break loose. 'U --- user U,local Returns address of the currently active user area. The user area (or process control block) contains important forth system variables for which different copies need to be kept for different co-processes. 'U points to the first location in the user area. This area is zero (false) if the co-process connected to the user area is active or waiting to become active. This area is non-zero (true) if the process is waiting for i/o or otherwise currently inactive. (At present, under Unix with no co-processes, this location is alway zero (false)). ( I,122 Used in the form: ( ccc) Accept and ignore comment characters from the input stream, until the next right parenthesis. As a word, the left parenthesis must be followed by one blank. It may be freely used while executing or compiling. An error condition exists if the input stream is exhausted before the right parenthesis. "paren" The right parenthesis is pronounced "close-paren" (( --- string_s strings Used in definitions of the form: (( string...) The characters between but not including the necessary leading space and the trailing delimiter ( ")", right parenthesis), are pushed as a string onto the string stack. (The leading space is needed as a delimiter for the forth outer interpreter). See the definition for `"' (The double-quote operator), which has identical behavior but a different trailing delimiter. () --- addr U,local Leaves an address on the stack. This variable currently has two uses. One use is as a byte pointer to the current position in the output buffer used by the routines which convert numbers from binary to ASCII. ( such as <# , # , HOLD , #> , etc. ). The second use is as an implied index within the VECTOR package, (X sets () to access the first element, Y to access the 2nd element, Z to access the 3rd element. See documentation of VECTOR package). The 1st use is likely to be given to a variable of a different name in the future. ()STRING strings #_of_elements max_length ()STRING name defines an array of character strings whose name is `name'. Space for `#_of_elements' character strings each of whose maximum length is `max_length' bytes is allocated. `name' is executed by a call of the form: n `name' This call references the `n'th string. The address of that string (below) and its maximum length (below) are placed on the parameter stack by this call. (.) n --- addr len local Convert single integer `n' to a character string according to BASE. The address of the character string is returned as `addr' and its length as `len'. (D.) n_2 --- addr len local Convert double integer `n_2' to a character string according to BASE. Display the sign only if negative. The address of the character string is returned as `addr' and its length as `len'. (E.) x_f --- addr count floating Floating point number `x_f' is converted to a character string using exponential format (for example -1.345678e+00). The address of the string `addr' and its length `count' are returned on the parameter stack. (U.) num_u --- addr len local Convert unsigned integer `num_u' to a character string according to BASE. The address of the character string is returned as `addr' and its length as `len'. * n1 n2 -- n3 138 Leave the arithmetic product of `n1' times `n2'. "times" */ n1 n2 n3 --- n4 220 Multiply `n1' by `n2', divide the result by `n3' and leave the quotient `n4'. `n4' is rounded toward zero. The product of `n1' times `n2' is maintained as an intermediate double-integer value for greater precision than the otherwise equivalent sequence: n1 n2 * n3 / "times-divide" */MOD n1 n2 n3 --- n4 n5 192 Multiply `n1' by `n2,' divide the result by n3 and leave the remainder `n4' and the quotient `n5'. A double integer intermediate product is used as for */. The remainder has the same sign as `n1'. + n1 n2 --- n3 121 Leave the arithmetic sum of `n1' plus `n2'. "plus" +! n addr --- 157 Add n to the word-length value at the address. "plus-store" ++ a1 --- a2 Local Increment address `a1' by one word-length, i.e., add the word length in bytes to address a1. ++! addr --- Local Add the number of bytes/word to the address pointed to by addr. +A n a1 --- a2 Local Add word offset `n' to address `a1', i.e., multiply `n' by the word length in bytes and add to address `a'. Like A+ except arguments are swapped. +LOOP n --- I,C,141 Add the signed increment `n' to the loop index using the convention for +, and compare the total to the limit. Return execution to the corresponding DO until the new index is equal to or greater than the limit (n>0), or until the new index is les than the limit (n<0). Upon exition from the loop, discard the loop control parameters, continuing execution ahead. Index and limited are signed word-length integers in the range at least {-32,768 ... 32,767}. "plus-loop" , n --- 143 Allot a word in the dictionary, storing `n' there. "comma" - n1 n2 --- n3 134 Subtract `n2' from `n1' and leave the difference `n3'. "minus" -! n addr --- local Subtract `n' from the word-length value at the address. "minus-store" -- a1 --- a2 Local Decrement address `a1' by one word-length, i.e., subtract the word length in bytes from address `a1'. --! addr --- Local Subtract the number of bytes/word from the address pointed to by addr. --> ref I,131 Continue interpretation on the next sequential screen. May be used within a colon definition that crosses a block boundary. May be used in screen format file whether it is LOAD'ed LOADF'ed or FLOAD'ed. "next-block" -DROP n1 n2 --- n2 Local Eliminate the stack element one below the top of the stack. -INSTALL name_s blockno mode --- Unix-interface Install file at specified block number. The file with path name `name_s' (passed on the string stack) is opened with access mode `mode' and installed in the block mapping table, mapping a range of forth blocks starting at `blockno' and equal in extent to the size of the file. If mode=2 (update) and the file has read-permission only, the file will be open read-only. It will first try the current directory. If that fails it will try the FORTH library directory (i.e. the directory defined by the string SDIR). If the file name begins with a '<' (i.e. a less-than symbol) the '<' character is stripped off and only the FORTH library directory is searched. If everything fails an abort is taken. NOTE: need to implement a search path. -MATCH addr1 len1 addr2 len2 --- addr3 flag reference Attempt to find string #2 somewhere in string #1. String #1 consists of `len1' characters starting ad address `addr1'. String #2 consists of `len2' characters starting at address `addr2'. Return return as `addr3' the address one byte beyond address of the match point within string #1. `flag' is zero if a match exists. -ROT n1 n2 n3 --- n3 n1 n2 Local Rotate the top three values in the other direction than ROT, putting the top number in the deepest position. -S? addr1 cnt1 addr2 cnt2 --- flag strings Compares the character string that starts at `addr1' and contains `cnt1' characters with the character string that starts at `addr2' and contains `cnt2' characters. The result of the comparison is returned on the parameter stack. If the string below is < than the string above ... -1 is returned. If the string below is = to the string above ... 0 is returned. If the string below is > than the string above ... +1 is returned. The comparison is done with the shorter string extended to the right with blanks to bring it to the same length as the longer string. -SANY addr1 cnt1 addr2 cnt2 --- flag strings Searches in the character string that starts at address `addr1' and contains `cnt1' characters for the 1st occurrence of any of the characters contained in the string that starts at address `addr2' and contains `cnt2' characters. The character number in the first string of the match is returned on the parameter stack. A zero is returned if none of the characters in the second string are contained in the first string. -SANY is used to search for a delimiter in a string. -SNONE addr1 cnt1 addr2 cnt2 --- flag strings Searches for the 1st character in the character string that starts at address `addr1' and contains `cnt1' characters, which is not contained in the character string which starts at address `addr2' and contains `cnt2' characters. The character number in the first string of position of the first non-matching character is returned on the parameter stack. A zero is returned if the first string consists only of characters from the second string. -SNONE is used to skip over leading delimiters in a string. -TRAILING addr n1 --- addr n2 148 Adjust the character count `n1' of a text string beginning at addr to exclude trailing blanks, i.e., the characters at `addr+n2' to `addr+n1-1' are blanks. An error conditions exists if `n1' is negative. "dash-trailing" X. n --- 193 Display `n' converted according to BASE in a free-field format with one trailing blank. Display only a negative sign. "dot" X." --- I,133,strings Interpreted or used in a colon-definition in the form: ." ccccc" Accept the following text from the input stream, terminated by a " (double-quote). If executing, transmit this text to the selected output device. If compiling, compile so that later execution will transmit the text to the selected output device. At least 127 char- acters are allowed in the text. If the input stream is exhausted before the terminating double-quote, an error condition exists. "dot-quote" implementation notes: 1) compiled strings longer than 5 characters are kept on disk. 2) the high singificance bit of the length byte of the compiled string is used to indicate a disk resident string. 3) The 'selected output device' is selected by the user variable TYPER. TYPER points to a control block whose first word points to the address of an output routine. If this routine is the standard unix terminal output interface UNIXOUT, then the second word will contain the file descriptor number of the output file. 4) The backslash character has been implemented as an escape character to allow the inclusion of control characters in strings. Generally the these "escape sequences" are the same as those use in the character strings of the "c" language (with some extensions). The possibilities are: chars preceded by a backslash are interpreted as control characters \b = backspace \e = escape char (octal 033) \f = form feed \n = new line (line-feed) \r = carriage return \t = tab \? = rubout character (octal 0177) \\ = backslash character \nnn = nnn is up to 3 digit octal number. \X = X is a capital letter. Value of X with most significant 3 bits removed, (i.e. \C = "control C") all other characters following a backslash yield an undefined result. X.D num_2 dig --- local Print double integer `num_2' with decimal point embedded `dig' digits from the right. The output includes a trailing space. X.FR num_2 dig wid --- local Print double integer `num_2' right justified in a field of `wid' characters with a decimal point embedded `dig' digits from the right. There is no trailing space. X.R n len reference Print `n' right-aligned in a field of `len' characters, according to number base BASE. If `len' is less than the number of characters required for `n', no leading blanks are supplied. "dot-r" X.[ --- strings Interpreted or used in a colon-definition in the form: .[ ccccc...] Accept the following text from the input stream, terminated by a ] (right square bracket). If executing, transmit this text to the selected output device. If compiling, compile so that later execution will transmit the text to the selected output device. At least 127 characters are allowed in the text. If the input stream is exhausted before the terminating double-quote, an error condition exists. Control characters can be produced by sequences of characters beginning with \ (backslash). For more information about these escape sequences see the description of ." (dot double-quote) which has the same behavior except for a different trailing delimiter. X/ n1 n2 --- n3 178 Divide `n1' by `n2' and leave the quotient `n3'. `n3' is rounded toward zero. X// sa_s sb_s --- sab_s strings Concatenate top two strings on string stack, string below on stack to the left and string above the stack on the right. X//PRFX sa_s sb_s --- sba_s strings Like // except the order of the arguments on the string stack is reversed. Appends the top string at the beginning of the lower string. Since // is defined as a SSWAP and a //PRFX, it is faster to use //PRFX when the arguments are already in the right order. X/C --- n local Return the number of bytes in a character. On all reasonable machines this is 1. X/CEIL divd divs --- quot local Divide `divd' by `divs', leaving the quotient. The result is rounded up to the next greater (more positive or less negative) number. X/L --- n local Return the number of bytes in an L type quantity (32-bit integer). On most machines this is 4. X/MCEIL divd_2 divs --- quot local Divide the double integer `divd_2' by the single integer `divs', leaving a single integer quotient. The result is rounded up to the next more positive or less negative number. X/MMOD divd_2 divsor --- rem quot local Perform the signed division of double integer `divd_2' by `divsor', leaving the remainder `rem', and quotient `quot'. All values are signed. X/MOD n1 n2 --- n3 198 Divide `n1' by `n2' and leave the remainder `n3' and quotient `n4'. `n3' has the same sign as `n1.' "divide-mod" X/N --- n local Return the number of bytes in an 1 stack cell width integer (the default size). On the vax this is 4 bytes, most 16 bit machines 2 bytes. X/W --- n local Return the number of bytes in a 16 bit integer. On most machines this is 2. 0! addr --- local Store zero at address `addr'. 0< n --- flag 144 True if `n' is less than zero (negative). "zero-less" 0<= n --- flag Local True if `n' is less than or equal to zero. 0<> n --- flag Local True if `n' is not equal to zero. 0= n --- flag 180 True if `n' is zero. "zero-equals" 0> n --- flag 118 True if `n' is greater than zero. "zero-greater" 0>= n --- flag local True if `n' is greater than or equal to 0. 0CR local Print a carriage-return without a line feed on the current output. 0INSTALL name_s mode --- blockno Unix-interface Install file in automatically allocated range of block numbers. The file with name `name_s' is opened with access mode `mode' and installed in the block mapping table. If mode = 2 (update) and the file is read permission only, will still be opened it but read-only rather than update. A range of block numbers large enough to fit the fill is automatically allocated. The beginning of this range of block numbers is returned on the parameter stack. It will first try the current directory. If that fails it will try the FORTH library directory (i.e. the directory defined by the string SDIR). If the file name begins with a '<' (i.e. a less-than symbol) the '<' character is stripped off and only the FORTH library directory is searched. If everything fails an abort is taken. NOTE: need to implement a search path. 0KEY Local Read one character from the keyboard, returning it on the stack. 0KEY is intended to be used preceded by <KEY and followed by KEY> . KEY , which reads one character from the keyboard and returns immediately without echoing it, is defined as: : KEY <KEY 0KEY KEY> ; In an operating system environment, when several characters are desired from the keyboard, it is cheaper to use (for example): <KEY 0KEY 0KEY 0KEY KEY> rather than: KEY KEY KEY 0TYPE addr n --- Local Transmit n characters beginning at `addr' to the output device pointed to by the user variable 0TYPER. This is essentially always one's own terminal. 0X! addr --- local,obsolescent Store zero at address `addr'. 1+ n --- n+1 107 Increment `n' by one, according to the operation + . "one-plus" 1+! addr --- Reference Add one to the word-length contents at addr. "one-plus-store" 1- n --- n-1 105 Decrement `n' by one, according to the operation - . " one-minus" 1-! addr --- Reference Subtract one from the word-length contents at `addr'. "one-minus-store" 1/X fl_f --- 1/fl_f floating Leaves the reciprocal of the floating point number `fl_f' on the floating point stack. 10I6 addr n --- local Print `n' single integers from array starting at address `addr', 10 numbers per line, room for 6 digits reserved in each number. 1FIX fl_f --- n floating Convert the floating point number `fl_f' to an integer by truncation toward zero, returning the result as the integer `n'. 1FLOAT n --- fl_f floating Convert integer `n' to a floating point number. 1INSTALL name_s mode --- descriptor size Unix-interface Checks whether the is room in the block mapping table for another file. Opens the file whose name is found on the string stack with access mode `mode'. Returns on parameter stack the file descriptor and the size in forth blocks (1024 bytes) of the newly open file. If `mode' is 2 (read/write) and the file has no write permission the file will be opened read/only. It will first try the current directory. If that fails it will try the FORTH library directory (i.e. the directory defined by the string SDIR). If the file name begins with a '<' (i.e. a less-than symbol) the '<' character is stripped off and only the FORTH library directory is searched. If everything fails an abort is taken. NOTE: need to implement a search path. 1RND fl_f --- n floating Convert the floating point number `fl_f' to an integer by rounding, returning the result as the integer `n'. 2! n_2 addr --- double_int Store `n_2' in a memory location at `addr' sufficient in size to hold a double integer. "two-store" 2* n --- 2*n reference Multiply `n' by 2. "two-times" 2+ n --- n+2 135 Increment `n' by two, according to the operation for +. "two-plus" 2+! addr --- Local Add two to the word-length contents at addr. "two-plus-store" 2- n --- n-2 129 Decrement `n' by two, according to the operation for -. "two-minus" 2-! addr --- Local Subtract two from the word-length contents at addr. "two-minus-store" 2->L n_2 --- m_l local Convert a double integer to an L-type (32 bit) number. An L-type number occupies the least number of stack cell elements that contain at least 32 bits. 2/ n --- n/2 reference Leave `n' divided by two. "two-divide" 2>R n_2 --- local Pop double integer `n_2' from the parameter stack and push it onto the return stack. 2@ addr --- n_2 double_int Leave on the stack the contents of the double integer beginning at `addr' "two-fetch". 2ASK --- num_2 flag local A number is read from the input stream up to the next trailing blank or tab and is returned on the stack as double length integer `num_2'. `flag' is false (0) if the number was valid and true (1) if the number was invalid. 2CONSTANT n_2 --- double_int A defining word used in the form: n_2 2CONSTANT <name> to create a dictionary entry for <name>, leaving `n_2' in its parameter field. When <name> is later executed, `n_2' will be left on the stack. "two-constant" 2DO i j n --- local,C Use in a colon-definition: 2DO . . . 2LOOP Begin a loop with two parallel incrementing counters that will repeat `n' times. The two counters are accessed inside the loop with the Forth words "I" and "J" and are initialized respectively by the values `i' and `j'. 2DROP n_2 --- double_int Drop the top double integer on the stack. "two-drop" 2DUP n_2 --- n_2 n_2 double_int Duplicate the top double integer on the stack. "two-dup" 2INSTALL blockno chan size --- Unix-interface Installs into the block mapping table an open file whose file descriptor is `chan' and whose size in 1024 byte forth blocks is `size' Thereafter any forth block number between `blockno' and `blockno'+size-1 will reference block 0 to block `size'-1 of this file. 2LITERAL d_2 --- I,local If compiling, then compile the double integer `d_l' as a double-integer literal, which, when later executed, will leave `d_l' on the stack. 2LOOP C,local Used in a colon-definition: 2DO . . . 2LOOP End a loop with two parallel counters, incrementing both if the loop is to repeat. 2LOVER n_2 m_l --- n_2 m_l n_2 local Leave a copy of the double integer `n_2' (below the L-type (32-bit) number `m_l') on top of the stack. 2LSWAP n_2 m_l --- m_l n_2 local Exchange the top two stack values with initially a double integer below and an L-type number (32 bit) above. 2NOVER n_2 m --- n_2 m n_2 local Leave a copy of the double integer `n_2' (below the single stack width number `m') on top of the stack. 2NSWAP n_2 m --- m n_2 local Exchange the top two stack values with initially a double integer below and a single integer above. 2OVER n1_2 n2_2 --- n1_2 n2_2 n1_2 double_int Leave a copy of the second double integer on the stack. "two-over" 2R> --- n_2 local Pop a double integer from the return stack and push it onto the parameter stack. 2ROT n1_2 n2_2 n3_3 --- n2_2 n3_2 n1_2 double_int Rotate the third double integer to the top of the stack. "two-rote" 2SHIFT n1_2 n --- n2_2 local Do an arithmetic shift of `n' bits on double integer `n1_2'. If `n' is positive do a left shift. If `n' is negative to a right arithmetic shift. 2SWAP n1_2 n2_2 --- n2_2 n1_2 double_int Exchange the top two double integers on the stack. "two-swap" 2VARIABLE double_int A defining word used in the form: 2VARIABLE <name> to create a dictionary entry of <name> and assign one double integer's worth of storage in the parameter field. When <name> is later executed, it will leave the address of the first byte of its parameter field on the stack. "two-variable" 4.2BSD --- local This dictionary entry exists only in a 4.2BSD system. Its existence can be tested for conditional compilation of 4.2BSD dependent features. 5F12.5 addr n --- local Print `n' floating point numbers from array starting at address `addr', 5 numbers per line, 5 digits after the decimal point. 5I12 addr n --- local Print `n' double integers from array starting at address `addr', 5 numbers per line, room for 12 digits reserved in each number. 79-STANDARD 119 Execute assuring that a FORTH-79 Standard system is available, otherwise an error condition exists. In this implementation types: "You Bet!". 8I6 addr n --- local Print `n' single integers from array starting at address `addr', 8 numbers per line, room for 6 digits reserved in each number. : 116 A defining word used in the form: : <name> . . . ; Select the CONTEXT vocabulary to be identical to CURRENT. Create a dictionary entry for <name> in CURRENT, and set compile mode. Words thus defined are called 'colon-definitions'. References to subsequent words from the input stream which are not immediate words are stored into the dictionary to be executed when <name> is later executed. IMMEDIATE words are executed as encountered. If a word is not found after a search of the CONTEXT and FORTH vocabularies, conversion and compilation of a literal number is attempted, with regard to the current BASE; that failing, an error condition exists. "colon" :> Local,I Switches from compiling higher lever Forth to compiling CODE. Sets CONTEXT to ASSEMBLER, clears compile mode, and, if necessary, compiles the code to do the context switch (unneccessary on the Vax). The definition can be ended normally with END-CODE. :> ... <: can be used to insert Code inside a colon definition (not recommended except in desparate circumstances). See <: ; I,C,196 Terminate a colon-definition and stop compilation. If compiling from storage and the input stream is exhausted before encountering ; an error condition exists. ;CODE C,I,206 Used in the form: : <name> . . . ;CODE Stop compilation and terminate a defining word <name>. ASSEMBLER becomes the CONTEXT vocabulary. When <name> is executed in the form: <name> <namex> to define the new <namex>, the execution address of <namex> will contain the address of the code sequence following the ;CODE in <name>. Execution of any <namex> will cause this machine code sequence to be executed. "semi-colon-code" ;S Reference Stop interpretation of a screen, resuming interpretation of previous input stream. For execution only. ;S will also terminate interpretation of a standard text file. "semi-es" < n1 n2 --- flag 139 True if n1 is less than n2. -32768 32767 < must return true. -32768 and 0 must be distinguished. "less-than" //go.sysin dd * made=TRUE if [ $made = TRUE ]; then /bin/chmod 644 ./doc/forth1 /bin/echo -n ' '; /bin/ls -ld ./doc/forth1 fi exit -- Bill Sebok Princeton University, Astrophysics {allegra,akgua,burl,cbosgd,decvax,ihnp4,kpno,princeton,vax135}!astrovax!wls