M


malloc
( n --- addr )
"malloc". Allocate n bytes of system memory. The C malloc() function is called. Use free to return the memory to the system when done with it. Usage:
      100 malloc
      mem_ptr !
      ( some words )
      mem_ptr @
      free
Use realloc to resize an array originally allocated by malloc.
max
( n1 n2 --- n3 )
"max". Return the larger of n1 or n2.
      99 66 max
returns 99. A good way to return a non-negative number is 0 max.
min
( n1 n2 --- n3 )
"min". Return the lesser of n1 and n2.
      99 66 min
returns 66.
mod
( n1 n2 --- mod )
"mod". Calculate the remainder of n1 divided by n2:
      4 2 mod
Leaves 0 on the stack.
msg
High Level ( 'string --- )
"message". Type a message to the console. The definition is:
      : msg   dup strlen type ;

move_string
High level ('source 'destination --- )
"move string". Move the contents of source to destination. Both addresses are counted strings. The destination string must be large enough to hold the source string. No check is made for string overflow.

N


next
( --- )
"next". Marks the end of a for loop.
negate
( n1 --- n2 )
"negate". Calculate the two's complement of a number.
not
( n1 --- n2 )
"not". Calculate the one's complement of a number.
null_strings
( tf --- )
"null strings". Until treats strings as counted by default for ". This word allows the programmer to toggle the operation of " to switch to null terminated representation.
        true  null_strings    \ Null terminated strings
        false null_strings    \ Counted strings
This is a convenience word generally used with the C string words. null_strings affects run-time string representation.
null->counted
('null 'counted --- )
"null-to-counted". Copy string from null to counted, converting from null terminated to counted form. Typical interactive usage is:
      { string} here inbuf null-*gt;counted
      inbuf count type

O


of
( n1 --- n|empty)
"of". The test portion of a case statement. When n matches the compiled value, the code up to the endcode executes. Otherwise, the next of condition is tested. n is left on the stack when no match occurs.
   : test      ( n --- )
      case
      1 of ." n is 1" cr endof
      2 of ." n is 2" cr endof
      ." No match" cr
      endcase ;

or
( n1 n2 --- tf)
"or". Calculate the bitwise or of n1 and n2.
      1010 1010  - n1
      0101 0101  - n2
      1111 1111  - Result

over
( n1 n2 --- n1 n2 n1 )
"over". Copy n1 to the top of the stack.
      1 2 over
results in ( 1 2 1 ).

P


pad
( --- 'pad )
"pad". Push the address of pad onto the parameter stack. pad is a memory buffer allocated at start up for use as a scratch memory area for some string operations. It is used as a temporary work area by many words. pad is allocated as a 128 byte buffer at startup in Until. It does NOT float at the end of the dictionary as in conventional Forths.
pfa_list
( --- 'pfa_list )
"p-f-a list". Push the address of the C array pfa_list onto the parameter stack. pfa_list is used to accumulate temporary definitions during compilation.
pfa_offset
( --- 'pfa_offset )
"p-f-a offset". Push the address of the C variable pfa_offset onto the stack. It is the current offset into pfa_list.
pick
( n --- value )
"pick". Pick the value n items from the top of the stack and place a copy of it on the top of the stack. Assume the top five numbers on the top of the stack are ( 1 2 3 4 5 ):
      5 pick
copies the fifth item, 1, to the top of the stack ( 1 2 3 4 5 1 ). 1 pick is the same as dup. 2 pick is the same as over.
plus_loop
Internal Use Only
"plus-loop". This is the internal word that is executed by +loop. Do not use it in application code.
printf
( a1 a2 ... an 'format fd --- )
"print-f". This is the C printf() function. The top of the stack contains a format string, 'format. 'format is a C printf() format string such as:
   " A string: %s  or a decimal number: %d"

The arguments to printf are in the order used. For example:

   " string" 65 " A string: %s  or a decimal number: %d\n" printf

will write:

   A string: string  or a decimal number: 65

with a trailing newline character to STDOUT. The first argument goes with the first format specifier (" string" and the %s) and the second argument goes with the second format specifier (65 and %d) in this case.

Note that floating point values cannot be used with printf. Use printf_f to output floating point values.


printf_f
( f1 f2 ... an 'format --- )
"print-f-underscore-f". This is the C printf() function. printf_f can only be used to out floating point values. The top of the stack contains a format string, 'format. 'format is a C printf() format string such as:
   " A floating point number: %e"
The arguments to printf_f are in the order used. For example:
   f# 123.456 " A floating point number: %e\n" printf_f
will write:
   A floating point number: 123.4560
with a trailing newline character to STDOUT. The first argument goes with the first format specifier (123.456 and the %e).

Note that only floating point values can be used with printf_f. Use printf to output other values.


Q


quote
Internal Use Only
"quote". This is the internal word called when " executes.

R


r>
( --- n )
"r-from". Move the number on the top of the return stack to the top of the parameter stack. r> must be paired with a previous >r. The Return Stack is used only for loop indices in Until.
r@
( --- n )
"r-fetch". Fetch the value from the top of the return stack. The return stack is unaffected.
READ
( --- 'READ )
"read". This word leaves the address of the "r" string used by fopen.
      " anyfile.dat" READ fopen
opens anyfile.dat with read access. The Return Stack is used only for loop indices in Until.
read_into
( 'string --- )
"read-into". Set SGML input buffer pointer to the string whose address is on the top of the stack. SGML input will be collected into this buffer until changed. It is very important that the allocate length of 'string be long enough to hold the text being collected into it.
   500 string trash
   ...
   trash read_into

realloc
( 'memory-block --- addr )
"re-alloc". Call the C function realloc() to reallocate a block of memory. memory-block is the address of a previously malloc'd block of memory. The return, addr, is either the address of the newly allocated memory block or 0 on error.
repeat
( --- )
"repeat". Terminate a:
      begin ... while ... repeat
loop. repeat branches to begin. The exit test is done by the while.
     : test
       0            \ initialize counter
       begin
         dup 1+     \ increment count
         dup 10 <   \ is count < 10
       while
         ." ."      \ type a .
       repeat
       cr ." Done, 9 dots, but count is: " . cr
       ;

replace
( 'string 'new_str 'sub_str --- 'string )
"replace". Replace the substring, sub_str, starting at string with the new string, new_str. The original address is returned. No check is made to see that the new string fits.
roll
( n --- )
"roll". Move the nth value on the stack to the top entry. All entries are pushed down a cell. n does not include itself in the count.
      3 roll
is equivalent to rot. The value of n must be greater than zero.
rot
( n1 n2 n3 --- n2 n3 n1 )
"rote". Rotate the third value on the parameter stack to the top. The other values are pushed down one cell.
      1 2 3 rot
results in (2 3 1).

Table of Contents
Next Section