# docs/reference/v4-dictionary.tsv -- the dictionary of v4 (#157): name, stack notation, # description, tab-separated. The names are the live system's (v4/tools/mkdictionary.py # check refuses a missing or a stale one). A row whose description starts TODO is a draft. ! ( x addr -- ) Store x in the cell at addr. # ( ud1 -- ud2 ) Pictured output: divide ud1 by BASE, put the remainder's digit in front of the string being built, leave the quotient. #> ( ud -- baddr u ) End pictured output: drop ud and leave the string built since <#. #S ( ud -- 0 0 ) Pictured output: convert digits with # until the number is zero (at least one digit). ' ( -- addr ) ' xxx: the parameter field address of xxx; compiled as a literal when compiling. ( ( -- ) ( text): a comment, ended by the first ); immediate. (.") ( -- ) The run time of .": print the string compiled after the call, and go on after it. (ABORT") ( flag -- ) The run time of ABORT": if flag is not zero, print the string compiled after the call and ABORT. (BITS) ( -- n ) The number of bits in a cell, counted at run time (forth79.4th; used by U/MOD). (CONSOLE) ( -- addr ) Variable: the node that what this node prints is sent to, as messages (core.f18). (LOG") ( level -- ) The run time of LOG-xxx": print the string compiled after the call if level is at or below LOG-LEVEL. (LOST) ( -- addr ) Variable: a count of the messages this node has dropped -- nowhere to send them, or no room. (ME) ( -- addr ) Variable: this node's number in the mesh. (NB) ( -- n ) Constant: the bits in a cell, (BITS) counted once at load (forth79.4th). (REFUSED) ( -- addr ) Variable: a count of the messages that came back to this node, refused. (S") ( -- baddr u ) The run time of S": leave the address and length of the string compiled after the call. (SEAL) ( -- ) What is in the dictionary now is the system: COLD returns to it and FORGET will not go below it. (UD) ( -- addr ) Variable: U/MOD's divisor while it divides (forth79.4th). (WORD-DEFINED) ( -- addr ) Variable: the hook told when an entry is made, with the xt its code will be at. (WORD-FORGOTTEN) ( -- addr ) Variable: the hook told when entries are forgotten, with the word address they went from. * ( n1 n2 -- n3 ) Multiply: the low cell of the product. */ ( n1 n2 n3 -- n4 ) n1 times n2 divided by n3, through a double-cell intermediate product. */MOD ( n1 n2 n3 -- n4 n5 ) n1 times n2 divided by n3, through a double product: n4 the remainder, n5 the quotient. + ( n1 n2 -- n3 ) Add. +! ( n addr -- ) Add n to the cell at addr. +LOOP ( n -- ) Compile-only: end a DO loop, adding n to the index; the loop ends when the index crosses the limit. , ( x -- ) Compile x into the next cell of the dictionary. - ( n1 n2 -- n3 ) Subtract: n1 minus n2. -! ( n addr -- ) Subtract n from the cell at addr. --> ( -- ) Go on loading with the next block; only in a block being loaded. -ROT ( x1 x2 x3 -- x3 x1 x2 ) Rotate the top three values the other way from ROT. -TRAILING ( baddr u1 -- baddr u2 ) The string without its trailing blanks. . ( n -- ) Print n in the current BASE, then a blank. ." ( -- ) ." text": print the text -- now when interpreting, when the word runs when compiling. .R ( n width -- ) Print n right-justified in a field of width characters. .S ( -- ) Print the stack's depth and every value on it, the stack unchanged. / ( n1 n2 -- n3 ) Divide: the quotient of n1 by n2. Division by zero is error 11. /MOD ( n1 n2 -- n3 n4 ) Divide n1 by n2: n3 the remainder, n4 the quotient. 0< ( n -- flag ) True if n is negative. 0<> ( x -- flag ) True if x is not zero. 0= ( x -- flag ) True if x is zero. 0> ( n -- flag ) True if n is greater than zero. 1+ ( n -- n+1 ) Add one. 1- ( n -- n-1 ) Subtract one. 2! ( x1 x2 addr -- ) Store the cell pair at addr: x2 at addr, x1 in the next cell. 2* ( n -- 2n ) Shift left one bit. 2+ ( n -- n+2 ) Add two. 2, ( x1 x2 -- ) Compile the cell pair into the dictionary. 2- ( n -- n-2 ) Subtract two. 2/ ( n -- n/2 ) Shift right one bit, keeping the sign. 2>R ( x1 x2 -- ) ( R: -- x1 x2 ) Compile-only: move the pair to the return stack. 2@ ( addr -- x1 x2 ) Fetch the cell pair at addr. 2DROP ( x1 x2 -- ) Drop the top pair. 2DUP ( x1 x2 -- x1 x2 x1 x2 ) Copy the top pair. 2OVER ( x1 x2 x3 x4 -- x1 x2 x3 x4 x1 x2 ) Copy the second pair to the top. 2R> ( -- x1 x2 ) ( R: x1 x2 -- ) Compile-only: move the pair from the return stack. 2R@ ( -- x1 x2 ) ( R: x1 x2 -- x1 x2 ) Compile-only: copy the pair on the return stack. 2ROT ( x1 x2 x3 x4 x5 x6 -- x3 x4 x5 x6 x1 x2 ) Rotate the top three pairs. 2SWAP ( x1 x2 x3 x4 -- x3 x4 x1 x2 ) Exchange the top two pairs. 79-STANDARD ( -- ) Run to be sure a FORTH-79 system is there; it is. : ( -- ) : xxx: start a definition of xxx; it cannot be found until ; ends it. ; ( -- ) Compile-only: end the definition -- compile its return, let it be found, stop compiling. < ( n1 n2 -- flag ) True if n1 is less than n2. <# ( -- ) Begin pictured numeric output. <= ( n1 n2 -- flag ) True if n1 is less than or equal to n2. <> ( x1 x2 -- flag ) True if x1 and x2 differ. = ( x1 x2 -- flag ) True if x1 equals x2. > ( n1 n2 -- flag ) True if n1 is greater than n2. >= ( n1 n2 -- flag ) True if n1 is greater than or equal to n2. >BODY ( xt -- addr ) The parameter field of the word whose execution token is xt. >IN ( -- addr ) Variable: the offset in the input buffer of the next character to read. >LINK ( xt -- lfa ) The link field of the entry whose execution token is xt. >NAME ( xt -- nfa ) The name field of the entry whose execution token is xt. >R ( x -- ) ( R: -- x ) Compile-only: move x to the return stack. ? ( addr -- ) Print the number in the cell at addr. ?DO ( limit index -- ) Compile-only: begin a DO loop that is skipped when limit equals index. ?DUP ( x -- x x | 0 ) Copy x if it is not zero. ?TERMINAL ( -- flag ) True if a key has been pressed and is waiting. @ ( addr -- x ) Fetch the cell at addr. ABORT ( -- ) Empty the data and return stacks, set execution mode, return control to the terminal. ABORT" ( flag -- ) ABORT" text": if flag is not zero, print the text and ABORT. ABS ( n -- u ) The absolute value. ACL-ALLOW! ( flag xt -- ) Set the word's allow flag (the word-level ACL); nothing on a pinned word. ACL-ALLOW@ ( xt -- flag ) The word's allow flag. ACL-HEAT@ ( xt -- heat ) How often the word has been used: its heat counter. ACL-HOOK ( -- addr ) Variable: the execution token of the ACL recheck word, or 0 for none. ACL-INHERIT ( src dst -- ) dst takes src's ACL mode; it is not pinned, its TTL is 0. ACL-INIT-PRIMITIVES ( -- ) Set every word in every vocabulary to its starting ACL fields. ACL-MODE! ( mode xt -- ) Set the word's ACL mode; nothing on a pinned word. ACL-MODE@ ( xt -- mode ) The word's ACL mode. ACL-PIN ( xt -- ) Pin the word: its ACL fields can no longer be changed. One-way. ACL-PINNED? ( xt -- flag ) True if the word is pinned. ACL-TTL! ( n xt -- ) Set the word's ACL time-to-live (0 to 65535); nothing on a pinned word. ACL-TTL@ ( xt -- n ) The word's ACL time-to-live. ACL-WORD-ID ( xt -- n ) A number for the word that never changes: its address. AGAIN ( -- ) Compile-only: end a BEGIN loop that repeats for ever. ALIGN ( -- ) Align the dictionary pointer to the next cell. ALLOT ( n -- ) Reserve n cells of dictionary space. AND ( x1 x2 -- x3 ) Bitwise and. AWAIT ( node -- how ) Wait for the node's word on how its text ended: 0 QUIT, 1 completed, otherwise an error. BASE ( -- addr ) Variable: the number base for conversion in and out. BEGIN ( -- ) Compile-only: mark the start of a loop (UNTIL, WHILE ... REPEAT, AGAIN). BL ( -- c ) Constant: the blank character, 32. BLANK ( baddr u -- ) Fill u bytes from baddr with blanks. BLK ( -- addr ) Variable: the block being interpreted, or 0 for the terminal. BLOCK ( n -- baddr ) A buffer holding block n, read from storage if it is not already in one. BUFFER ( n -- baddr ) A buffer assigned to block n, not read from storage. BYE ( -- ) A cold restart of the machine (the kernel's word). C! ( c baddr -- ) Store the byte c at baddr. C, ( c -- ) Compile the byte c into the dictionary. C@ ( baddr -- c ) Fetch the byte at baddr. CASE ( -- ) Compile-only: begin a CASE ... OF ... ENDOF ... ENDCASE selection. CELLS ( n1 -- n2 ) n1 cells, in address units. CFA ( pfa -- cfa ) The code field address from the parameter field address. CMOVE ( baddr1 baddr2 u -- ) Copy u bytes from baddr1 to baddr2, lowest first. CMOVE> ( baddr1 baddr2 u -- ) Copy u bytes from baddr1 to baddr2, highest first (for overlapping moves up). COLD ( -- ) Return the system to what it was when its capsules had just been loaded. COMPARE ( baddr1 u1 baddr2 u2 -- n ) Compare two strings: 0 if equal, -1 if the first is lower, 1 if higher. COMPILE ( -- ) COMPILE xxx: when the word containing this runs, compile xxx. CONSTANT ( n -- ) CONSTANT xxx: define xxx, which leaves n. CONTEXT ( -- addr ) Variable: the vocabulary searched first. CONVERT ( d1 baddr1 -- d2 baddr2 ) Convert the digits from baddr1+1 into d1 in BASE; baddr2 is the first character that is not a digit. COUNT ( baddr1 -- baddr2 u ) From a counted string: its first character's address and its length. CR ( -- ) Print a new line. CREATE ( -- ) CREATE xxx: an entry whose word leaves the address of its parameter field. CURRENT ( -- addr ) Variable: the vocabulary new definitions go into. D+ ( d1 d2 -- d3 ) Add two double-cell numbers. D- ( d1 d2 -- d3 ) Subtract d2 from d1. D. ( d -- ) Print the double-cell number d, then a blank. D.R ( d width -- ) Print d right-justified in a field of width characters. D0< ( d -- flag ) True if d is negative. D0= ( d -- flag ) True if d is zero. D2* ( d1 -- d2 ) Shift d1 left one bit. D2/ ( d1 -- d2 ) Shift d1 right one bit, keeping the sign. D< ( d1 d2 -- flag ) True if d1 is less than d2. D= ( d1 d2 -- flag ) True if d1 equals d2. DABS ( d -- ud ) The absolute value of d. DECIMAL ( -- ) Set BASE to ten. DEFAULT-ROUTE ( port -- ) The port, by its number, leads toward every node this node has not been told of. DEFER ( -- ) DEFER xxx: define xxx, whose action is set later by IS; run unset, it is error 15. DEFER@ ( -- xt ) DEFER@ xxx: the execution token xxx runs now; compiled when compiling. DEFINITIONS ( -- ) New definitions go into the CONTEXT vocabulary from now on. DEPTH ( -- n ) The number of values on the stack before DEPTH. DMAX ( d1 d2 -- d3 ) The greater of two doubles. DMIN ( d1 d2 -- d3 ) The lesser of two doubles. DNEGATE ( d -- -d ) Negate a double-cell number. DO ( limit index -- ) Compile-only: begin a counted loop, ended by LOOP or +LOOP. DOES> ( -- ) Compile-only: in a defining word, what the words it defines do, with their parameter field's address on the stack. DROP ( x -- ) Drop the top value. DUMP ( baddr u -- ) Print u bytes from baddr in the current BASE, with their addresses. DUP ( x -- x x ) Copy the top value. ELSE ( -- ) Compile-only: the other branch of IF ... ELSE ... THEN. EMIT ( c -- ) Print the character c. EMPTY-BUFFERS ( -- ) Forget what is in the block buffers; nothing is written. ENCLOSE ( baddr c -- baddr n1 n2 n3 ) Find a word delimited by c in the string at baddr: n1 its start, n2 its end, n3 the offset after the delimiter. ENDCASE ( x -- ) Compile-only: end a CASE selection, dropping the value if no OF matched. ENDOF ( -- ) Compile-only: end an OF branch; go on after ENDCASE. ERASE ( baddr u -- ) Fill u bytes from baddr with zeros. EXECUTE ( xt -- ) Run the word whose execution token is xt. EXIT ( -- ) Compile-only: return from the definition at this point. EXPECT ( baddr n -- ) Read up to n characters, or a line, from the terminal into baddr; SPAN holds how many. FALSE ( -- 0 ) Constant: the false flag, zero. FENCE ( -- addr ) Variable: FORGET will not remove anything below the address it holds. FILL ( baddr u c -- ) Fill u bytes from baddr with the byte c. FIND ( -- xt | 0 ) FIND xxx: the execution token of xxx, from the input stream, or 0 if it is not found. FLUSH ( -- ) Write every changed block (SAVE-BUFFERS). FORGET ( -- ) FORGET xxx: remove xxx and every word defined after it, never below FENCE. FORTH ( -- ) Make FORTH, the primary vocabulary, the CONTEXT vocabulary. GONE ( n node -- ) Tell the node that node n is gone; it acts on that only if this node is its centre. HERE ( -- addr ) The address of the next free dictionary cell. HEX ( -- ) Set BASE to sixteen. HIDDEN ( -- ) Hide the newest entry: it cannot be found until revealed. HOLD ( c -- ) Pictured output: put the character c in front of the string being built. I ( -- n ) Compile-only: the index of the innermost DO loop. IF ( flag -- ) Compile-only: run what follows if flag is not zero, else skip to ELSE or THEN. IMMEDIATE ( -- ) Make the newest definition run when compiling instead of being compiled. INTERPRET ( -- ) Interpret words from the input stream until it is exhausted. INVERT ( x1 -- x2 ) Invert every bit. IS ( xt -- ) IS xxx: make the deferred word xxx run xt; compiled when compiling. J ( -- n ) Compile-only: the index of the next outer DO loop. KERNEL-WORD ( n -- ) KERNEL-WORD xxx: define xxx, a word that asks the kernel to do request n (as BYE, BLOCK). KEY ( -- c ) Wait for a key and leave its character. LATEST ( -- xt ) The newest entry of the CURRENT vocabulary. LEAVE ( -- ) Compile-only: leave the innermost DO loop at its next LOOP or +LOOP. LFA ( xt -- addr ) The link field of the entry (>LINK). LINK> ( addr -- xt ) The entry that a link field points to. LIST ( n -- ) Print block n as 16 lines of 64 characters; SCR holds n. LITERAL ( x -- ) If compiling, compile x as a literal. LOAD ( n -- ) Interpret block n, then go on with what follows. LOG-DEBUG ( -- 4 ) Constant: the debug log level. LOG-DEBUG" ( -- ) LOG-DEBUG" text": log the text at the debug level. LOG-DEBUG-STR ( baddr u -- ) Log the string at the debug level. LOG-ERROR ( -- 0 ) Constant: the error log level. LOG-ERROR" ( -- ) LOG-ERROR" text": log the text at the error level. LOG-ERROR-STR ( baddr u -- ) Log the string at the error level. LOG-INFO ( -- 2 ) Constant: the info log level. LOG-INFO" ( -- ) LOG-INFO" text": log the text at the info level. LOG-INFO-STR ( baddr u -- ) Log the string at the info level. LOG-LEVEL! ( n -- ) Set the log level, held to 0 .. 4: messages at or below it are printed. LOG-LEVEL@ ( -- n ) The log level. LOG-TEST ( -- 3 ) Constant: the test log level. LOG-TEST" ( -- ) LOG-TEST" text": log the text at the test level. LOG-TEST-STR ( baddr u -- ) Log the string at the test level. LOG-WARN ( -- 1 ) Constant: the warning log level. LOG-WARN" ( -- ) LOG-WARN" text": log the text at the warning level. LOG-WARN-STR ( baddr u -- ) Log the string at the warning level. LOOP ( -- ) Compile-only: end a DO loop, adding one to the index. LSHIFT ( x1 u -- x2 ) Shift x1 left u bits; a count that is negative or a cell or more gives 0. M* ( n1 n2 -- d ) Multiply: the double-cell product, signed. M+ ( d1 n -- d2 ) Add a single-cell number to a double. M- ( d1 n -- d2 ) Subtract a single-cell number from a double. M/MOD ( d n1 -- n2 n3 ) Divide d by n1: n2 the remainder, n3 the quotient. MAX ( n1 n2 -- n3 ) The greater of two numbers. MIN ( n1 n2 -- n3 ) The lesser of two numbers. MINT-ZUSE ( -- ) Mint the real Zuse onto a second stick: asks for the stick, writes nothing until YES (the kernel's word; STICK.md 6a). MOD ( n1 n2 -- n3 ) The remainder of n1 divided by n2. MOVE ( addr1 addr2 n -- ) Copy n cells from addr1 to addr2, the first cell first. NAME> ( baddr -- xt ) The entry whose name field is at baddr. NEGATE ( n -- -n ) Negate. NEIGHBOUR ( node port -- ) Record the node on the other end of the port, by its number; 0: none. NFA ( xt -- baddr ) The name field of the entry (>NAME). NO-ROUTE ( node -- ) Forget the way to that node, if one is known. NO-ROUTES ( -- ) Forget every way to every node: for when the wiring has changed. NODE-ERROR ( -- addr ) Variable: storing a non-zero code raises that error -- the word goes no further and the line ends with ERROR. NOP ( -- ) Do nothing. NOT ( flag1 -- flag2 ) True if flag1 is zero (as 0=). NUMBER ( baddr -- d ) Convert the counted string at baddr to a double; what is not a number gives 0 and sets NODE-ERROR. OCTAL ( -- ) Set BASE to eight. OF ( x1 x2 -- | x1 ) Compile-only: in CASE, run the branch to ENDOF if x1 equals x2. OR ( x1 x2 -- x3 ) Bitwise or. ORDER ( -- ) Print where names are looked for, and where new ones go. OVER ( x1 x2 -- x1 x2 x1 ) Copy the second value to the top. PAD ( -- baddr ) A scratch area for text. PAGE ( -- ) Clear the screen and put the cursor at the top. PFA ( xt -- addr ) The parameter field of the entry. PICK ( n -- x ) A copy of the n-th value, not counting n itself: 1 PICK is DUP. PORT! ( w port -- ) Write a cell to the port, by its number; waits until the neighbour reads it. Q.* TODO ---- multiply ---- Q.+ TODO ---- the double words under other names ---- Q.- TODO Q./ TODO Q.0 TODO Q.0= TODO Q.1 TODO Q.< TODO Q.= TODO Q.> TODO Q.ABS TODO Q.COS TODO Q.EXP TODO ---- e to the x ---- Q.FROM-INT TODO ---- conversion and constants ---- Q.LOG TODO ---- natural logarithm ---- Q.MAX TODO Q.MIN TODO Q.NEG TODO Q.PRINT TODO ---- printing ---- The integer part, a point, five digits, a blank; always in decimal. Q.SCALE TODO Q.SIN TODO Q.SQRT TODO ---- square root ---- Q.TO-INT TODO QUERY ( -- ) TODO FORTH-79: up to 80 characters, or a line, into TIB; >IN to 0. QUIT TODO R> TODO R@ TODO REPEAT TODO ROLL ( n -- ) TODO FORTH-79: the n-th value, not counting n itself, is taken out and put on top. 3 ROLL is ROT, 2 ROLL is SWAP, 1 ROLL does nothing. n less than one is an error. ROT TODO ROUTE ( node port -- ) TODO the port, by its number, leads toward that node RSHIFT TODO S" ( -- baddr u ) TODO S" text" as v3. In a definition the text is compiled into it. At the prompt it is copied to PAD, where it stays until PAD is used again: WORD's buffer is overwritten by the very next word of the line. S>D TODO SAVE-BUFFERS TODO FORTH-79: write every block that has been UPDATEd. SCAN TODO SCR TODO SEARCH TODO SEND ( baddr u node -- ) TODO send the node u characters of text to interpret, by the way this node knows to it. What it prints there goes to that node's console. With no way to the node it is error 12. SEND-ON ( baddr u node port -- ) TODO the same by a port this node names, by its number, whatever ways it knows: for a neighbour that has no number of its own yet, to which text is sent as to node 0. SIGN TODO SKIP TODO SMUDGE TODO SOURCE ( -- baddr u ) TODO the input buffer and how much of it is in use SPACE TODO SPACES TODO ---- spaces and the number base ---- SPAN TODO STATE TODO SWAP TODO THEN TODO THRU ( first last -- ) TODO as v3: LOAD each block from first to last. TIB TODO TRAVERSE ( baddr n -- baddr' ) TODO as v3: for n > 0, from a name's count byte to the byte after its last character; otherwise the address unchanged. TRUE TODO TYPE TODO U* TODO U. TODO U.R TODO U/MOD TODO U< TODO U> TODO UM* TODO ---- section 4: multiply ------------------------------------------------ UNLOOP TODO UNTIL TODO UPDATE TODO FORTH-79: mark the block most recently asked for as changed, so that it is written before its buffer is used for another. VARIABLE TODO FORTH-79: CREATE and one cell. The standard leaves its first value to the programme; here it is 0. VERSION ( -- ) TODO which system this is, and its cell width VLIST TODO VOCABULARY TODO WARM ( -- ) TODO as v3's message, and then ABORT: both stacks emptied, the prompt WHILE TODO WITHIN TODO WORD TODO WORDS ( -- ) TODO the names in the CONTEXT vocabulary, the newest first, a blank after each, a new line whenever one has passed column 64. Hidden entries -- a definition under way -- are not shown. (Q)+0 is the column. XOR TODO [ TODO ['] TODO ['] xxx the same inside a definition, whatever STATE is; and [LITERAL], which v3 has as another name for LITERAL. [COMPILE] TODO [COMPILE] xxx FORTH-79: compile xxx even though it is immediate [LITERAL] TODO \ TODO ] TODO