Dictionary


  1. Dictionary Maintenance
  2. Compilation and Execution Words
  3. Defining Words
  4. Control Structures
  5. Stack and Memory Operations
  6. Logic and Bit Manipulation Operations
  7. Arithmetic and Relational Operations
  8. Floating Point Functions
  9. Number Conversion
  10. Input and Output
  11. File Access
  12. Operating System Interface
  13. Miscellaneous

Stack diagram notation:

Data TypeStack Cells
aaddress1
nsigned single integer1
uunsigned single integer1
dsigned double length integer2
udunsigned double length integer2
bboolean flag: true or false (-1 or 0)1
fdouble precision floating point value2
^strcounted string address1


Word names shown in BOLDFACE are not standard in ANS Forth.



Dictionary Maintenance

FORGET -- remove the next word in the input stream and later words from the dictionary
COLD -- remove all non-intrinsic definitions from the dictionary
WORDS -- list the defined words in the dictionary
FIND ^str -- a flagsearch the dictionary for the word specified by the counted string;
flag is true if found and a is execution address


The word FORGET may be used to remove words from the dictionary. Typing

FORGET name


will remove name and all words defined after name from the dictionary.

The word COLD deletes all non-intrinsic definitions and strings, resets all stacks, and restarts the Forth environment in interpreter mode.


Compilation and Execution Words

IMMEDIATE -- set the precedence during compilation of the most recently defined word
NONDEFERRED -- set the precedence during interpretation of the most recently defined word
POSTPONE -- append the run-time semantics of the next word to the current definition
LITERALn | a -- compile a number or address on the stack into the current definition
' -- areturns the code field address (cfa) of the next word in the input stream
['] -- immediate version of ' for use inside a word definition
>BODYa1 -- a2convert the cfa of a word to its parameter field address (pfa)
COMPILE, a -- compile the execution semantics for the cfa of a word into the current definition
EXECUTEa -- execute a word with its cfa given on the stack
EVALUATEa u -- interpret and execute source code contained in a string
: -- create a new word definition and enter the compilation state
; --
[ -- enter interpretation state
] -- enter compilation state
STATE -- breturn true (-1) if compiling; false (0) otherwise


The words ' (TICK), and ['] may be used to search the dictionary for a specified word. These words behave according to the ANS Forth standard, and return an execution address on the stack. The word EXECUTE may be used to execute a word given the execution address on the stack. The word NONDEFERRED is a non-standard word which is used to set the enhanced precedence state of a word in kForth. For more information on the concept of precedence in kForth, refer to the Technical Information section of the user's guide.

The following standard compilation words are provided in Forth source in ans-words.4th and strings.4th:

2LITERALd -- compile a double number on the stack into the current definitionans-words.4th
SLITERALa u -- compile a string address and count from the stack into the current definitionstrings.4th
TO -- determine the body address of the next word and append the ans-words.4th
run-time semantics to store a value at that address



Defining Words

In addition to ordinary "colon definitions" of the form,

: NAME ... ;

the following defining words are also provided:

CREATE name
VARIABLE name
n CONSTANT name
FVARIABLE name
f FCONSTANT name

CREATE can be used inside a word definition to make your own defining words. The word DOES>, as part of a CREATE ... DOES> expression, allows you to specify the run time behavior of words created by the defining word.

The following common Forth defining words have source code definitions, provided in ans-words.4th:

n VALUE name
d 2CONSTANT name
2VARIABLE name
DEFER name



Control Structures

The following control structures are provided in kForth:

DO ... LOOP
DO ... +LOOP
?DO ... LOOP
?DO ... +LOOP
IF ... THEN
IF ... ELSE ... THEN
BEGIN ... AGAIN
BEGIN ... UNTIL
BEGIN ... WHILE ... REPEAT
CASE ... OF ... ENDOF ... ENDCASE

All control stuctures may be nested --- for DO loops the number of levels of nesting is only limited by return stack space. The following execution control words are also defined:

RECURSE
LEAVE
EXIT
QUIT
ABORT
ABORT"

RECURSE causes the currently executing word to be executed.

LEAVE removes the current loop parameters from the return stack, by calling UNLOOP, and causes an immediate jump out of the current loop. Execution resumes at the instruction following the loop.

EXIT causes an immediate return from the word currently being executed. Note that EXIT from within a loop requires that the loop parameters be discarded from the return stack explicitly with UNLOOP.

QUIT empties the return stack, terminates execution of the current word and returns kForth to the interpreter mode.

ABORT empties the data stack and executes QUIT.

ABORT" examines the flag on top of the stack and if the flag is true, prints the message delimited by ", then executes ABORT.

The exception handling words CATCH and THROW are defined in source in ans-words.4th.


Stack and Memory Operations

Allowed data stack operations are listed in the following table:

DUPn -- n nduplicate
?DUPn -- n n | 0 dup if not zero
SWAPn1 n2 -- n2 n1swap
OVERn1 n2 -- n1 n2 n1over
ROTn1 n2 n3 -- n2 n3 n1 rotate cw
-ROTn1 n2 n3 -- n3 n1 n2 rotate ccw
DROPn1 --drop
NIPn1 n2 -- n2nip
TUCKn1 n2 -- n2 n1 n2tuck
PICK... n -- ... m copy nth item deep
ROLL... n -- ... m rotate nth item deep to top of stack
DEPTH ... -- ... nstack depth
2DUPn1 n2 -- n1 n2 n1 n2
2SWAP n1 n2 n3 n4 -- n3 n4 n1 n2
2OVER n1 n2 n3 n4 -- n1 n2 n3 n4 n1 n2
2ROT n1 n2 n3 n4 n5 n6 -- n3 n4 n5 n6 n1n2
2DROP n1 n2 --
FDUPf -- f f same as 2DUP
FSWAP f1 f2 -- f2 f1 same as 2SWAP
FOVER f1 f2 -- f1 f2 f1 same as 2OVER
FROT f1 f2 f3 -- f2 f3 f1 same as 2ROT
FDROP f1 -- same as 2DROP

Return stack operations are:

>R n -- push onto return stack
R> -- n pop from return stack
R@ -- n copy from top of return stack
2>R d -- push two stack cells onto return stack
2R> -- d pop two cells from return stack
2R@ -- d copy two cells from top of return stack
I-- ncurrent loop index
J-- nnext outer loop index
UNLOOP -- discard loop parameters from return stack

Note that 2>R is not equivalent to the sequence >R >R. The order of the two single length elements on top of the return stack is different for the two cases. 2>R pushes two items from the top of the stack so that they have the same order on the return stack. The sequence 2>R 2R>, however, is identical to the sequence >R >R R> R>.

The following memory access words are implemented:

@a -- nfetch single
!n a -- store single n to address a
2@a -- d fetch double number from address a
2!d a -- store double number to address a
A@a1 -- a2 fetch address from address a
C@a -- n fetch byte
C! n a --store byte
W@a -- n fetch signed word
W!n a --store signed word
SF@a -- f fetch single precision float
SF!f a -- store f as single precision float
DF@a -- f fetch double precision float
DF!f a -- store double precision float
F@a -- f same as DF@
F!f a -- same as DF!
SP@-- a fetch data stack pointer
RP@-- a fetch return stack pointer
SP!a -- set data stack pointer
RP!a -- set return stack pointer
?a -- fetch and print single; equivalent to @ .
ALLOTu -- allocates u bytes in the dictionary
?ALLOTu -- a allocates u bytes in the dictionary and returns
starting address of the allocated region
ALLOCATEu -- a n reserve u bytes of system memory and return starting
address of the allocated region and error code
FREEa -- n release memory previously reserved with ALLOCATE
and return error code (0 = success)
C" -- ^str compile a counted string into the string table;
the string is taken from the input stream and
must be terminated by "
S" -- a u compile a string and return address and count
COUNT^str -- a u convert counted string address to character
buffer address a and character count u
CMOVEa1 a2 u -- move u bytes from source a1 to dest a2
CMOVE>a1 a2 u -- move u bytes from a1 to a2 in descending order
FILLa n1 n2 -- fill n1 bytes with byte value n2 starting at a
ERASEa n -- fill n bytes with zero starting at a
SEARCHa1 u1 a2 u2 -- a3 u3 b search for the string a2 u2 within the string a1 u1;
return true if found and the substring a3 u3
COMPAREa1 u1 a2 u2 -- n compare the strings a1 u1 and a2 u2. Return zero if they are equal.

The following standard memory words are provided in Forth source in ans-words.4th, strings.4th, and dump.4th:

PAD -- a return address of a scratch-pad in memory for temporary useans-words.4th
MOVEa1 a2 u -- move u bytes from source a1 to dest a2; handle overlapping region ans-words.4th
BLANKa u -- fill u bytes with the blank-space character starting at address 'a' strings.4th
DUMPa u -- output a hexadecimal display of the u bytes starting at address 'a' dump.4th

