X-Git-Url: https://git.rrq.au/?a=blobdiff_plain;f=reference.html;h=9cb4b59609eabf30834431443a2a66a96331f340;hb=e7f64d44f6ca8a9eaf89945e83af5828a1a16953;hp=988e55177cc3476fd286dc94d7b0324a2893bef9;hpb=d7958ae7b474ef357864237fc40412139e43b117;p=rrq%2Frrqforth.git diff --git a/reference.html b/reference.html index 988e551..9cb4b59 100644 --- a/reference.html +++ b/reference.html @@ -770,13 +770,19 @@ asciidoc.install(); !   C@   C!   +W@   +W!   +D@   +D!   2@   2!   !+   @n++   @n--   C,   -S"   +W,   +D,   +S"   >R   R@   R>   @@ -840,6 +846,7 @@ asciidoc.install(); IMMEDIATE   INPUT  

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

MAIN-ARGS   @@ -868,6 +875,7 @@ asciidoc.install(); STDIN   STREAM   STREAM-NCHARS   +STR>TEMP   STRLEN   STRNCMP   STRNCPY   @@ -875,6 +883,8 @@ asciidoc.install(); SYSTEM  

TELL   .TEMP   +TEMP   +TEMPSPACE   TERMINATE0   TFA>CFA   TFA>DFA   @@ -1138,6 +1148,52 @@ 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! ;

+
+
+
+_______________________________________________________ +

@@ -1170,6 +1226,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.

+
+_______________________________________________________ +

@@ -1183,10 +1265,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 )
@@ -2542,25 +2650,43 @@ _______________________________________________________

-

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.

+
+_______________________________________________________ +

@@ -3070,8 +3196,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.

@@ -3236,6 +3363,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
+
+
+_______________________________________________________ +

@@ -3321,6 +3471,58 @@ 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: TEMPSPACE

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

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

+
    +
  • +

    +the size of the temporary memory space (default 104857600 bytes) +

    +
  • +
  • +

    +the base address for whole temporary memory area +

    +
  • +
  • +

    +the amount currently used +

    +
  • +
+

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.

+
+_______________________________________________________ +

@@ -3628,7 +3830,7 @@ is deepest.