core wordset

description

CORE-EXT -- The standard CORE and CORE-EXT wordset

Copyright (C) Tektronix, Inc. 1998 - 2001. All rights reserved.

description: The Core Wordset contains the most of the essential words for ANS Forth.

FORTH

! ( val addr -- )();
p4:"store";

store value at addr (sizeof CELL)

dpANS .6.1.0010 - standard forth word

FORTH

# ( n.n -- n.n' )();
p4:"sh";

see also HOLD for old-style forth-formatting words and PRINTF of the C-style formatting - this word divides the argument by BASE and add it to the picture space - it should be used inside of <# and #>

dpANS .6.1.0030 - standard forth word

FORTH
#> ( n.n -- str-addr str-len )(); 
 ;

see also HOLD for old-style forth-formatting words and PRINTF of the C-style formatting - this word drops the argument and returns the picture space buffer

FORTH

#S ( n.n -- n.n )f();
p4:"sh-s";

see also HOLD for old-style forth-formatting words and PRINTF of the C-style formatting - this word does repeat the word # for a number of times, until the argument becomes zero. Hence the result is always null - it should be used inside of <# and #>

dpANS .6.1.0050 - standard forth word

FORTH
( ( 'comment<closeparen>' -- )(); 
 ;

eat everything up to the next closing paren - treat it as a comment.

dpANS 11.6.1.0080 - standard forth word

FORTH

* ( a b -- a*b )();
p4:"star";

return the multiply of the two args

dpANS .6.1.0090 - standard forth word

FORTH

*/ ( a b c -- a*b/c )();
p4:"star-slash";

regard the b/c as element Q - this word has an advantage over the sequence of * and / by using an intermediate double-cell value

dpANS .6.1.0100 - standard forth word

FORTH
*/MOD ( a b c -- m n )(); 
 ;

has an adavantage over the sequence of * and /MOD by using an intermediate double-cell value.

dpANS .6.1.0110 - standard forth word

FORTH

+ ( a b -- a+b )();
p4:"plus";

return the sum of the two args

dpANS .6.1.0120 - standard forth word

FORTH

+! ( val addr -- )();
p4:"plus-store";

add val to the value found in addr

 simulate:
   : +! TUCK @ + SWAP ! ;
 

dpANS .6.1.0130 - standard forth word

FORTH

+LOOP ( increment -- )();
p4:"plus-loop";

compile ((+LOOP)) which will use the increment as the loop-offset instead of just 1. See the DO and LOOP construct.

dpANS .6.1.0140 - standard forth word

FORTH

, ( val -- )();
p4:"comma";

store the value in the dictionary

 simulate:
   : , DP  1 CELLS DP +!  ! ;
 

dpANS .6.1.0150 - standard forth word

FORTH

- ( a b -- a-b )();
p4:"minus";

return the difference of the two arguments

dpANS .6.1.0160 - standard forth word

FORTH

. ( val -- )();
p4:"dot";

print the numerical value to stdout - uses BASE

dpANS .6.1.0180 - standard forth word

FORTH

." ( [string<">] -- )();
p4:"dot-quote";

print the string to stdout

dpANS .6.1.0190 - standard forth word

FORTH

/ ( a b -- a/b )();
p4:"slash";

return the quotient of the two arguments

dpANS .6.1.0230 - standard forth word

FORTH

/MOD ( a b -- m n )();
p4:"slash-mod";

divide a and b and return both quotient n and remainder m

dpANS .6.1.0240 - standard forth word

FORTH

0< ( val -- cond )();
p4:"zero-less";

return a flag that is true if val is lower than zero

 simulate:
  : 0< 0 < ;
 
FORTH

0= ( val -- cond )();
p4:"zero-equal";

return a flag that is true if val is just zero

 simulate:
  : 0= 0 = ;
 

dpANS .6.1.0270 - standard forth word

FORTH

1+ ( val -- val+1 )();
p4:"one-plus";

return the value incremented by one

 simulate:
  : 1+ 1 + ;
 

dpANS .6.1.0290 - standard forth word

FORTH

1- ( val -- val-1 )();
p4:"one-minus";

return the value decremented by one

 simulate:
   : 1- 1 - ;
 

dpANS .6.1.0300 - standard forth word

FORTH

2! ( a,a addr -- )();
p4:"two-store";

double-cell store

dpANS .6.1.0310 - standard forth word

FORTH

2* ( a -- a*2 )();
p4:"two-star";

multiplies the value with two - but it does actually use a shift1 to be faster

 simulate:
  : 2* 2 * ; ( canonic) : 2* 1 LSHIFT ; ( usual)
 

dpANS .6.1.0320 - standard forth word

FORTH

2/ ( a -- a/2 )();
p4:"two-slash";

divides the value by two - but it does actually use a shift1 to be faster

 simulate:
  : 2/ 2 / ; ( canonic) : 2/ 1 RSHIFT ; ( usual)
 

dpANS .6.1.0330 - standard forth word

FORTH

2@ ( addr -- a,a )();
p4:"two-fetch";

double-cell fetch

dpANS .6.1.0350 - standard forth word

FORTH

2DROP ( a b -- )();
p4:"two-drop";

double-cell drop, also used to drop two items

dpANS .6.1.0370 - standard forth word

FORTH

2DUP ( a,a -- a,a a,a )();
p4:"two-dup";

double-cell duplication, also used to duplicate two items

 simulate:
   : 2DUP OVER OVER ; ( wrong would be : 2DUP DUP DUP ; !!) 
 

dpANS .6.1.0380 - standard forth word

FORTH
2OVER ( a,a b,b -- a,a b,b a,a )(); 
 ;

double-cell over, see OVER and 2DUP

 simulate:
   : 2OVER SP@ 2 CELLS + 2@ ;
 

dpANS .6.1.0400 - standard forth word

FORTH
2SWAP ( a,a b,b -- b,b a,a )(); 
 ;

double-cell swap, see SWAP and 2DUP

 simulate:
   : 2SWAP LOCALS| B1 B2 A1 A2 | B2 B1 A2 A1 ;
 

dpANS .6.1.0430 - standard forth word

FORTH

: ( 'name' -- )();
p4:"colon";

create a header for a nesting word and go to compiling mode then. This word is usually ended with ; but the execution of the resulting colon-word can also return with EXIT

dpANS .6.1.0450 - standard forth word

FORTH

; ( -- )();
p4:"semicolon";

compiles ((;)) which does EXIT the current colon-definition. It does then end compile-mode and returns to execute-mode. See : and :NONAME

dpANS .6.1.0460 - standard forth word

FORTH

< ( a b -- cond )();
p4:"less-than";

return a flag telling if a is lower than b

dpANS .6.1.0480 - standard forth word

FORTH

<# ( -- )();
p4:"less-sh";

see also HOLD for old-style forth-formatting words and PRINTF of the C-style formatting - this word does initialize the pictured numeric output space.

dpANS .6.1.0490 - standard forth word

FORTH

= ( a b -- cond )();
p4:"equals";

return a flag telling if a is equal to b

dpANS .6.1.0530 - standard forth word

FORTH

> ( a b -- cond )();
p4:"greater-than";

return a flag telling if a is greater than b

FORTH