Since kForth uses the data stack for floating point operations, the words DF@ and F@ are equivalent to 2@, and DF! and F! are equivalent to 2!.

The non-ANS standard word A@ is needed because kForth performs type checking for operands involved in memory access. It is essentially identical to @ except the type field is set to be an address for the retrieved value. Addresses may be stored in ordinary variables using !; however they should be retrieved with A@.

The behavior of ALLOT does not conform exactly to the ANS standard. ALLOT dynamically allocates the requested amount of memory and sets the parameter field address (PFA) of the last created word to the address of the alloted region. Thus, ALLOT should always be preceeded by CREATE. In kForth, an attempt to ALLOT without first creating a named dictionary entry, using CREATE, will result in a virtual machine error. Thus kForth limits the use of ALLOT, but code written for kForth will be portable to ANS Forths.

The non-ANS standard word ?ALLOT is provided because kForth contains no HERE address. ?ALLOT should be preceeded by CREATE as described above. All memory is dynamically allocated, and freed upon exiting kForth.


Logic and Bit Manipulation Operations


ANDn1 n2 -- n3 bitwise AND of n1 and n2
ORn1 n2 -- n3 bitwise OR of n1 and n2
XORn2 n2 -- n3 bitwise exclusive OR of n1 and n2
NOTn1 -- n2 one's complement of n1
INVERTn1 -- n2 same as NOT
LSHIFTn1 n2 -- n3 n3 is n1 shifted left by n2 bits
RSHIFTn1 n2 -- n3 n3 is n1 shifted right by n2 bits


Arithmetic and Relational Operations

Single and Double Integer Operations

1+n1 -- n2 increment (n2 = n1 + 1)
1-n1 -- n2decrement (n2 = n1 - 1)
2+n1 -- n2n2 = n1 + 2
2-n1 -- n2n2 = n1 - 2
2*n1 -- n2arithmetic left shift (n2 = n1*2)
2/n1 -- n2arithmetic right shift (n2 = n1/2)
CELLSn1 -- n2 n2 is n1 times size in bytes of a cell (4)
CELL+n1 -- n2 n2 is n1 plus the size in bytes of a cell
DFLOATSn1 -- n2 n2 is n1 times size of a floating point number
DFLOAT+n1 -- n2 n2 is n1 plus the size of a floating point number
SFLOATSn1 -- n2 same as CELLS
SFLOAT+n1 -- n2 same as CELL+
CHAR+n1 -- n2 same as 1+
+n1 n2 -- n3add
-n1 n2 -- n3subtract (n3 = n1 - n2)
*n1 n2 -- n3multiply
/n1 n2 -- n3divide ( n3 = n1/n2)
+!n a -- add n to value at address a
MODn1 n2 -- n3 modulus or remainder
/MODn1 n2 -- n3 n4 n3 = remainder and n4 = quotient for n1/n2
*/n1 n2 n3 -- n4 n4 = n1*n2/n3; intermediate value is 64 bit
*/MODn1 n2 n3 -- n4 n5 n4 and n5 are remainder and quotient for n1*n2/n3
M+d1 n -- d2 add single to double integer
M*n1 n2 -- d multiply two singles and return signed double
UM*u1 u2 -- ud multiply unsigned singles and return unsigned double
UM/MODud u1 -- u2 u3 divide unsigned double number by unsigned single
and return remainder (u2) and quotient (u3).
Returns -1 -1 for u2 and u3 on division overflow
FM/MODd n1 -- n2 n3 divide double by single to give floored quotient n3 and modulus n2
SM/REMd n1 -- n2 n3 divide double by single to give symmetric quotient n3 and remainder n2
D+d1 d2 -- d3 double number addition
D-d1 d2 -- d3 double number subtraction
ABSn1 -- n2 absolute value
NEGATEn1 -- n2 n2 = -n1
DABSd1 -- d2 double number absolute value
DNEGATEd1 -- d2 double number negation
MINn1 n2 -- n1 | n2 minimum of n1 and n2
MAXn1 n2 -- n1 | n2 maximum of n1 and n2
=n1 n2 -- btest n1 equal to n2
<>n1 n2 -- b test n1 not equal to n2
<n1 n2 -- b test n1 less than n2
>n1 n2 -- b test n1 greater than n2
<=n1 n2 -- b test n1 less than or equal to n2
>=n1 n2 -- b test n1 greater than or equal to n2
U<u1 u2 -- b test unsigned u1 less than u2
U>u1 u2 -- b test unsigned u1 greater than u2
D=d1 d2 -- b test d1 equal to d2
D<d1 d2 -- b test d1 less than d2
0<n -- b test n less than zero
0>n -- btest n greater than zero
0=n -- btest n equal to zero
0<>n -- btest n not equal to zero
D0=d -- b test d equal to zero

