X-Git-Url: https://git.rrq.au/?a=blobdiff_plain;f=adoc%2Fp_create.adoc;h=5fdfe27d3caa6536bededd5473358779baf49ec0;hb=076f00a88873336acf2c7150281f1a8172683fe7;hp=dc6926a9cd441240e65fe13284e89d3611649644;hpb=b7da3f7bbd1cb10241163abdb950472e539e796d;p=rrq%2Frrqforth.git diff --git a/adoc/p_create.adoc b/adoc/p_create.adoc index dc6926a..5fdfe27 100644 --- a/adoc/p_create.adoc +++ b/adoc/p_create.adoc @@ -1,19 +1,21 @@ +// compile.asm: WORD p_create,'CREATE',fasm + anchor:p_create[] -Word: CREATE ------------- +=== Word: CREATE ----- -compile.asm: WORD p_create,'CREATE',fasm ----- +.... Data stack: ( char* n -- tfa ) +.... "CREATE" is a function word that allocates a "word header" with the indicated [n:char*] print name, and returns the "TFA" (Token Field Address) of the word. The header memory layout is as follows: ==== +.rrqforth word structure +[caption='Layout {counter:layout}: '] ---- struct WORD TFA 8 link ; tfa of previous word @@ -41,11 +43,9 @@ its DFA when executed. This is changed to "doforth" for RRQFORTH function words initiated by ":" (aka "COLON") or changed to "dovalue" for RRQFORTH constants created by "CONSTANT". -See "<>" about range of +doer+ assignments and -their meanings. - -.Execution semantics expressed in RRQFORTH ==== +.Definition concept for CREATE +**** HERE @ R> ( save tfa on RS ) R@ CURRENT-WORD @ DUP @ , ! ( link in a new word ) DUP 49 + R@ + , ( pCFA ) @@ -53,15 +53,22 @@ HERE @ R> ( save tfa on RS ) DUP , ( length ) HERE @ ROT ROT MEMCPY 0 C, ( pname + NUL ) R@ , ( pTFA ) - 0, ( OFF ) + 0 , ( OFF ) doVARIABLE ( CFA, default semantics ) +**** ==== -.Usage example ==== -\ A possible definition of the word CONSTANT -: CONSTANT - READ-WORD CREATE TFA>DFA doVALUE OVER 8 - ! ! -; +.a possible definition of CONSTANT +[caption='Usage example {counter:example}: '] +---- +: CONSTANT READ-WORD CREATE TFA>DFA doVALUE OVER 8 - ! ! ; +---- ==== +See also <>, <>, <>, <>, +<>, <>, <>, +<>, <>, <>, <>, +and <>, +as well as <> +about the range of "doer" assignments and their meanings.