X-Git-Url: https://git.rrq.au/?a=blobdiff_plain;f=reference.html;h=9137d075cfd0bd68e35fda305d8050d21cc8f636;hb=433a6cc4e7fccb418345a78de099a4e15891abcf;hp=7b6cb8a76ba03b4ffab29e3c1afa8e80369db11c;hpb=b49fed131d5a7806d0737bdc6f9b693c64753cf2;p=rrq%2Frrqforth.git diff --git a/reference.html b/reference.html index 7b6cb8a..9137d07 100644 --- a/reference.html +++ b/reference.html @@ -770,17 +770,24 @@ asciidoc.install(); !   C@   C!   +W@   +W!   +D@   +D!   2@   2!   !+   @n++   @n--   C,   -S"   +W,   +D,   +S"   >R   R@   R>   -R[n]  

+R[n]   +D[n]  

DATA-STACK   RETURN-STACK     @@ -801,10 +808,12 @@ asciidoc.install(); BEGIN   BREAK  

CFA>FLAGS@   +CFA>TFA   CLEAR-STREAM   CREATE   CURRENT-WORDLIST  

DECIMAL   +DEFINITIONS   DEPTH   DIGITS   /MOD   @@ -838,10 +847,13 @@ asciidoc.install(); IMMEDIATE   INPUT  

LIT   +LIT-STRING   LOAD-BUFFER-SIZE   LOAD-FILE  

MAIN-ARGS   -MALLOC  

+MALLOC   +MIN   +MAX  

NEGATE   NIP   NL   @@ -855,8 +867,10 @@ asciidoc.install(); PROGRAM_VERSION  

QUIT  

READ-STREAM-CHAR   +READ-STREAM-LINE   READ-WORD   REALLOC   +RETURN   ROLL   ROT   RSP  

@@ -865,6 +879,7 @@ asciidoc.install(); STDIN   STREAM   STREAM-NCHARS   +STR>TEMP   STRLEN   STRNCMP   STRNCPY   @@ -872,6 +887,10 @@ asciidoc.install(); SYSTEM  

TELL   .TEMP   +TEMP   +TEMPHELD   +TEMPSPACE   +TEMPUSED   TERMINATE0   TFA>CFA   TFA>DFA   @@ -881,7 +900,8 @@ asciidoc.install(); THIS-WORD   TRUE   TUCK  

-

UNSTREAM  

+

UNSTREAM   +USE  

VERBOSE?  

WITHIN   WORDS  

@@ -1134,6 +1154,85 @@ at the current free head address, which also is incremented.

_______________________________________________________
+

+ +
+

Word: W,

+
+
+
Data stack: ( v -- )
+
+

"W," (W-comma) is a function word that puts a "word" (double-byte) on +the HERE heap. The two least significant bytes of the value +are put at the current free head address, which also is incremented +accordingly.

+
+
+
+
+
Definition concept for W,
+

: W, HERE @ 2 ALLOT W! ;

+
+
+
+_______________________________________________________ +
+

+
+
+

Word: D,

+
+
+
Data stack: ( v -- )
+
+

"D," (D-comma) is a function word that puts a "double word" +(double-byte) on the HERE heap. The four least significant +bytes of the value are put at the current free head address, which +also is incremented accordingly.

+
+
+
+
+
Definition concept for D,
+

: D, HERE @ 4 ALLOT D! ;

+
+
+
+_______________________________________________________ +
+

+
+
+

Word: D[n]

+
+
+
Data stack: ( n -- a )
+
+

"D[n]" is a function word that pushes the address for the n:th cell of +the data stack onto the data stack.

+
+_______________________________________________________ +
+

+
+
+

Word: CFA>TFA

+
+
+
Data stack: ( cfa -- tfa )
+
+

"CFA>TFA" is a function word that pushes word tfa of the given cfa.

+
+
+
+
+
Definition concept for CFA>TFA
+

: CFA>TFA 14 - @ ;

+
+
+
+_______________________________________________________ +

@@ -1146,6 +1245,32 @@ _______________________________________________________
_______________________________________________________
+

+
+
+

Word: W@

+
+
+
Data stack: ( a -- v )
+
+

"W@" is a function word that pushes the "word" (double-byte) value v +from the address a.

+
+_______________________________________________________ +
+

+
+
+

Word: R@

+
+
+
Data stack: ( -- v )   Return stack: ( v -- v )
+
+

"R@" is a function word that "copies" the top return stack value onto +the data stack.

+
+_______________________________________________________ +

@@ -1159,10 +1284,36 @@ significant byte of the cell) at the address a.

_______________________________________________________
+

+ +
+

Word: W!

+
+
+
Data stack: ( v a -- )
+
+

"W!" is a function word that stores the "word" (2-byte) value v (the +two least significant bytes of the cell) at the address a.

+
+_______________________________________________________ +
+

+
+
+

Word: D!

+
+
+
Data stack: ( v a -- )
+
+

"D!" is a function word that stores the "doublw word" (4-byte) value v +(the four least significant bytes of the cell) at the address a.

+
+_______________________________________________________ +

-

Word: R@

+

Word: R@

Data stack: ( -- v )   Return stack: ( v -- v )
@@ -1264,7 +1415,8 @@ _______________________________________________________

"ARGS" is a value word that holds a pointer to the command line data block which consists of a count cell followed by that many asciiz -pointers and then a 0 cell.

+pointers and then a 0 cell. That is next followed by the environment +as a number of asciiz pointers and a 0 cell.

@@ -1272,9 +1424,10 @@ pointers and then a 0 cell.

ARGS -> 8 bytes: count of non-zero asciiz pointers following
         8 bytes: command name string
-        8 bytes: first argument string
-        8* ...
-        8 zero
+ 8* bytes: argument strings + 8 bytes: zero cell + 8* bytes: envirnment strings + 8 bytes: zero cell
@@ -1634,6 +1787,27 @@ _______________________________________________________
_______________________________________________________
+

+
+
+

Word: DEFINITIONS

+
+
+
Data stack: ( wordlist -- )
+
+

"DEFINITIONS" is a function word that installs the given wordlist as +the CURRENT-WORDLIST one.

+
+
+
+
+
Definition concept for DEFINITIONS
+

: DEFINITIONS CURRENT-WORDLIST ! ;

+
+
+
+_______________________________________________________ +

@@ -2112,11 +2286,10 @@ _______________________________________________________

Word: EXIT

-
Data stack: ( -- )
+
Data stack: ( v -- )
-

"EXIT" is a function word that implements the ending of a FORTH -definition and its threading to the subsequent step of the calling -definition.

+

"EXIT" is a function word that terminates the rrqforth process +immediately with the given exit code.

_______________________________________________________
@@ -2498,22 +2671,40 @@ _______________________________________________________

-

Word: S"

+

Word: LIT-STRING

Data stack: ( -- chars* n )
-

"S"" is a function word that pushes the [n:char] pointer for a string -inlined subsequently to it in the containing definition. This is -similar to LIT but for a string literal.

+

"LIT-STRING" is a function word that pushes the char* and length n of +a subsequent inline string, then advances execution to continue after +the string. This is similar to LIT but for a block literal.

+

Note that the inlined byte count includes the terminating NUL byte.

-
Definition concept for LIT
-

: LIT R> DUP @ 2DUP + 8 + >R SWAP 8 + SWAP ;

+
Definition concept for LIT-STRING
+

: LIT-STRING R@ DUP @ 8 + R@ @ 2DUP + R> + >R 1 - ;

+
+
+_______________________________________________________ +
+

+
+
+

Word: S"

+
+
+
Data stack: ( -- )  Input stream: " chars"
+

"S"" is an immediate function word that compiles the subseqent +characters up to terminating double-quote into the current definition, +preceded by a LIT-STRING cell, and the count of +bytes scanned. The inline text includes a terminating NUL character +which also is included in the inlined count.

+

Note that "S"" uses " for reading the string.

_______________________________________________________
@@ -2584,6 +2775,32 @@ page" of mmap for details.

_______________________________________________________
+

+ +
+

Word: MAX

+
+
+
Data stack: ( v1 v2 -- v3 )
+
+

"MAX" is a function word that selects the greatest of v1 and v2. To +that end, the values are 64-bit signed integers.

+
+_______________________________________________________ +
+

+
+
+

Word: MIN

+
+
+
Data stack: ( v1 v2 -- v3 )
+
+

"MIN" is a function word that selects the least of v1 and v2. To that +end, the values are 64-bit signed integers.

+
+_______________________________________________________ +

@@ -2868,8 +3085,8 @@ _______________________________________________________
Data stack: ( n -- a )
-

