📄 gforth.htm
字号:
<p><kbd>.(</kbd> is an immediate word.</p>
<hr><p><pre><b>.DIAGRAM ( DEFINITION -- )</b></pre></p>
<p>Display the stack diagram of <kbd>DEFINITION</kbd> in a user-readable
format, plus a trailing space character.</p>
<hr><p><pre><b>.ERROR ( SIGNED -- )</b></pre></p>
<p>If <kbd>SIGNED</kbd> is not equal to zero, display an error message
depending on the value of <kbd>SIGNED</kbd>.</p>
<p>Display the current line of the input source up to and including the
most recently parsed word, plus an error message associated with the
error code <kbd>SIGNED</kbd>. Display the data types of the items
currently on the data stack on a second line.</p>
<hr><p><pre><b>.R ( DOUBLE INTEGER -- )</b></pre></p>
<p>Display <kbd>DOUBLE</kbd> as an unsigned double-precision number
right aligned in a field <kbd>INTEGER</kbd> characters wide.
<kbd>INTEGER</kbd> is assumed to be a signed number.
If <kbd>INTEGER</kbd> is not positive or the number of characters
required to display <kbd>DOUBLE</kbd> is greater than
<kbd>INTEGER</kbd>, all digits are displayed with no leading spaces
in a field as wide as necessary.</p>
<hr><p><pre><b>.R ( SIGNED-DOUBLE INTEGER -- )</b></pre></p>
<p>Display <kbd>SIGNED-DOUBLE</kbd> as a signed double-precision number
right aligned in a field <kbd>INTEGER</kbd> characters wide.
<kbd>INTEGER</kbd> is assumed to be a signed number.
If <kbd>INTEGER</kbd> is not positive or the number of characters
required to display <kbd>SIGNED-DOUBLE</kbd> is greater than
<kbd>INTEGER</kbd>, all digits are displayed with no leading spaces
in a field as wide as necessary.</p>
<hr><p><pre><b>.R ( SINGLE INTEGER -- )</b></pre></p>
<p>Display <kbd>SINGLE</kbd> as an unsigned number right aligned in a
field <kbd>INTEGER</kbd> characters wide.
<kbd>INTEGER</kbd> is assumed to be a signed number.
If <kbd>INTEGER</kbd> is not
positive or the number of characters required to
display <kbd>SINGLE</kbd> is greater than <kbd>INTEGER</kbd>, all digits
are displayed with no leading spaces in a field as wide as necessary.</p>
<hr><p><pre><b>.R ( SIGNED INTEGER -- )</b></pre></p>
<p>Display <kbd>SIGNED</kbd> as a signed number right aligned
in a field <kbd>INTEGER</kbd> characters wide.
<kbd>INTEGER</kbd> is assumed to be a signed number. If
<kbd>INTEGER</kbd> is not positive or the number of characters required
to display <kbd>SIGNED</kbd> is greater than
<kbd>INTEGER</kbd>, all digits are displayed with no leading spaces
in a field as wide as necessary.</p>
<hr><p><pre><b>.S ( -- )</b></pre></p>
<p>Display the data types on the data type heap.
In interpretation state, the interpreter data type heap is used.
In compilation state, the compiler data type heap is used.</p>
<p>Other than ANS Forth, <kbd>.S</kbd> does not display the
values of the items on the data stack.</p>
<p><kbd>.S</kbd> is an immediate word.</p>
<hr><p><pre><b>/ ( UNSIGNED UNSIGNED -- 1ST )</b></pre></p>
<p>Divide the first <kbd>UNSIGNED</kbd> by the second <kbd>UNSIGNED</kbd>,
giving the unsigned quotient <kbd>1ST</kbd>. An ambiguous condition exists
if the second <kbd>UNSIGNED</kbd> is zero.</p>
<hr><p><pre><b>/ ( SIGNED SIGNED -- 1ST )</b></pre></p>
<p>Divide the first <kbd>SIGNED</kbd> by the second <kbd>SIGNED</kbd>,
giving the signed quotient <kbd>1ST</kbd>. An ambiguous condition exists
if the second <kbd>SIGNED</kbd> is zero. If both operands differ in sign,
the result returned will be the same as that
returned by the phrase <kbd>SWAP S>D SWAP SM/REM SWAP DROP</kbd>.</p>
<hr><p><pre><b>/ ( UNSIGNED-DOUBLE UNSIGNED -- 1ST )</b></pre></p>
<p>Divide <kbd>UNSIGNED-DOUBLE</kbd> by <kbd>UNSIGNED</kbd>, giving the
unsigned double-precision quotient <kbd>1ST</kbd>. An ambiguous condition exists
if <kbd>UNSIGNED</kbd> is zero.</p>
<hr><p><pre><b>/MOD ( UNSIGNED UNSIGNED -- 2ND 1ST )</b></pre></p>
<p>Divide the first <kbd>UNSIGNED</kbd> by the second <kbd>UNSIGNED</kbd>,
giving the unsigned remainder <kbd>2ND</kbd> and the unsigned
quotient <kbd>1ST</kbd>. An ambiguous condition exists if the
second <kbd>UNSIGNED</kbd> is zero.</p>
<hr><p><pre><b>/MOD ( SIGNED SIGNED -- 2ND 1ST )</b></pre></p>
<p>Divide the first <kbd>SIGNED</kbd> by the second <kbd>SIGNED</kbd>,
giving the signed remainder <kbd>2ND</kbd> and the signed
quotient <kbd>1ST</kbd>. An ambiguous condition exists if the
second <kbd>UNSIGNED</kbd> is zero. If both operands differ in sign, the
result returned will be the same as that returned
by the phrase <kbd>SWAP S>D SWAP SM/REM</kbd>.</p>
<hr><p><pre><b>/MOD ( UNSIGNED-DOUBLE UNSIGNED -- 2ND 1ST )</b></pre></p>
<p>Divide <kbd>UNSIGNED-DOUBLE</kbd> by <kbd>UNSIGNED</kbd>,
giving the unsigned single-precision remainder <kbd>2ND</kbd> and the
unsigned double-precision quotient <kbd>1ST</kbd>. An ambiguous condition exists
if <kbd>UNSIGNED</kbd> is zero.</p>
<hr><p><pre><b>/STRING ( CADDRESS -> CHARACTER UNSIGNED INTEGER -- 1ST 3RD )</b></pre></p>
<p>Adjust the character string at <kbd>CADDRESS -> CHARACTER</kbd>
with length <kbd>UNSIGNED</kbd> by <kbd>INTEGER</kbd> characters.
The resulting character string, specified by <kbd>1ST 3RD</kbd>,
begins at <kbd>CADDRESS -> CHARACTER</kbd> plus <kbd>INTEGER</kbd> characters
and is <kbd>UNSIGNED</kbd> minus <kbd>INTEGER</kbd> characters long.</p>
<hr><p><pre><b>/STRING ( CADDRESS -> CHARACTER UNSIGNED -- 1ST 3RD )</b></pre></p>
<p>Adjust the character string at <kbd>CADDRESS -> CHARACTER</kbd>
with length <kbd>UNSIGNED</kbd> by one character.
The resulting character string, specified by <kbd>1ST 3RD</kbd>,
begins at <kbd>CADDRESS -> CHARACTER</kbd> plus one character and is
<kbd>UNSIGNED</kbd> minus one characters long.</p>
<hr><p><pre><b>0< ( SIGNED -- FLAG )</b></pre></p>
<p><kbd>FLAG</kbd> is true if and only if <kbd>SIGNED</kbd> is less than zero.</p>
<hr><p><pre><b>0< ( SIGNED-DOUBLE -- FLAG )</b></pre></p>
<p><kbd>FLAG</kbd> is true if and only if <kbd>SIGNED-DOUBLE</kbd> is less than zero.</p>
<hr><p><pre><b>0<> ( SINGLE -- FLAG )</b></pre></p>
<p><kbd>FLAG</kbd> is true if and only if <kbd>SINGLE</kbd> is not equal to zero.</p>
<hr><p><pre><b>0<> ( DOUBLE -- FLAG )</b></pre></p>
<p><kbd>FLAG</kbd> is true if and only if <kbd>DOUBLE</kbd> is not equal to zero.</p>
<hr><p><pre><b>0= ( SINGLE -- FLAG )</b></pre></p>
<p><kbd>FLAG</kbd> is true if and only if <kbd>SINGLE</kbd> is equal to zero.</p>
<hr><p><pre><b>0= ( DOUBLE -- FLAG )</b></pre></p>
<p><kbd>FLAG</kbd> is true if and only if <kbd>DOUBLE</kbd> is equal to zero.</p>
<hr><p><pre><b>0> ( SIGNED -- FLAG )</b></pre></p>
<p><kbd>FLAG</kbd> is true if and only if <kbd>SIGNED</kbd> is greater than zero.</p>
<hr><p><pre><b>0> ( SIGNED-DOUBLE -- FLAG )</b></pre></p>
<p><kbd>FLAG</kbd> is true if and only if <kbd>SIGNED-DOUBLE</kbd> is greater than zero.</p>
<hr><p><pre><b>1+ ( INTEGER -- 1ST )</b></pre></p>
<p>Add one (1) to <kbd>INTEGER</kbd> giving <kbd>1ST</kbd>.</p>
<hr><p><pre><b>1+ ( ADDRESS -- 1ST )</b></pre></p>
<p>Add one (1) to <kbd>ADDRESS</kbd> giving <kbd>1ST</kbd>.</p>
<hr><p><pre><b>1+ ( ADDRESS -> SINGLE -- 1ST )</b></pre></p>
<p>Add the number of address units per cell
to <kbd>ADDRESS -> SINGLE</kbd> giving <kbd>1ST</kbd>.</p>
<hr><p><pre><b>1+ ( ADDRESS -> DOUBLE -- 1ST )</b></pre></p>
<p>Add the number of address units per double cell
to <kbd>ADDRESS -> DOUBLE</kbd> giving <kbd>1ST</kbd>.</p>
<hr><p><pre><b>1+ ( CADDRESS -- 1ST )</b></pre></p>
<p>Add the number of address units per character
to <kbd>CADDRESS</kbd> giving <kbd>1ST</kbd>.</p>
<hr><p><pre><b>1+ ( INTEGER-DOUBLE -- 1ST )</b></pre></p>
<p>Add one (1) to <kbd>INTEGER-DOUBLE</kbd> giving <kbd>1ST</kbd>.</p>
<hr><p><pre><b>1- ( INTEGER -- 1ST )</b></pre></p>
<p>Subtract one (1) from <kbd>INTEGER</kbd> giving <kbd>1ST</kbd>.</p>
<hr><p><pre><b>1- ( ADDRESS -- 1ST )</b></pre></p>
<p>Subtract one (1) from <kbd>ADDRESS</kbd> giving <kbd>1ST</kbd>.</p>
<hr><p><pre><b>1- ( ADDRESS -> SINGLE -- 1ST )</b></pre></p>
<p>Subtract the number of address units per cell
from <kbd>ADDRESS -> SINGLE</kbd> giving <kbd>1ST</kbd>.</p>
<hr><p><pre><b>1- ( ADDRESS -> DOUBLE -- 1ST )</b></pre></p>
<p>Subtract the number of address units per double cell
from <kbd>ADDRESS -> DOUBLE</kbd> giving <kbd>1ST</kbd>.</p>
<hr><p><pre><b>1- ( CADDRESS -- 1ST )</b></pre></p>
<p>Subtract the number of address units per character
from <kbd>CADDRESS</kbd> giving <kbd>1ST</kbd>.</p>
<hr><p><pre><b>1- ( INTEGER-DOUBLE -- 1ST )</b></pre></p>
<p>Subtract one (1) from <kbd>INTEGER-DOUBLE</kbd> giving <kbd>1ST</kbd>.</p>
<hr><p><pre><b>1ST ( STACK-DIAGRAM -- 1ST )</b></pre></p>
<p><kbd>1ST</kbd> is used in a stack diagram to specify input or output
parameters which should have exactly the same data type as the first data
type in the input parameter list of the same definition.</p>
<p>An exception is thrown if the input parameter list is empty.</p>
<hr><p><pre><b>2* ( INTEGER -- 1ST )</b></pre></p>
<p>Multiply <kbd>INTEGER</kbd> by 2 giving the product <kbd>1ST</kbd>.
Note that <kbd>2*</kbd> may only be used on integer values.
Use <kbd>LSHIFT</kbd> for shifting bits to the left.</p>
<hr><p><pre><b>2* ( INTEGER-DOUBLE -- 1ST )</b></pre></p>
<p>Multiply <kbd>INTEGER-DOUBLE</kbd> by 2 giving the product <kbd>1ST</kbd>.</p>
<hr><p><pre><b>2/ ( UNSIGNED -- 1ST )</b></pre></p>
<p>Divide <kbd>UNSIGNED</kbd> by 2 giving the quotient <kbd>1ST</kbd>.
Note that <kbd>2/</kbd> may only be used on unsigned numbers.
Use <kbd>RSHIFT</kbd> for shifting bits to the right.</p>
<hr><p><pre><b>2/ ( SIGNED -- 1ST )</b></pre></p>
<p>Divide <kbd>SIGNED</kbd> by 2 giving the quotient <kbd>1ST</kbd>.
Note that <kbd>2/</kbd> may only be used on signed numbers.
Use <kbd>RSHIFT</kbd> for shifting bits to the right.</p>
<hr><p><pre><b>2/ ( UNSIGNED-DOUBLE -- 1ST )</b></pre></p>
<p>Divide <kbd>UNSIGNED-DOUBLE</kbd> by 2 giving the quotient <kbd>1ST</kbd>.</p>
<hr><p><pre><b>2/ ( SIGNED-DOUBLE -- 1ST )</b></pre></p>
<p>Divide <kbd>SIGNED-DOUBLE</kbd> by 2 giving the quotient <kbd>1ST</kbd>.</p>
<hr><p><pre><b>2DROP-S ( -- )</b></pre></p>
<p>Change the compiler data type heap according to the stack effect of
the word <kbd>(2DROP-S)</kbd>.
An exception is thrown if <kbd>DROP-S</kbd> is interpreted,
if the compiler data type heap is locked, or if <kbd>(2DROP-S)</kbd>
can not be found in the dictionary.</p>
<hr><p><pre><b>2ND ( STACK-DIAGRAM -- 1ST )</b></pre></p>
<p><kbd>2ND</kbd> is used in a stack diagram to specify input or output
parameters which should have exactly the same data type as the second
data type in the input parameter list of the same definition. Since the
second basic data type of the input parameter list can be a part of the
first input parameter, it is possible to build a reference to the
tail of a compound data type representing the first input parameter.</p>
<p>An exception is thrown if the input parameter list contains
less than two basic data types or if the second basic data type is
itself a reference.</p>
<hr><p><pre><b>3RD ( STACK-DIAGRAM -- 1ST )</b></pre></p>
<p><kbd>3RD</kbd> is used in a stack diagram to specify input or output
parameters which should have exactly the same data type as the third
data type in the input parameter list of the same definition. Since the
third basic data type of the input parameter list can be a part of the
first or second input parameter, it is possible to build a reference to
only the tail of a compound data type representing the first or second
input parameter.</p>
<p>An exception is thrown if the input parameter list contains
less than three basic data types or if the third basic data type is
itself a reference.</p>
<hr><p><pre><b>: ( "<spaces><em>name</em>" -- COLON-SYS )</b></pre></p>
<p>Skip leading space delimiters. Parse <em>name</em> delimited by a space.
Create a definition for <em>name</em>, called a <em>colon definition</em>.
Enter compilation state and initialize the compiler data type heap and the
local dictionary. Start the current definition, producing
<kbd>COLON-SYS</kbd>. Append the initiation semantics given below to
the current definition.</p>
<p>The execution semantics of <em>name</em> will be determined by the
words compiled into the body of the definition. The current definition can
not be found in the dictionary until it is finished or until the execution
of <kbd>DOES></kbd>.</p>
<p>Initiation: <b><kbd>( -- ) ( R: -- nest-sys )</kbd></b>
<br>Save information <kbd>nest-sys</kbd> about the calling definition.</p>
<p><em>name</em> Execution: <b><kbd>( -- )</kbd></b>
<br>Execute the definition <em>name</em>.</p>
<p>Note that the new definition does have no stack effects by default.
Stack effects have to be specified separately if they are intended.
By using a stack diagram phrase <kbd>( ... -- ... )</kbd> immediately
following <kbd>:</kbd> and the def
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -