Google

FORTH-83 compatibility

All FORTH-83-Standard words are included here that are not in the dpANS already. Though most of the "uncontrolled reference words" are omitted.



2+ ( i -- i )  

add 2 to the value on stack (and leave the result there)
 simulate:
   : 2+ 2 + ;

reference: p4_two_plus in ../src/forth-83.c:0044, export CO 2+

2- ( i -- i )  

substract 2 from the value on stack (and leave the result there)
 simulate:
   : 2- 2 - ;

reference: p4_two_minus in ../src/forth-83.c:0054, export CO 2-

?TERMINAL ( -- flag )  

if a character is available from the keyboard, return true. The KEY word will retrieve the actual character.

reference: p4_key_question in ../src/facility.c:0060, export CO ?TERMINAL

COMPILE word ( )  
smart-word
compile the next word. The next word should not be immediate, in which case you would have to use [COMPILE]. For this reason, you should use the word POSTPONE, which takes care it.
 simulate:
   : COMPILE  R> DUP @ , CELL+ >R ;  ( not immediate !!! )

reference: p4_compile in ../src/forth-83.c:0067, export CS COMPILE

INVERT ( value -- value' )  

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

reference: p4_invert in ../src/core.c:1344, export CO NOT

VOCABULARY name ( -- )  

create a vocabulary of that name. If the named vocabulary is called later, it will run ((VOCABULARY)) , thereby putting it into the current search order. Special pfe-extensions are accessible via CASE-SENSITIVE-VOC and SEARCH-ALSO-VOC
 simulate:
   : VOCABULARY  CREATE ALLOT-WORDLIST
        DOES> ( the ((VOCABULARY)) runtime )
          CONTEXT ! 
   ; IMMEDIATE

reference: p4_vocabulary in ../src/forth-83.c:0096, export CO VOCABULARY

<MARK ( -- DP-mark )   compile-only

memorizes the current DP on the CS-STACK used for <RESOLVE later. Useful for creation of compiling words, eg. BEGIN , see AHEAD
 simulate:
   : <MARK ?COMP  HERE ;

reference: p4_backward_mark in ../src/forth-83.c:0165, export CO <MARK

<RESOLVE ( DP-mark -- )   compile-only

resolves a previous <MARK , actually pushes the DP-address memorized at BRANCH or ?BRANCH in compiling words like UNTIL
 simulate:
   : <RESOLVE ?COMP  , ;

reference: p4_backward_resolve in ../src/forth-83.c:0179, export CO <RESOLVE

MARK> ( -- DP-mark )   compile-only

makes room for a pointer in the dictionary to be resolved through RESOLVE> and does therefore memorize that cell's address on the CS-STACK Mostly used after BRANCH or ?BRANCH in compiling words like IF or ELSE
 simulate:
   : MARK> ?COMP  HERE 0 , ;

reference: p4_forward_mark in ../src/forth-83.c:0198, export CO MARK>

RESOLVE> ( DP-mark -- )   compile-only

resolves a pointer created by MARK> Mostly used in compiling words like THEN
 simulate:
   : RESOLVE> ?COMP  HERE SWAP ! ;

reference: p4_forward_resolve in ../src/forth-83.c:0210, export CO RESOLVE>

((ELSE)) ( -- )  

execution compiled by ELSE - just a simple BRANCH

reference: p4_else_execution in ../src/forth-83.c:0156, export CO BRANCH

?BRANCH  

*********************************************************************

reference: p4_if_execution in ../src/forth-83.c:0155, export CO ?BRANCH

CONTEXT  
dict-variable
SEARCH ORDER variables, for VOCABULARY ALSO DEFINITIONS

reference: context in ../src/forth-83.c:0482, export DV CONTEXT

CURRENT  
dict-variable
SEARCH ORDER variables, for VOCABULARY ALSO DEFINITIONS

reference: current in ../src/forth-83.c:0483, export DV CURRENT

--> ( -- )   no-return
immediate
does increase BLK and refills the input-buffer from there. Does hence break interpretation of the current BLK and starts with the next. Old-style forth mechanism. You should use INCLUDE

reference: p4_next_block in ../src/forth-83.c:0231, export CI -->

INTERPRET  

the INTERPRET is the internal inner interpreter, which you would usually not call directly. Use the word EVALUATE now. The QUIT outer interpreter does call this routine.
 example:
   : QUIT (COLD) BEGIN CR QUERY INTERPRET ?STACK OK REPEAT ; 

reference: p4_interpret in doc-pfe.cdoc:0072, export CO INTERPRET

K ( -- counter-val )  

the 3rd loop index just like I and J

reference: p4_k in ../src/forth-83.c:0240, export CO K

OCTAL ( -- )  

sets BASE to 8. Compare with HEX and DECIMAL
 simulate:
   : OCTAL  8 BASE ! ;

reference: p4_octal in ../src/forth-83.c:0250, export CO OCTAL

SP@ ( -- )  

the address of the top of stack. Does save it onto the stack. You could do
   : DUP  SP@ @ ;

reference: p4_s_p_fetch in ../src/forth-83.c:0260, export CO SP@

!BITS ( bits addr mask -- )  

at the cell pointed to by addr, change only the bits that are enabled in mask
 simulate:
   : !BITS  >R 2DUP @ R NOT AND SWAP R> AND OR SWAP ! DROP ;

reference: p4_store_bits in ../src/forth-83.c:0277, export CO !BITS

@BITS ( addr mask -- value )  

see the companion word !BITS
 simulate:
   : @BITS  SWAP @ AND ;

reference: p4_fetch_bits in ../src/forth-83.c:0339, export CO @BITS

>< ( a -- a' )  

byte-swap a word

reference: p4_byte_swap in ../src/forth-83.c:0302, export CO ><

>MOVE< ( from-addr to-addr count -- )  

see MOVE , does byte-swap for each word underway

reference: p4_byte_swap_move in ../src/forth-83.c:0318, export CO >MOVE<

** ( a b -- r )  

raise second to top power

reference: p4_power in ../src/forth-83.c:0290, export CO **

DPL  
dict-variable
the DPL is the decimal point for double numbers as seen in >NUMBER

reference: dpl in doc-pfe.cdoc:0063, export DV DPL

SEAL ( -- )  

looks through the search-order and kills the ONLY wordset - hence you can't access the primary vocabularies from there.

reference: p4_seal in ../src/forth-83.c:0353, export CO SEAL

BODY> ( pfa -- cfa )  

converts a pointer to the parameter-field (PFA) to point then to the corresponding code-field (CFA)
 implementation-specific simulation:
   : BODY> CELL - ;

reference: p4_body_from in ../src/forth-83.c:0392, export CO BODY>

>LINK ( cfa -- lfa )  

converts a pointer to the code-field (CFA) to point then to the corresponding link-field (LFA)

reference: p4_to_link in ../src/forth-83.c:0381, export CO >LINK

LINK> ( lfa -- cfa )  

converts a pointer to the link-field (LFA) to point then to the corresponding code-field (CFA)

reference: p4_link_from in ../src/forth-83.c:0412, export CO LINK>

>NAME ( cfa -- nfa )  

converts a pointer to the code-field (CFA) to point then to the corresponding name-field (NFA)
 implementation-specific simulation:
   : >NAME  >LINK L>NAME ;

reference: p4_to_name in ../src/forth-83.c:0372, export CO >NAME

NAME> ( nfa -- cfa )  

converts a pointer to the name-field (NFA) to point then to the corresponding code-field (CFA)
 implementation-specific simulation:
   : NAME>  N>LINK LINK> ;

reference: p4_name_from in ../src/forth-83.c:0403, export CO NAME>

L>NAME ( lfa -- nfa )  

converts a pointer to the link-field (LFA) to point then to the corresponding name-field (CFA)

reference: p4_l_to_name in ../src/forth-83.c:0421, export CO L>NAME

N>LINK ( nfa -- lfa )  

converts a pointer to the name-field (NFA) to point then to the corresponding link-field (LFA)
 implementation-specific configure-dependent simulation:
   : N>LINK  C@ + ;

reference: p4_n_to_link in ../src/forth-83.c:0432, export CO N>LINK

>FFA ( nfa -- ffa )  

converts a pointer to the name-field (NFA) to point then to the corresponding flag-field (FFA) - in traditinal Forth this is the same address. pfe _can_ do different.
 implementation-specific configure-dependent simulation:
   : FFA  1- ;

reference: p4_to_ffa in ../src/forth-83.c:0444, export CO >FFA

FFA> ( ffa -- nfa )  

converts a pointer to the flag-field (FFA) to point then to the corresponding name-field (NFA) - in traditinal Forth this is the same address. pfe _can_ do different.
 implementation-specific configure-dependent simulation:
   : FFA  1+ ;

reference: p4_ffa_from in ../src/forth-83.c:0458, export CO FFA>

CASE-SENSITIVE-VOC ( -- )  

accesses CONTEXT which is generally the last named VOCABULARY . sets a flag in the vocabulary-definition so that words are matched case-sensitive.
 example: 
    VOCABULARY MY-VOC  MY-VOC CASE-SENSITIVE-VOC

reference: p4_case_sensitive_voc in ../src/forth-83.c:0109, export CO CASE-SENSITIVE-VOC

SEARCH-ALSO-VOC ( -- )  

binds CONTEXT with CURRENT. If the CURRENT VOCABULARY is in the search-order (later), then the CONTEXT vocabulary will be searched also. If the result of this word could lead into a recursive lookup with FIND it will throw CURRENT_DELETED and leave the CURRENT VOCABULARY unaltered.
 example:
MY-VOC DEFINITIONS MY-VOC-PRIVATE SEARCH-ALSO-VOC

reference: p4_search_also_voc in ../src/forth-83.c:0124, export CO SEARCH-ALSO-VOC