kForth provides pre-defined constants TRUE (-1) and FALSE (0).

The following standard arithmetic and relational operations are provided in Forth source in ans-words.4th:

D2*d1 -- d2 d2 is the arithmetic left shift of d1 ans-words.4th
D2/d1 -- d2 d2 is the arithmetic right shift of d1ans-words.4th
DMINd1 d2 -- d1|d2 minimum of d1 and d2ans-words.4th
DMAXd1 d2 -- d1|d2 maximum of d1 and d2ans-words.4th
WITHINn1|u1 n2|u2 n3|u3 -- b return TRUE if n2|u2 <= n1|u1 < n3|u3, given n2|u2 < n3|u3ans-words.4th

Floating Point Operations

F+f1 f2 -- f3fadd
F-f1 f2 -- f3fsubtract (f3 = f1 - f2)
F*f1 f2 -- f3fmultiply
F/f1 f2 -- f3fdivide ( f3 = f1/f2)
FABSf1 -- f2absolute value
FNEGATEf1 -- f2f2 = -f1
FROUNDf1 -- f2round to nearest whole number
FTRUNCf1 -- f2 truncate, towards zero, to whole number
FLOORf1 -- f2truncate, towards minus infinity, to whole number
FMINf1 f2 -- f1 | f2 minimum of f1 and f2
FMAXf1 f2 -- f1 | f2 maximum of f1 and f2
F0=f -- btest f equal to zero
F0<f -- btest f less than zero
F=f1 f2 -- btest f1 equal to f2
F<>f1 f2 -- b test f1 not equal to f2
F<f1 f2 -- b test f1 less than f2
F>f1 f2 -- b test f1 greater than f2
F<=f1 f2 -- b test f1 less than or equal to f2
F>=f1 f2 -- b test f1 greater than or equal to f2


The following standard word is provided as Forth source in ans-words.4th:

F~ f1 f2 f3 -- b test f1 approximately equal to f2, within uncertainty f3;ans-words.4th
if f3 = 0e, f1 and f2 must be exactly equal in their binary representation



Floating Point Functions


F**f1 f2 -- f3 f3 = f1 raised to power of f2
FSQRTf1 -- f2 square root
FLOGf1 -- f2 f2 = log base 10 of f1
FEXPf1 -- f2 f2 = exp(f1)
FLNf1 -- f2 f2 = log base e of f1
DEG>RADf1 -- f2 degrees to radians
RAD>DEGf1 -- f2 radians to degrees
FSINf1 -- f2f2 = sin(f1)
FCOSf1 -- f2f2 = cos(f1)
FSINCOSf1 -- f2 f3 f2 = sin(f1); f3 = cos(f1)
FTANf1 -- f2f2 = tan(f1)
FASINf1 -- f2 arc sine
FACOSf1 -- f2 arc cosine
FATANf1 -- f2 arc tangent
FATAN2f1 f2 -- f3 f3 is arc tangent of f1/f2
FSINHf1 -- f2f2 = sinh(f1)
FCOSHf1 -- f2f2 = cosh(f1)
FTANHf1 -- f2f2 = tanh(f1)
FASINHf1 -- f2 inverse hyperbolic sine
FACOSHf1 -- f2 inverse hyperbolic cosine
FATANHf1 -- f2 inverse hyperbolic tangent


Number Conversion


S>Dn -- d convert single integer to double length integer
D>Sd -- n convert signed double integer to signed integer
S>Fn -- f convert single integer to floating point number
D>Fd -- f convert double length integer to fp number
F>Sf -- n DISCONTINUED (see below)
FROUND>Sf -- n convert floating point to integer by rounding
FTRUNC>Sf -- n convert floating point to integer by truncating towards zero
F>Df -- d convert fp number to double integer by truncating towards zero
NUMBER?^str -- d b convert counted string to signed double number
b is TRUE if successfull
<#ud -- ud begin conversion of unsigned double to a string
#ud1 -- ud2 convert the least significant digit of ud1 to a character;
concatenate character to conversion string.
#Sud1 -- 0 0 convert all significant digits in ud1 to string
SIGNn -- attach minus sign to conversion string if n < 0
HOLDn -- attach character with ASCII code n to the conversion string
#>ud -- a u drop the double number and return the string address and count