>BODY ( addr -- addr' )();
p4:"to-body";

adjust the execution-token (ie. the CFA) to point to the parameter field (ie. the PFA) of a word. this is not a constant operation - most words have their parameters at "1 CELLS +" but CREATE/DOES-words have the parameters at "2 CELLS +" and ROM/USER words go indirect with a rom'ed offset i.e. "CELL + @ UP +"

FORTH

>IN ( .. )();
as:"back-in";

threadstate variable >IN

input.to_in (no special usage info)

FORTH
>NUMBER ( a,a str-adr str-len -- a,a' str-adr' str-len)(); 
 ;

try to convert a string into a number, and place that number at a,a respeciting BASE

FORTH

>R ( value -- )();
p4:"to-r";

save the value onto the return stack. The return stack must be returned back to clean state before an exit and you should note that the return-stack is also touched by the DO ... WHILE loop. Use R> to clean the stack and R@ to get the last value put by >R

FORTH
?DUP ( value -- value|[nothing] )(); 
 ;

one of the rare words whose stack-change is condition-dependet. This word will duplicate the value only if it is not zero. The usual place to use it is directly before a control-word that can go to different places where we can spare an extra DROP on the is-null-part. This makes the code faster and often a little easier to read.

 example:
   : XX BEGIN ?DUP WHILE DUP . 2/ REPEAT ; instead of
   : XX BEGIN DUP WHILE DUP . 2/ REPEAT DROP ;
 

dpANS .6.1.0630 - standard forth word

FORTH

@ ( addr -- value )();
p4:"fetch";

fetch the value from the variables address

dpANS .6.1.0650 - standard forth word

FORTH

ABS ( value -- value' )();
p4:"abs";

return the absolute value

dpANS .6.1.0690 - standard forth word

FORTH

ACCEPT ( a n -- n' )();
p4:"accept";

get a string from terminal into the named input buffer, returns the number of bytes being stored in the buffer. May provide line-editing functions.

dpANS .6.1.0695 - standard forth word

FORTH

ALIGN ( -- )();
p4:"align";

will make the dictionary aligned, usually to a cell-boundary, see ALIGNED

dpANS .6.1.0705 - standard forth word

FORTH

ALIGNED ( addr -- addr' )();
p4:"aligned";

uses the value (being usually a dictionary-address) and increment it to the required alignment for the dictionary which is usually in CELLS - see also ALIGN

dpANS .6.1.0706 - standard forth word

FORTH

ALLOT ( count -- )();
p4:"allot";

make room in the dictionary - usually called after a CREATE word like VARIABLE or VALUE to make for an array of variables. Does not initialize the space allocated from the dictionary-heap. The count is in bytes - use CELLS ALLOT to allocate a field of cells.

dpANS .6.1.0710 - standard forth word

FORTH

AND ( val mask -- val' )();
p4:"and";

mask with a bitwise and - be careful when applying it to logical values.

dpANS .6.1.0720 - standard forth word

FORTH

BASE ( .. )();
as:"base";

threadstate variable BASE

base (no special usage info)

dpANS .6.1.0750 - standard forth word

FORTH
BEGIN ( -- )compile-time: ( -- cs-marker )(); 
 ;

start a control-loop, see WHILE and REPEAT

dpANS .6.1.0760 - standard forth word

FORTH

BL ( .. )();
as:"bl";

( ' ' )  constant BL

an ordinary constant (no special usage info)

dpANS .6.1.0770 - standard forth word

FORTH

C! ( value address -- )();
p4:"c-store";

store the byte-value at address, see !

dpANS .6.1.0850 - standard forth word

FORTH

C, ( value -- )();
p4:"c-comma";

store a new byte-value in the dictionary, implicit 1 ALLOT, see ,

dpANS .6.1.0860 - standard forth word

FORTH

C@ ( addr -- value )();
p4:"c-fetch";

fetch a byte-value from the address, see @

dpANS .6.1.0870 - standard forth word

FORTH

CELL+ ( value -- value' )();
p4:"cell-plus";

adjust the value by adding a single Cell's width - the value is often an address or offset, see CELLS

dpANS .6.1.0880 - standard forth word

FORTH

CELLS ( value -- value' )();
p4:"cells";

scale the value by the sizeof a Cell the value is then often applied to an address or fed into ALLOT

dpANS .6.1.0890 - standard forth word

FORTH

CHAR ( 'word' -- value )();
p4:"char";

return the (ascii-)value of the following word's first character.

dpANS .6.1.0895 - standard forth word

FORTH

CHAR+ ( value -- value' )();
p4:"char-plus";

increment the value by the sizeof one char - the value is often a pointer or an offset, see CHARS

dpANS .6.1.0897 - standard forth word

FORTH

CHARS ( value -- value' )();
p4:"chars";

scale the value by the sizeof a char - the value is then often applied to an address or fed into ALLOT (did you expect that sizeof(p4char) may actually yield 2 bytes?)

dpANS .6.1.0898 - standard forth word

FORTH
CONSTANT ( value 'name' -- )(); 
 ;

CREATE a new word with runtime ((CONSTANT)) so that the value placed here is returned everytime the constant's name is used in code. See VALUE for constant-like names that are expected to change during execution of the program. In a ROM-able forth the CONSTANT-value may get into a shared ROM-area and is never copied to a RAM-address.

dpANS .6.1.0950 - standard forth word

FORTH
COUNT ( counted-string -- string-pointer string-length )(); 
 ;

usually before calling TYPE

(as an unwarranted extension, this word does try to be idempotent).

dpANS .6.1.0980 - standard forth word

FORTH

CR ( -- )();
p4:"cr";

print a carriage-return/new-line on stdout

dpANS .6.1.0990 - standard forth word

FORTH

DECIMAL ( -- )();
p4:"decimal";

set the BASE to 10

 simulate:
   : DECIMAL 10 BASE ! ;
 

dpANS .6.1.1170 - standard forth word

FORTH

DEPTH ( -- value )();
p4:"depth";

return the depth of the parameter stack before the call, see SP@ - the return-value is in CELLS

dpANS .6.1.1200 - standard forth word

FORTH

DO ( end start -- )... LOOP();
p4:"do";

pushes $end and $start onto the return-stack ( >R ) and starts a control-loop that ends with LOOP or +LOOP and may get a break-out with LEAVE . The loop-variable can be accessed with I

dpANS .6.1.1240 - standard forth word

FORTH

DOES> ( -- pfa )();
p4:"does";

does twist the last CREATE word to carry the (DOES>) runtime. That way, using the word will execute the code-piece following DOES> where the pfa of the word is already on stack. (note: FIG option will leave pfa+cell since does-rt is stored in pfa)

FORTH

DROP ( a -- )();
p4:"drop";

just drop the word on the top of stack, see DUP

dpANS .6.1.1260 - standard forth word

FORTH

DUP ( a -- a a )();
p4:"dup";

duplicate the cell on top of the stack - so the two topmost cells have the same value (they are equal w.r.t = ) , see DROP for the inverse

dpANS .6.1.1290 - standard forth word

FORTH

ELSE ( -- )();
p4:"else";

will compile an ((ELSE)) BRANCH that performs an unconditional jump to the next THEN - and it resolves an IF for the non-true case

dpANS .6.1.1310 - standard forth word

FORTH

EMIT ( char -- )();
p4:"emit";

print the char-value on stack to stdout

dpANS .6.1.1320 - standard forth word

FORTH
ENVIRONMENT? ( a1 n1 -- false | ?? true )(); 
 ;

check the environment for a property, usually a condition like questioning the existance of specified wordset, but it can also return some implementation properties like "WORDLISTS" (the length of the search-order) or "#LOCALS" (the maximum number of locals)

Here it implements the environment queries as a SEARCH-WORDLIST in a user-visible vocabulary called ENVIRONMENT

 : ENVIRONMENT?
   ['] ENVIRONMENT >WORDLIST SEARCH-WORDLIST
   IF  EXECUTE TRUE ELSE  FALSE THEN ;
 

dpANS .6.1.1345 - standard forth word

FORTH
EVALUATE ( str-ptr str-len -- )(); 
 ;

INTERPRET the given string, SOURCE id is -1 during that time.

dpANS 7.6.1.1360 - standard forth word

FORTH

EXECUTE ( xt -- )();
p4:"execute";

run the execution-token on stack - this will usually trap if it was null for some reason, see >EXECUTE

 simulate:
  : EXECUTE >R EXIT ;
 

dpANS .6.1.1370 - standard forth word

FORTH

EXIT ( -- )();
p4:"exit";

will unnest the current colon-word so it will actually return the word calling it. This can be found in the middle of a colon-sequence between : and ;

dpANS .6.1.1380 - standard forth word

FORTH
FILL ( mem-addr mem-length char -- )(); 
 ;

fill a memory area with the given char, does now simply call memset()

dpANS .6.1.1540 - standard forth word

FORTH
FIND ( bstring -- cfa|bstring -1|0|1 )(); 
 ;

looks into the current search-order and tries to find the name string as the name of a word. Returns its execution-token or the original-bstring if not found, along with a flag-like value that is zero if nothing could be found. Otherwise it will be 1 (a positive value) if the word had been immediate, -1 otherwise (a negative value).

dpANS 16.6.1.1550 - standard forth word

FORTH
FM/MOD ( n1.n1 n2 -- m n )(); 
 ;

divide the double-cell value n1 by n2 and return both (floored) quotient n and remainder m

dpANS .6.1.1561 - standard forth word

FORTH

HERE ( -- dp-value )();
p4:"here";

used with WORD and many compiling words

 simulate:   : HERE DP @ ;
 

dpANS .6.1.1650 - standard forth word

FORTH

HOLD ( char -- )();
p4:"hold";

the old-style forth-formatting system -- this word adds a char to the picutred output string.

dpANS .6.1.1670 - standard forth word

FORTH

I ( -- value )();
p4:"i";

returns the index-value of the innermost DO .. LOOP

dpANS .6.1.1680 - standard forth word

FORTH

IF ( value -- ).. THEN();
p4:"if";

checks the value on the stack (at run-time, not compile-time) and if true executes the code-piece between IF and the next ELSE or THEN . Otherwise it has compiled a branch over to be executed if the value on stack had been null at run-time.

dpANS .6.1.1700 - standard forth word

FORTH

IMMEDIATE ( -- )();
p4:"immediate";

make the LATEST word immediate, see also CREATE

dpANS .6.1.1710 - standard forth word

FORTH

INVERT ( value -- value' )();
p4:"invert";

make a bitwise negation of the value on stack. see also NEGATE

dpANS .6.1.1720 - standard forth word

FORTH

J ( -- value )();
p4:"j";

get the current DO ... LOOP index-value being the not-innnermost. (the second-innermost...) see also for the other loop-index-values at I and K

dpANS .6.1.1730 - standard forth word

FORTH

KEY ( -- char )();
p4:"key";

return a single character from the keyboard - the key is not echoed.

dpANS .6.1.1750 - standard forth word

FORTH

LEAVE ( -- )();
p4:"leave";

quit the innermost DO .. LOOP - it does even clean the return-stack and branches to the place directly after the next LOOP

dpANS .6.1.1760 - standard forth word

FORTH
LITERAL ( value -- )immediate(); 
 ;

if compiling this will take the value from the compiling-stack and puts in dictionary so that it will pop up again at the run-time of the word currently in creation. This word is used in compiling words but may also be useful in making a hard-constant value in some code-piece like this:

 : DCELLS [ 2 CELLS ] LITERAL * ; ( will save a multiplication at runtime)

(in most configurations this word is statesmart and it will do nothing in interpret-mode. See LITERAL, for a non-immediate variant)

dpANS .6.1.1780 - standard forth word

FORTH

LOOP ( -- )();
p4:"loop";

resolves a previous DO thereby compiling ((LOOP)) which does increment/decrement the index-value and branch back if the end-value of the loop has not been reached.

dpANS .6.1.1800 - standard forth word

FORTH
LSHIFT ( value shift-val -- value' )(); 
 ;

does a bitwise left-shift on value

dpANS .6.1.1805 - standard forth word

FORTH

M* ( a b -- m,m )();
p4:"m-star";

multiply and return a double-cell result

dpANS .6.1.1810 - standard forth word

FORTH

MAX ( a b -- c )();
p4:"max";

return the maximum of a and b

dpANS .6.1.1870 - standard forth word

FORTH

MIN ( a b -- c )();
p4:"min";

return the minimum of a and b

dpANS .6.1.1880 - standard forth word

FORTH

MOD ( a b -- c )();
p4:"mod";

return the module of "a mod b"

dpANS .6.1.1890 - standard forth word

FORTH

MOVE ( from to length -- )();
p4:"move";

memcpy an area

dpANS .6.1.1900 - standard forth word

FORTH

NEGATE ( value -- value' )();
p4:"negate";

return the arithmetic negative of the (signed) cell

 simulate:   : NEGATE -1 * ;
 

dpANS .6.1.1910 - standard forth word

FORTH

OR ( a b -- ab )();
p4:"or";

return the bitwise OR of a and b - unlike AND this is usually safe to use on logical values

dpANS .6.1.1980 - standard forth word

FORTH

OVER ( a b -- a b a )();
p4:"over";

get the value from under the top of stack. The inverse operation would be TUCK

dpANS .6.1.1990 - standard forth word

FORTH

POSTPONE ( [word] -- )();
p4:"postpone";

will compile the following word at the run-time of the current-word which is a compiling-word. The point is that POSTPONE takes care of the fact that word may be an IMMEDIATE-word that flags for a compiling word, so it must be executed (and not pushed directly) to compile sth. later. Choose this word in favour of COMPILE (for non-immediate words) and [COMPILE] (for immediate words)

dpANS .6.1.2033 - standard forth word

FORTH

QUIT ( -- )no-return();
p4:"quit";

this will throw and lead back to the outer-interpreter. traditionally, the outer-interpreter is called QUIT in forth itself where the first part of the QUIT-word had been to clean the stacks (and some other variables) and then turn to an endless loop containing QUERY and EVALUATE (otherwise known as INTERPRET ) - in pfe it is defined as a THROW ,

 : QUIT -56 THROW ;
 

dpANS .6.1.2050 - standard forth word

FORTH

R> ( R: a -- a R: )();
p4:"r-from";

get back a value from the return-stack that had been saved there using >R . This is the traditional form of a local var space that could be accessed with R@ later. If you need more local variables you should have a look at LOCALS| which does grab some space from the return-stack too, but names them the way you like.

FORTH

R@ ( R: a -- a R: a )();
p4:"r-fetch";

fetch the (upper-most) value from the return-stack that had been saved there using >R - This is the traditional form of a local var space. If you need more local variables you should have a look at LOCALS| , see also >R and R> . Without LOCALS-EXT there are useful words like 2R@ R'@ R"@ R!

dpANS .6.1.2070 - standard forth word

FORTH

RECURSE ( ? -- ? )();
p4:"recurse";

when creating a colon word the name of the currently-created word is smudged, so that you can redefine a previous word of the same name simply by using its name. Sometimes however one wants to recurse into the current definition instead of calling the older defintion. The RECURSE word does it exactly this.

   traditionally the following code had been in use:
   : GREAT-WORD [ UNSMUDGE ] DUP . 1- ?DUP IF GREAT-WORD THEN ;
   now use
   : GREAT-WORD DUP . 1- ?DUP IF RECURSE THEN ;
 

dpANS .6.1.2120 - standard forth word

FORTH

REPEAT ( -- )();
p4:"repeat";

ends an unconditional loop, see BEGIN

dpANS .6.1.2140 - standard forth word

FORTH

ROT ( a b c -- b c a )();
p4:"rot";

rotates the three uppermost values on the stack, the other direction would be with -ROT - please have a look at LOCALS| and VAR that can avoid its use.

dpANS .6.1.2160 - standard forth word

FORTH
RSHIFT ( value shift-val -- value' )(); 
 ;

does a bitwise logical right-shift on value (ie. the value is considered to be unsigned)

dpANS .6.1.2162 - standard forth word

FORTH
S" ( [string<">] -- string-address string-length)(); 
 ;

if compiling then place the string into the currently compiled word and on execution the string pops up again as a double-cell value yielding the string's address and length. To be most portable this is the word to be best being used. Compare with C" and non-portable "

dpANS 11.6.1.2165 - standard forth word

FORTH

S>D ( a -- a,a' )();
p4:"s-to-d";

signed extension of a single-cell value to a double-cell value

FORTH

SIGN ( a -- )();
p4:"sign";

put the sign of the value into the hold-space, this is the forth-style output formatting, see HOLD

dpANS .6.1.2210 - standard forth word

FORTH
SM/REM ( a.a b -- c d )(); 
 ;

see /MOD or FM/MOD or UM/MOD or SM/REM

dpANS .6.1.2214 - standard forth word

FORTH
SOURCE ( -- buffer IN-offset )(); 
 ;

the current point of interpret can be gotten through SOURCE. The buffer may flag out TIB or BLK or a FILE and IN gives you the offset therein. Traditionally, if the current SOURCE buffer is used up, REFILL is called that asks for another input-line or input-block. This scheme would have made it impossible to stretch an [IF] ... [THEN] over different blocks, unless [IF] does call REFILL

dpANS .6.1.2216 - standard forth word

FORTH

SPACE ( -- )();
p4:"space";

print a single space to stdout, see SPACES

 simulate:    : SPACE  BL EMIT ;
 

dpANS .6.1.2220 - standard forth word

FORTH

SPACES ( n -- )();
p4:"spaces";

print n space to stdout, actually a loop over n calling SPACE , but the implemenation may take advantage of printing chunks of spaces to speed up the operation.

dpANS .6.1.2230 - standard forth word

FORTH

STATE ( .. )();
as:"state";

threadstate variable STATE

state (no special usage info)

dpANS 15.6.2.2250 - standard forth word

FORTH

SWAP ( a b -- b a )();
p4:"swap";

exchanges the value on top of the stack with the value beneath it

dpANS .6.1.2260 - standard forth word

FORTH

THEN ( -- )();
p4:"then";

does resolve a branch coming from either IF or ELSE

dpANS .6.1.2270 - standard forth word

FORTH
TYPE ( string-pointer string-length -- )(); 
 ;

prints the string-buffer to stdout, see COUNT and EMIT

dpANS .6.1.2310 - standard forth word

FORTH

U. ( .. )();
as:"u-dot";

ordinary primitive U.

an executable word (no special usage info)

or wrapper call around p4_u_dot

dpANS .6.1.2320 - standard forth word

FORTH

U< ( a b -- cond )();
p4:"u-less-than";

unsigned comparison, see <

FORTH

UM* ( a b -- c,c )();
p4:"u-m-star";

unsigned multiply returning double-cell value

dpANS .6.1.2360 - standard forth word

FORTH

UM/MOD ( a b -- c,c )();
p4:"u-m-slash-mod";

see /MOD and SM/REM

dpANS .6.1.2370 - standard forth word

FORTH

UNLOOP ( -- )();
p4:"unloop";

drop the DO .. LOOP runtime variables from the return-stack, usually used just in before an EXIT call. Using this multiple times can unnest multiple nested loops.

dpANS .6.1.2380 - standard forth word

FORTH

UNTIL ( cond -- )();
p4:"until";

ends an control-loop, see BEGIN and compare with WHILE

dpANS .6.1.2390 - standard forth word

FORTH

VARIABLE ( 'name' -- )();
p4:"variable";

CREATE a new variable, so that everytime the variable is name, the address is returned for using with @ and ! - be aware that in FIG-forth VARIABLE did take an argument being the initial value. ANSI-forth does different here.

dpANS .6.1.2410 - standard forth word

FORTH

WHILE ( cond -- )();
p4:"while";

middle part of a BEGIN .. WHILE .. REPEAT control-loop - if cond is true the code-piece up to REPEAT is executed which will then jump back to BEGIN - and if the cond is null then WHILE will branch to right after the REPEAT (compare with UNTIL that forms a BEGIN .. UNTIL loop)

dpANS .6.1.2430 - standard forth word

FORTH
WORD ( delimiter-char -- here-addr )(); 
 ;

read the next SOURCE section (thereby moving >IN ) up to the point reaching $delimiter-char - the text is placed at HERE - where you will find a counted string. You may want to use PARSE instead.

dpANS .6.1.2450 - standard forth word

FORTH

XOR ( a b -- ab )();
p4:"xor";

return the bitwise-or of the two arguments - it may be unsafe use it on logical values. beware.

dpANS .6.1.2490 - standard forth word

FORTH

[ ( -- )();
p4:"left-bracket";

leave compiling mode - often used inside of a colon-definition to make fetch some very constant value and place it into the currently compiled colon-defintion with , or LITERAL - the corresponding unleave word is ]

dpANS .6.1.2500 - standard forth word

FORTH
['] ( [name] -- )immediate(); 
 ;

will place the execution token of the following word into the dictionary. See ' for non-compiling variant.

dpANS .6.1.2510 - standard forth word

FORTH
[CHAR] ( [word] -- char )(); 
 ;

in compile-mode, get the (ascii-)value of the first charachter in the following word and compile it as a literal so that it will pop up on execution again. See CHAR and forth-83 ASCII

dpANS .6.1.2520 - standard forth word

FORTH

] ( -- )();
p4:"right-bracket";

enter compiling mode - often used inside of a colon-definition to end a previous [ - you may find a , or LITERAL nearby in example texts.

dpANS .6.1.2540 - standard forth word

FORTH

#TIB ( .. )();
as:"sharp-tib";

threadstate variable #TIB

input.number_tib (no special usage info)

dpANS .6.2.0060 - standard forth word

FORTH
.( ( [message<closeparen>] -- )(); 
 ;

print the message to the screen while reading a file. This works too while compiling, so you can whatch the interpretation/compilation to go on. Some Forth-implementations won't even accept a ." message" outside compile-mode while the (current) pfe does.

dpANS .6.2.0200 - standard forth word

FORTH

.R ( val prec -- )();
p4:"dot-r";

print with precision - that is to fill a field of the give prec-with with right-aligned number from the converted value

dpANS .6.2.0210 - standard forth word

FORTH
0<> ( value -- cond )(); 
 ;

returns a logical-value saying if the value was not-zero. This is most useful in turning a numerical value into a boolean value that can be fed into bitwise words like AND and XOR - a simple IF or WHILE doesn't need it actually.

FORTH

0> ( value -- cond )();
p4:"zero-greater";

return value greater than zero

 simulate:    : 0> 0 > ;
 

dpANS .6.2.0280 - standard forth word

FORTH

2>R ( a,a -- R: a,a )();
p4:"two-to-r";

save a double-cell value onto the return-stack, see >R

dpANS .6.2.0340 - standard forth word

FORTH

2R> ( R: a,a -- a,a R: )();
p4:"two-r-from";

pop back a double-cell value from the return-stack, see R> and the earlier used 2>R

FORTH
2R@ ( R: a,a -- a,a R: a,a )(); 
 ;

fetch a double-cell value from the return-stack, that had been previously been put there with 2>R - see R@ for single value. This can partly be a two-cell LOCALS| value, without LOCALS-EXT there are alos other useful words like 2R! R'@ R"@

dpANS .6.2.0415 - standard forth word

FORTH
:NONAME ( -- cs.value )(); 
 ;

start a colon nested-word but do not use CREATE - so no name is given to the colon-definition that follows. When the definition is finished at the corresponding ; the start-address (ie. the execution token) can be found on the outer cs.stack that may be stored used elsewhere then.

dpANS .6.2.0455 - standard forth word

FORTH

<> ( a b -- cond )();
p4:"not-equals";

return true if a and b are not equal, see =

FORTH

?DO ( end start -- ).. LOOP();
p4:"Q-do";

start a control-loop just like DO - but don't execute atleast once. Instead jump over the code-piece if the loop's variables are not in a range to allow any loop.

dpANS .6.2.0620 - standard forth word

FORTH

AGAIN ( -- )();
p4:"again";

ends an infinite loop, see BEGIN and compare with WHILE

dpANS .6.2.0700 - standard forth word

FORTH
C" ( [string<">] -- bstring )(); 
 ;

in compiling mode place the following string in the current word and return the address of the counted string on execution. (in exec-mode use a POCKET and leave the bstring-address of it), see S" string" and the non-portable " string"

dpANS .6.2.0855 - standard forth word

FORTH
CASE ( comp-value -- comp-value )(); 
 ;

start a CASE construct that ends at ENDCASE and compares the value on stack at each OF place

dpANS .6.2.0873 - standard forth word

FORTH

COMPILE, ( xt -- )();
p4:"compile-comma";

place the execution-token on stack into the dictionary - in traditional forth this is not even the least different than a simple , but in call-threaded code there's a big difference - so COMPILE, is the portable one. Unlike COMPILE , [COMPILE] and POSTPONE this word does not need the xt to have actually a name, see :NONAME

dpANS .6.2.0945 - standard forth word

FORTH

CONVERT ( a b -- a b )();
p4:"convert";

digit conversion, obsolete, superseded by >NUMBER

dpANS .6.2.0970 - standard forth word

FORTH

ENDCASE ( comp-value -- )();
p4:"endcase";

ends a CASE construct that may surround multiple sections of OF ... ENDOF code-portions. The ENDCASE has to resolve the branches that are necessary at each ENDOF to point to right after ENDCASE

dpANS .6.2.1342 - standard forth word

FORTH

ENDOF ( -- )();
p4:"endof";

resolve the branch need at the previous OF to mark a code-piece and leave with an unconditional branch at the next ENDCASE (opened by CASE )

dpANS .6.2.1343 - standard forth word

FORTH

ERASE ( ptr len -- )();
p4:"erase";

fill an area will zeros.

 2000 CREATE DUP ALLOT ERASE
 

dpANS .6.2.1350 - standard forth word

FORTH
EXPECT ( str-adr str-len -- )(); 
 ;

input handling, see WORD and PARSE and QUERY the input string is placed at str-adr and its length

 in SPAN - this word is superceded by ACCEPT
 

dpANS .6.2.1390 - standard forth word

FORTH

FALSE ( .. )();
as:"false";

( P4_FALSE )  constant FALSE

an ordinary constant (no special usage info)

dpANS .6.2.1485 - standard forth word

FORTH

HEX ( -- )();
p4:"hex";

set the input/output BASE to hexadecimal

 simulate:        : HEX 16 BASE ! ;
 

dpANS .6.2.1660 - standard forth word

FORTH

MARKER ( 'name' -- )();
p4:"marker";

create a named marker that you can use to FORGET , running the created word will reset the dict/order variables to the state at the creation of this name.

 : MARKER PARSE-WORD (MARKER) ;

see also ANEW which is not defined in ans-forth but which uses the MARKER functionality in the way it should have been defined.

dpANS .6.2.1850 - standard forth word

FORTH

NIP ( a b -- b )();
p4:"nip";

drop the value under the top of stack, inverse of TUCK

 simulate:        : NIP SWAP DROP ;
 

dpANS .6.2.1930 - standard forth word

FORTH
OF ( comp-value case-value -- comp-value ).. ENDOF(); 
 ;

compare the case-value placed lately with the comp-value being available since CASE - if they are equal run the following code-portion up to ENDOF after which the case-construct ends at the next ENDCASE

dpANS .6.2.1950 - standard forth word

FORTH

PAD ( -- addr )();
p4:"pad";

transient buffer region

dpANS .6.2.2000 - standard forth word

FORTH
PARSE ( delim-char -- buffer-start buffer-count )(); 
 ;

parse a piece of input (not much unlike WORD) and place it into the given buffer. The difference with word is also that WORD would first skip any delim-char while PARSE does not and thus may yield that one. In a newer version, PARSE will not copy but just return the word-span being seen in the input-buffer - therefore a transient space.

dpANS .6.2.2008 - standard forth word

FORTH

PICK ( n -- value )();
p4:"pick";

pick the nth value from under the top of stack and push it note that

   0 PICK -> DUP         1 PICK -> OVER
 

dpANS .6.2.2030 - standard forth word

FORTH

QUERY ( -- )();
p4:"query";

source input: read from terminal using _accept_ with the returned string to show up in TIB of /TIB size.

dpANS .6.2.2040 - standard forth word

FORTH

REFILL ( -- flag )();
p4:"refill";

try to get a new input line from the SOURCE and set >IN accordingly. Return a flag if sucessful, which is always true if the current input comes from a terminal and which is always false if the current input comes from EVALUATE - and may be either if the input comes from a file

dpANS 11.6.2.2125 - standard forth word

FORTH
RESTORE-INPUT ( xn ... x1 -- )(); 
 ;

inverse of SAVE-INPUT

dpANS .6.2.2148 - standard forth word

FORTH
ROLL ( xn xm ... x1 n -- xm ... x1 xn )(); 
 ;

the extended form of ROT

    2 ROLL -> ROT
 

dpANS .6.2.2150 - standard forth word

FORTH
SAVE-INPUT ( -- xn .. x1 )(); 
 ;

fetch the current state of the input-channel which may be restored with RESTORE-INPUT later

dpANS .6.2.2182 - standard forth word

FORTH

SOURCE-ID ( .. )();
as:"source-minus-id";

- loader type P4_DVaL SOURCE-ID

input.source_id (no special usage info)

dpANS 11.6.1.2218 - standard forth word

FORTH

SPAN ( .. )();
as:"span";

threadstate variable SPAN

span (no special usage info)

dpANS .6.2.2240 - standard forth word

FORTH

TIB ( .. )();
as:"tib";

- loader type P4_DVaL TIB

input.tib (no special usage info)

dpANS .6.2.2290 - standard forth word

FORTH

TO ( value [name] -- )();
p4:"to";

set the parameter field of name to the value, this is used to change the value of a VALUE and it can be also used to change the value of LOCALS|

dpANS 13.6.1.2295 - standard forth word

FORTH

TRUE ( .. )();
as:"true";

( P4_TRUE )  constant TRUE

an ordinary constant (no special usage info)

dpANS .6.2.2298 - standard forth word

FORTH

TUCK ( a b -- b a b )();
p4:"tuck";

shove the top-value under the value beneath. See OVER and NIP

 simulate:    : TUCK  SWAP OVER ;
 

dpANS .6.2.2300 - standard forth word

FORTH

U.R ( value prec -- )();
p4:"u-dot-r";

print right-aligned in a prec-field, treat value to be unsigned as opposed to .R

dpANS .6.2.2330 - standard forth word

FORTH

U> ( a b -- ab )();
p4:"u-greater-than";

unsigned comparison of a and b, see >

FORTH

UNUSED ( -- val )();
p4:"unused";

return the number of cells that are left to be used above HERE

dpANS .6.2.2395 - standard forth word

FORTH

VALUE ( value 'name' -- )();
p4:"value";

CREATE a word and initialize it with value. Using it later will push the value back onto the stack. Compare with VARIABLE and CONSTANT - look also for LOCALS| and VAR

dpANS .6.2.2405 - standard forth word

FORTH

WITHIN ( a b c -- cond )();
p4:"within";

a widely used word, returns ( b <= a && a < c ) so that is very useful to check an index a of an array to be within range b to c

dpANS .6.2.2440 - standard forth word

FORTH
[COMPILE] ( [word] -- )(); 
 ;

while compiling the next word will be place in the currently defined word no matter if that word is immediate (like IF ) - compare with COMPILE and POSTPONE

dpANS .6.2.2530 - standard forth word

FORTH

\ ( [comment<eol>] -- )();
p4:"backslash";

eat everything up to the next end-of-line so that it is getting ignored by the interpreter.

dpANS 7.6.2.2535 - standard forth word

FORTH
" ( [string<">] -- bstring )or perhaps ( [..] -- str-ptr str-len )(); 
 ;

This is the non-portable word which is why the ANSI-committee on forth has created the two other words, namely S" and C" , since each implementation (and in pfe configurable) uses another runtime behaviour. FIG-forth did return bstring which is the configure default for pfe.

FORTH
PARSE-WORD ( "chars" -- c-addr u )(); 
 ;

the ANS'94 standard describes this word in a comment under PARSE, section A.6.2.2008 - quote:

Skip leading spaces and parse name delimited by a space. c-addr is the address within the input buffer and u is the length of the selected string. If the parse area is empty, the resulting string has a zero length.

If both PARSE and PARSE-WORD are present, the need for WORD is largely eliminated.

FORTH

<BUILDS ( 'name' -- )();
p4:"builds";

make a HEADER whose runtime will be changed later using DOES>

note that ans'forth does not define <BUILDS and it suggests to use CREATE directly.

... if you want to write FIG-programs in pure pfe then you have to use CREATE: to get the FIG-like meaning of CREATE whereas the ans-forth CREATE is the same as <BUILDS

 : <BUILDS BL WORD HEADER DOCREATE A, 0 A, ;
 
FORTH

CFA' ( .. )();
as:"cfa-tick";

ordinary primitive CFA'

an executable word (no special usage info)

or wrapper call around p4_tick

FORTH

CREATE ( .. )();
as:"create";

forthword synonym CREATE

is doing the same as <BUILDS

this word is provided only for compatibility with common forth usage in programs. Thegiven synonym should be preferred however.

dpANS .6.1.1000 - standard forth word

FORTH

' ( 'name' -- xt )();
p4:"tick";

return the execution token of the following name. This word is _not_ immediate and may not do what you expect in compile-mode. See ['] and '> - note that in FIG-forth the word of the same name had returned the PFA (not the CFA) and was immediate/smart, so beware when porting forth-code from FIG-forth to ANSI-forth.

dpANS .6.1.0070 - standard forth word

EXTENSIONS
(MARKER) ( str-ptr str-len -- )(); 
 ;

create a named marker that you can use to FORGET , running the created word will reset the dict/order variables to the state at the creation of this name.

 : (MARKER) (CREATE) HERE , 
         GET-ORDER DUP , 0 DO ?DUP IF , THEN LOOP 0 , 
         ...
   DOES> DUP @ (FORGET) 
         ...
 ; 
 
EXTENSIONS

ANEW ( 'name' -- )();
p4:"anew";

creates a MARKER if it doesn't exist, or forgets everything after it if it does. (it just gets executed).

 : ANEW BL WORD   DUP FIND NIP IF EXECUTE THEN   (MARKER) ;
 
ENVIRONMENT

CORE-EXT ( .. )();
as:"core-minus-ext";

( 1994  )  constant CORE-EXT

an ordinary constant (no special usage info)

ENVIRONMENT
/COUNTED-STRING ( .. )(); 
 ;
( UCHAR_MAX  )  constant /COUNTED-STRING

an ordinary constant (no special usage info)

ENVIRONMENT

/HOLD ( .. )();
as:"slash-hold";

( MIN_HOLD  )  constant /HOLD

an ordinary constant (no special usage info)

ENVIRONMENT

/PAD ( .. )();
as:"slash-pad";

( MIN_PAD  )  constant /PAD

an ordinary constant (no special usage info)

ENVIRONMENT
ADDRESS-UNIT-BITS ( .. )(); 
 ;
( CHAR_BIT  )  constant ADDRESS-UNIT-BITS

an ordinary constant (no special usage info)

ENVIRONMENT

FLOORED ( .. )();
as:"floored";

( P4_TRUE  )  constant FLOORED

an ordinary constant (no special usage info)

ENVIRONMENT

MAX-CHAR ( .. )();
as:"max-minus-char";

( UCHAR_MAX  )  constant MAX-CHAR

an ordinary constant (no special usage info)

ENVIRONMENT

MAX-N ( .. )();
as:"max-minus-n";

( CELL_MAX  )  constant MAX-N

an ordinary constant (no special usage info)

ENVIRONMENT

MAX-U ( .. )();
as:"max-minus-u";

( UCELL_MAX  )  constant MAX-U

an ordinary constant (no special usage info)

ENVIRONMENT
STACK-CELLS ( .. )(); 
 ;

ordinary primitive STACK-CELLS

an executable word (no special usage info)

or wrapper call around p__stack_cells

ENVIRONMENT
RETURN-STACK-CELLS ( .. )(); 
 ;

ordinary primitive RETURN-STACK-CELLS

an executable word (no special usage info)

or wrapper call around p__return_stack_cells