X-Git-Url: https://git.rrq.au/?a=blobdiff_plain;f=reference.html;h=9cb4b59609eabf30834431443a2a66a96331f340;hb=97bcab28825fde3e717ac5489b0f3f19e5e3f5db;hp=f57f5c8805811feb0fa67dcb88aee1b7a7ee5d6d;hpb=c8819ee75b180664d649f542f4448122f6c4cdce;p=rrq%2Frrqforth.git diff --git a/reference.html b/reference.html index f57f5c8..9cb4b59 100644 --- a/reference.html +++ b/reference.html @@ -770,17 +770,23 @@ asciidoc.install(); ! C@ C! +W@ +W! +D@ +D! 2@ 2! !+ @n++ @n-- C, -S" +W, +D, +S" >R R@ R> -R[n]
+R[n]DATA-STACK RETURN-STACK @@ -793,6 +799,7 @@ asciidoc.install(); 2OVER 2SWAP
Note that the FORTH compiler does not invoke an assembler so any +inline assembly code must be provided in its binary form.
Note that the branch offset is a byte count and each FORTH word of a +definition take up a cell of 8 bytes. The offset is relative to the +cell address immediately subsequent to the offset cell. In other +words, offset 0 is not branching anywhere and an offset of -16 would +make a tight loop back to the branch instruction itself. The latter +would pull data stack values until and including the first non-zero +value.
"0=" is a function word that replaces a value with its logical complement; the result is zero if the value non-zero, and the result is non-zero if the value is zero.
Compare with NOT.
This is the same function as NOT.
Note that the branch offset is a byte count and each FORTH word of a +definition take up a cell of 8 bytes. The offset is relative to the +cell address immediately subsequent to the offset cell. In other +words, offset 0 is not branching anywhere and an offset of -16 would +make a tight loop back to the branch instruction itself. The latter +would pull data stack values until and including the first zero value.
See also :, [p_comma]. HERE, @, @@ -1108,6 +1148,72 @@ at the current free head address, which also is incremented.
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.
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.
Data stack: ( cfa -- tfa )
+"CFA>TFA" is a function word that pushes word tfa of the given cfa.
Data stack: ( a -- v )
+"W@" is a function word that pushes the "word" (double-byte) value v +from the address a.
Data stack: ( -- v ) Return stack: ( v -- v )
+"R@" is a function word that "copies" the top return stack value onto +the data stack.
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.
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.
Data stack: ( -- v ) Return stack: ( v -- v )
@@ -1172,6 +1330,23 @@ value. To that end, the values are 64-bit signed integers.Data stack: Compiling: ( -- a )
+"AGAIN" is an immediate function word that is used together with +BEGIN and instead of END to implement structured +execution control. AGAIN scans the datastack for the nearest preceding +BEGIN marker and lays out an unconditional branch from this point the +beginning of the block during execution. It thereafter performs the +END compile action to end the block.
See also DIGITS, which holds the mapping table from digits to text.
CREATE FOO BASE
: WTELL ( tfa -- ; Print word pname )
+ 24 + DUP 8 + SWAP @ TELL SP EMIT
+;
+
+: WORDS ( wordlist -- ; Print all words of word list )
+ BEGIN
+ @ DUP 0= IFBREAK
+ DUP WTELL
+ END
+ DROP
+ NL EMIT
+;
+"[']" is an immediate function word that reads the next word on the input stream and pushes its cfa.
"BRANCH" is a function word that implements execution transfer by means of adding the subsequent branch offset to the point of execution.
Note that the branch offset is a byte count and each FORTH word of a +definition take up a cell of 8 bytes. The offset is relative to the +cell address immediately subsequent to the offset cell. In other +words, offset 0 is not branching anywhere and an offset of -16 would +make a tight loop back to the branch instruction itself. The latter +would pull data stack values until and including the first zero value.
: WTELL ( tfa -- ; Print word pname )
+ 24 + DUP 8 + SWAP @ TELL SP EMIT
+;
+
+: WORDS ( wordlist -- ; Print all words of word list )
+ BEGIN
+ @ DUP IF DUP WTELL ELSE BREAK THEN
+ 1 IFAGAIN
+ END
+ DROP
+ NL EMIT
+;
+See also doFORTH, READ-WORD, @@ -1397,10 +1625,10 @@ _______________________________________________________ HERE heap.
See also :, [p_Ccomma]. HERE, @, @@ -1422,6 +1650,7 @@ Address) of the word. The header memory layout is as follows:
struct WORD
TFA 8 link ; tfa of previous word
@@ -1448,10 +1677,10 @@ function words initiated by ":" (aka "COLON") or changed to "dovalue"
for RRQFORTH constants created by "CONSTANT".