The following standard conversion words are provided as Forth source in ans-words.4th:

>NUMBER ud1 a1 u1 -- ud2 a2 u2 convert one digit of string a1 u1 and add this number to ud1*base;ans-words.4th
result is ud2 and a2 u2 point to next character in the string


The word F>S has been removed from kForth, as of version 1.0.14, due to its inconsistent implementations in existing Forth systems. There are two common requirements for converting a floating point number to an integer: rounding and truncating towards zero. Two separate words are provided for these two distinct functions: FROUND>S and FTRUNC>S. In versions of kForth, prior to 1.0.14, the word F>S had the same meaning as FROUND>S.

Currently NUMBER? may only be used to translate a counted string into number that is within the bounds of a single length number. The returned double number may be converted to a single length number by dropping the top half of the returned double number.

Other useful conversion words for number to string conversion and vice-versa are given in Forth source in strings.4th:

U>STRING u -- ^str converted unsigned integer to counted string in base 10 strings.4th
UD>STRINGud -- ^str convert unsigned double integer to counted string in base 10strings.4th
D>STRINGd -- ^str convert signed double integer to counted string in base 10 strings.4th
S>STRINGn -- ^str convert signed integer to counted string in base 10 strings.4th
STRING>S^str -- n convert counted string to signed integer; always interpret in base 10strings.4th
F>STRINGf n -- ^str convert floating point to counted string represented in exponential format with n placesstrings.4th
STRING>F^str -- f convert counted string to a floating point number strings.4th
PARSE_ARGSa u -- f1 ... fn n parse a string delimited by spaces into sequence of n floating point numbersstrings.4th

Input and Output