"R[n]" is a function word that pushes the address for the n:th cell on -the top return stack value onto the data stack.

+

"R[n]" is a function word that pushes the address for the n:th cell of +the return stack onto the data stack.

@@ -2899,6 +3116,22 @@ instead.

_______________________________________________________
+

+
+
+

Word: READ-STREAM-LINE

+
+
+
Data stack: ( stream -- n )
+
+

"READ-STREAM-LINE" is a function word that gets the next line from the +given stream buffer into PAD and returns number of characters. If the +stream is backed by a file descriptor, the stream buffer is refilled +from there as needed, by a SYS_READ call when more characters are +needed.

+
+_______________________________________________________ +

@@ -2945,6 +3178,20 @@ kernel, and the granularity is in pages, i.e. a multiple of 4 kb.

_______________________________________________________
+

+
+
+

Word: RETURN

+
+
+
Data stack: ( -- )
+
+

"RETURN" is a function word that implements the ending of a FORTH +definition and make execution return to the next step in the calling +definition.

+
+_______________________________________________________ +

compile.asm: WORD p_right_bracket,],fasm

@@ -3012,8 +3259,9 @@ _______________________________________________________
Data stack: ( -- )
-

";" (semi-colon) is a function word that ends a new forth definition -by means of adding an EXIT

+

";" (semi-colon) is an immediate function word that ends a new forth +definition by means of adding an EXIT cell, then changing +<<p_state,STATE> to interpreting.

@@ -3178,6 +3426,29 @@ stream (or filling it by reading the backing file).

_______________________________________________________
+

+
+
+

Word: STR>TEMP

+
+
+

Data stack: ( char* n — char* n )

+
+

"STR>TEMP" is a function word that copies a given string plus a +terminating NUL character into a TEMPSPACE snippet, +all preceded by a length cell. It returns a pointer for to the text in +the snippet and its length, excluding the NUL character at end and the +length cell before tie text.

+
+
Layout for copied string
+
+
        length: 8 bytes
+returned char*: n bytes
+           nul: 1 byte
+
+
+_______________________________________________________ +

@@ -3263,6 +3534,90 @@ descriptor 1).

_______________________________________________________
+

+
+
+

Word: TEMP

+
+
+

Data stack: ( size — addr )

+
+

"TEMP" is a function word that "allocates" a TEMPSPACE +area of given size and returns its base address. The allocation is +temporary and only valid until there is a later allocation that +overruns this area.

+

Allocations are done in succession until the requested size overruns +the TEMPSPACE. If so, the allocation pointer is reset +and the space is allocated from start again. This is all intended for +small and short-lived data areas.

+
+_______________________________________________________ +
+

+
+
+

Word: TEMPHELD

+
+
+
Data stack: ( -- a )
+
+

"TEMPHELD" is a variable word that keeps the lowest offset of the +TEMPSPACE space to reuse upon cycling. The space +below TEMPHELD is "held" in the sense of not being reused upon +cycling. An application may change the TEMPSPACE offset as needed to +dynamically preserve memory longer term.

+
+_______________________________________________________ +
+

+
+
+

Word: TEMPSPACE

+
+
+
Data stack: ( -- a )
+
+

"TEMPSPACE" is a variable word that holds three cells the for managing +"temporary memory":

+
+

This memory is intended to be used by requesting snippets of memory in +a cyclic fashion via TEMP without concern about it possibly +overlapping a prior request.

+
+_______________________________________________________ +
+

+
+
+

Word: TEMPUSED

+
+
+
Data stack: ( -- a )
+
+

"TEMPUSED" is a variable word that keeps the lowest offset of the +TEMPSPACE space to use next as temporary space. This +is advance upon each allocation via TEMP, and recycled back +to TEMPHELD when next allocation otherwise would exceed +the space size.

+
+_______________________________________________________ +

@@ -3462,8 +3817,24 @@ at (stream* + 16) is its size.

_______________________________________________________
-

+

+ + +
+

Word: USE

+
+
+
Data value: ( wordlist -- )  Input stream: word
+
+

"USE" is a function word that looks up next word given the wordlist. +It reads next word on INPUT via READ-WORD, +then temporarily changes CURRENT-WORDLIST to +FIND the word via the given wordlist, and returns the TFA +of that word, or just 0 if the word coudn’t be found.

+
+_______________________________________________________
+

Word: VERBOSE?

@@ -3554,7 +3925,7 @@ is deepest.