figForth Word - INTERPRET

  Some parts of this page/site are currently incomplete & will be updated asap
  Other parts will change continually so use “Refresh” in your browser !!
  There is extensive use of “Tooltips” text to support learning which do
not seem to render on a Smartphone


INTERPRET The outer text interpreter which sequentially executes or compiles text from the input stream (terminal or disc) depending on STATE. If the word name cannot be found after a search of CONTEXT and then CURRENT it is converted to a number according to the current base. That also failing, an error message echoing the name with a “ ?” will be given. Text input will be taken according to the convention for WORD. If a decimal point is found as part of a number, a double number value will be left. The decimal point has no other purpose than to force this action. See NUMBER

“INTERPRET is the text interpreter which sequentially executes or compiles text from the input stream depending on STATE. If the word cannot be found after searching CONTEXT and CURRENT, it is converted to a number according to the current base. That also failing, an error message echoing the name with a “?” will be printed”

NFA:    00705B 89            DB   89H
        00705C 494E5445 52505245  DB   "INTERPRE"
        007064 D4            DB   'T'+80H
LFA:    007065 3070          DW   QSTAC-9
CFA:    007067 3C28   INTER: DW   DOCOL
PFA:    007069        INTE1:                   ; BEGIN       Start the interpretation loop
        007069 076F          DW	DFIND	; -FIND
        00706B DA21          DW	ZBRAN
        00706D 1E00          DW	INTE2-$	; IF
        00706F 7768          DW	STATE	;	STATE
        007071 8F27          DW	AT		;	@
        007073 6569          DW	LESS		;	<
        007075 DA21          DW	ZBRAN	;	IF
        007077 0A00          DW	INTE3-$
        007079 4D6A          DW	CFA		;	CFA
        00707B 2369          DW	COMMA	;	,
        00707D C221          DW	BRAN		;	ELSE
        00707F 0600          DW	INTE4-$
        007081 4D6A   INTE3: DW	CFA		;   CFA
        007083 B321          DW	EXEC		;   EXECUTE
        007085        INTE4:                ;   THEN
        007085 3970          DW	QSTAC	;	?STACK
        007087 C221          DW	BRAN		; ELSE
        007089 1C00          DW	INTE5-$
        00708B 0769   INTE2: DW	HERE		;	HERE     Start of the text string on top of the dictionary
        00708D 7D6E          DW	NUMB		;	NUMBER   Convert the string at HERE to a signed double number, using the current base
                                                         If a decimal point is encountered in the text, its position is stored in DPL. If numeric conversion is not possible, an error message will be given and QUIT
        00708F 8A68 8F27     DW   DPL,AT    ;   DPL @        Is there a decimal point?
        007093 D368          DW	ONEP		;	1+           If there is, DPL + 1 should be greater than zero (true)
        007095 DA21 0800     DW   ZBRAN,INTE6-$ ;  IF        Decimal point was detected
        007099 1E70          DW	DLITE           ;   DLITERAL    If compiling, compile the double number on stack into a
                                                                   literal, which will be pushed on stack during execution. If executing, the number remains on stack...
        00709B C221 0600     DW   BRAN,INTE7-$  ;  ELSE         No decimal point, the number should be a single 16 bit number
        00709F CC26   INTE6: DW   DROP          ;   DROP        Discard the high order part of the double number
        0070A1 0170          DW   LITER         ;   LITERAL     If compiling, compile the number on stack as a literal
                                                                  The number is left on stack if executing...
        0070A3 3970   INTE7: DW   QSTAC         ;   ?STACK      Check the data stack overflow or underflow
                                                ;  THEN
        0070A5        INTE5:                    ; THEN     End of the IF clause after -FIND
        0070A5 C221 C2FF     DW   BRAN,INTE1-$  ; AGAIN    Repeat interpretation of the next text string in the input stream

BEGIN
    -FIND   Move the next word from input stream to HERE and search the CONTEXT and then the CURRENT
            vocabularies for a matching entry
            If found, the dictionary entry's parameter field address, its length byte, and a boolean
            true flag are left on stack, otherwise, only a false flag is left...
    IF      A matching entry is found. Do the following:
        STATE @ <   If the length byte < state , the word is to be compiled
            IF
                CFA ,   Compile the code field address of this word to the dictionary
            ELSE        Length byte > state, this is an immediate word,
                CFA     then put the code field address on the data stack and
                EXECUTE call the address interpreter to execute this word
            THEN
        ?STACK      Check the data stack. If overflow or underflow, print error message and jump to QUIT
    ELSE            No matching entry. Try to convert the text to a number
        HERE        

The Meaning of the Dictionary Fields:

NFALFACFAPFA

“The text interpreter seems to be in an infinite loop without an exit, except the error handling procedures in ?STACK and NUMBER. The normal exit from this loop, after successfully interpreting a line of text, is buried in a mysterious, nameless word called NULL or ‘X’ in the Forth source code. The true name of this procedure is an ASCII NUL character, which cannot be accessed from the terminal. The text input procedure appends an ASCII NUL character to the end of a text input stream in place of a carriage return which terminates the text stream. After the text stream is successfully processed, the text interpreter will pick up this null character and execute the NULL procedure”


Updated: 31st August 2022 by David Husband
© 2021 David Husband, a.k.a. Baremetal Engineer Extraordinaire
All Rights Reserved – All Trademarks & Copyrights Acknowledged
All personal information is subject to the Data Protection Act 2018 & the UK GDPR
“ad auxilium aliis ad auxilium sibi”