BASE -- a return the address containing current number base
DECIMAL -- set the number base to ten
BINARY -- set the number base to two
HEX -- set the number base to sixteen
KEY -- n wait for key press and return key code
ACCEPTa n1 -- n2 read up to n1 characters into buffer a
from keyboard. n2 is actual number input.
BL -- 32 return the ascii value for a blank space character
WORDn -- ^str parse a word from the input stream, delimited by
character with ascii value n and return
the address of a counted string containing the word
CHAR -- n parse the next word, delimited by a space and return
the ascii value of its first character
[CHAR] -- n version of CHAR for use in compile state
.n -- display top item on the stack in the current base
.Rn m -- display n in the current base in m-wide field
U.u -- display unsigned single in current base
U.Ru m -- display u in the current base in m-wide field
D.d -- display signed double length number
F.f -- display the floating point value on top of the stack
.Sn1 n2 ... -- n1 n2 ... non-destructive display of the stack
." -- display text message; the message is read from
the input stream and must be terminated by "
.( -- display text message from input stream; message
is terminated by ')'. The word is executed immediately.
CR -- output carriage return
SPACESn -- output n spaces
EMITn -- output character with ascii value n
TYPEa n -- display n characters from buffer at a
SOURCE -- a u return address and count of the input buffer
REFILL -- b attempt to read another line from the input source and return flag
>FILE -- change output stream from the console to a file.
The filename is the next word in the input stream
CONSOLE -- reset output stream to the console


The following terminal control words for ANSI terminals are provided in Forth source in ansi.4th:

PAGE -- clear the screen and put cursor at top left ansi.4th
AT-XYn1 n2 -- position cursor at column n1 and row n2, origin is (0,0) ansi.4th
?AT-XY -- n1 n2 return cursor's current column and row ansi.4th
GOTOXYn1 n2 -- position cursor at column n1 and row n2, origin is (1,1) ansi.4th
ROWS -- n return row size of console ansi.4th
COLS -- n return column size of console ansi.4th
CLRTOEOL -- clear to end of lineansi.4th
CUR_UP n -- move the cursor up by n linesansi.4th
CUR_DOWN n -- move the cursor down by n linesansi.4th
CUR_LEFT n -- move the cursor left by n columnsansi.4th
CUR_RIGHT n -- move the cursor right by n columnsansi.4th
SAVE_CURSOR -- save the current cursor positionansi.4th
RESTORE_CURSOR -- restore the cursor to the previously saved positionansi.4th
FOREGROUND n -- set the foreground color to n (in the range 0--7)ansi.4th
BACKGROUND n -- set the background color to n (in the range 0--7)ansi.4th
TEXT_NORMAL -- restore the default text attributesansi.4th
TEXT_BOLD -- set bold textansi.4th
TEXT_UNDERLINE -- set underlined textansi.4th
TEXT_BLINK -- set blinking textansi.4th
TEXT_REVERSE -- set reverse video textansi.4th


File Access


OPEN ^name n1 -- n2 open file specified by counted string ^name
in mode n1, which can be the following:
0 read-only (R/O)
1 write-only (W/O)
2 read-write (R/W)
n2 is the file descriptor, a non-negative
integer if successful.
LSEEKn1 n2 n3 -- n4 change current position in opened file
n1 is the file descriptor
n2 is the offset, and
n3 is the mode with the following meaning:
0 offset is relative to start of file
1 offset is relative to current position
2 offset is relative to end of file
n4 is the resulting offset from the
beginning of the file, or -1 if error.
READn1 a n2 -- n3 read n2 bytes into buffer address a, from
file with descriptor n1.
n3 is the number of bytes actually read.
WRITEn1 a n2 -- n3 write n2 bytes from buffer address a to
file with descriptor n1.
n3 is the number of bytes actually written.
CLOSEn1 -- n2 close file with descriptor n1 and return
status n2 (0 if successful, -1 if error).
INCLUDE -- read and process the specified Forth source file

The following ANS standard file access words are provided as Forth definitions in files.4th (Linux) and filesw.4th (Win95/98/NT/2000/XP):

R/O -- n "read-only" file access method files.4th and filesw.4th
W/O -- n "write-only" file access method files.4th and filesw.4th
R/W -- n "read-write" file access method files.4th and filesw.4th
CREATE-FILE a u n1 -- n2 n3 create a file with name specified by string address and count a u,files.4th and filesw.4th
and access method n1. Return file descriptor n2 and result code n3
INCLUDED a u -- ? set the input stream for the interpreter to the files.4th and filesw.4th
specified file and process it line by line
OPEN-FILE a u n1 -- n2 n3 open an existing file and return file descriptor n2 and result code n3 files.4th and filesw.4th
CLOSE-FILE n1 -- n2close the file with descriptor n1 and return result code n2files.4th and filesw.4th
READ-FILE a u1 n1 -- u2 n2 read u1 bytes into buffer at address 'a' from file with descriptor n1files.4th and filesw.4th
and return actual number of bytes read u2 and result code n2
WRITE-FILE a u n1 -- n2write u bytes from buffer 'a' to file with descriptor n1; return result code n2files.4th and filesw.4th
FILE-POSITION n1 -- ud n2return the current file position ud and result code n2files.4th and filesw.4th
REPOSITION-FILE ud n1 -- n2 set file position to ud for file with descriptor n1 and return result code n2files.4th and filesw.4th
FILE-SIZE n1 -- ud n2 return the size of the file ud and the result code n2 files.4th and filesw.4th
FILE-EXISTS ^str -- b return TRUE if the specified file exists files.4th and filesw.4th
DELETE-FILE a u -- n delete the file specified by string a u, and return result code nfiles.4th
READ-LINE a u1 n1 -- u2 b n2 read a line of text, with at most u1 bytes, from file with descriptor n1files.4th and filesw.4th
into the buffer 'a'; return actual bytes read u2, success flag, and result code n2
WRITE-LINE a u n1 -- n2 write a line of text having u bytes from buffer 'a' into file files.4th and filesw.4th
with descriptor n1, and return result code n2


Operating System Interface


SYSTEM^str -- n execute another process; ^str is the command line passed
to the operating system. n is the return code
and is OS dependent.
BYE -- close the Forth environment and exit to the system.
CHDIR^path -- n change the current directory to the one specified in
the counted string ^path; n is OS dependent return code
IOCTLn1 n2 a -- n3 send device control request n2 to file
with descriptor n1. Additional parameters
are passed through buffer at address a.
n3 is the status (0 if successful, -1 if error).
TIME&DAY -- sec min hr day mo yr return the local time
MSu -- wait for at least u milliseconds
MS@ -- u return number of milliseconds elapsed since start of kForth
FORTH-SIGNALa n -- aold install Forth word as handler for signal n
RAISEn -- ior assert signal n
SET-ITIMERn1 a1 a2 -- n2 set up timer signals
GET-ITIMERn a -- n2 get timer countdown count
USLEEPu -- wait for at least u microseconds
(For Windows version, resolution is 1000)


Miscellaneous


CALLa -- call machine language subroutine at address a


    

Copyright © 1998--2005 Creative Consulting for Research and Education