| \ \ here allot , c, A, 17dec92py |
\ \ here allot , c, A, 17dec92py |
| |
|
| : allot ( n -- ) \ core |
: allot ( n -- ) \ core |
| dup unused u> -8 and throw |
\G Reserve or release @var{n} address units of data space; @var{n} |
| dp +! ; |
\G is a signed number. There are restrictions on releasing data |
| |
\G space. |
| |
here + |
| |
dup 1- usable-dictionary-end forthstart within -8 and throw |
| |
dp ! ; |
| |
|
| : c, ( c -- ) \ core |
: c, ( c -- ) \ core |
| |
\G Reserve data space for one char and store @var{c} in the space. |
| here 1 chars allot c! ; |
here 1 chars allot c! ; |
| |
|
| : , ( x -- ) \ core |
: , ( w -- ) \ core |
| |
\G Reserve data space for one cell and store @var{w} in the space. |
| here cell allot ! ; |
here cell allot ! ; |
| |
|
| : 2, ( w1 w2 -- ) \ gforth |
: 2, ( w1 w2 -- ) \ gforth |
| |
\G Reserve data space for two cells and store the double @var{w1 |
| |
\G w2} in the space. |
| here 2 cells allot 2! ; |
here 2 cells allot 2! ; |
| |
|
| \ : aligned ( addr -- addr' ) \ core |
\ : aligned ( addr -- addr' ) \ core |
| bl c, |
bl c, |
| LOOP ; |
LOOP ; |
| |
|
| : maxalign ( -- ) \ float |
: maxalign ( -- ) \ gforth |
| here dup maxaligned swap |
here dup maxaligned swap |
| ?DO |
?DO |
| bl c, |
bl c, |
| ['] noname-header IS (header) ; |
['] noname-header IS (header) ; |
| |
|
| : lastxt ( -- xt ) \ gforth |
: lastxt ( -- xt ) \ gforth |
| \ xt is the execution token of the last word defined. The main purpose of this word is to get the xt of words defined using noname |
\G @var{xt} is the execution token of the last word defined. |
| |
\ The main purpose of this word is to get the xt of words defined using noname |
| lastcfa @ ; |
lastcfa @ ; |
| |
|
| \ \ literals 17dec92py |
\ \ literals 17dec92py |
| |
|
| : Literal ( compilation n -- ; run-time -- n ) \ core |
: Literal ( compilation n -- ; run-time -- n ) \ core |
| \G Compile appropriate code such that, at run-time, n is placed |
\G Compile appropriate code such that, at run-time, @var{n} is placed |
| \G on the stack. Interpretation semantics are undefined. |
\G on the stack. Interpretation semantics are undefined. |
| postpone lit , ; immediate restrict |
postpone lit , ; immediate restrict |
| |
|
| postpone lit A, ; immediate restrict |
postpone lit A, ; immediate restrict |
| |
|
| : char ( '<spaces>ccc' -- c ) \ core |
: char ( '<spaces>ccc' -- c ) \ core |
| \G Skip leading spaces. Parse the string ccc and return c, the |
\G Skip leading spaces. Parse the string @var{ccc} and return @var{c}, the |
| \G display code representing the first character of ccc. |
\G display code representing the first character of @var{ccc}. |
| bl word char+ c@ ; |
bl word char+ c@ ; |
| |
|
| : [char] ( compilation '<spaces>ccc' -- ; run-time -- c ) \ core bracket-char |
: [char] ( compilation '<spaces>ccc' -- ; run-time -- c ) \ core bracket-char |
| \G Compilation: skip leading spaces. Parse the string ccc. Run-time: |
\G Compilation: skip leading spaces. Parse the string |
| \G return c, the display code representing the first character of ccc. |
\G @var{ccc}. Run-time: return @var{c}, the display code |
| \G Interpretation semantics for this word are undefined. |
\G representing the first character of @var{ccc}. Interpretation |
| |
\G semantics for this word are undefined. |
| char postpone Literal ; immediate restrict |
char postpone Literal ; immediate restrict |
| |
|
| \ \ threading 17mar93py |
\ \ threading 17mar93py |
| 0 A, 0 , code-address! ; |
0 A, 0 , code-address! ; |
| |
|
| : compile, ( xt -- ) \ core-ext compile-comma |
: compile, ( xt -- ) \ core-ext compile-comma |
| \G Blah, blah. |
\G Compile the word represented by the execution token, @var{xt}. |
| A, ; |
A, ; |
| |
|
| : !does ( addr -- ) \ gforth store-does |
: !does ( addr -- ) \ gforth store-does |
| r> dup cell+ >r @ compile, ; |
r> dup cell+ >r @ compile, ; |
| |
|
| : postpone, ( w xt -- ) \ gforth postpone-comma |
: postpone, ( w xt -- ) \ gforth postpone-comma |
| \g Compiles the compilation semantics represented by @var{w xt}. |
\g Compile the compilation semantics represented by @var{w xt}. |
| dup ['] execute = |
dup ['] execute = |
| if |
if |
| drop compile, |
drop compile, |
| \ \ recurse 17may93jaw |
\ \ recurse 17may93jaw |
| |
|
| : recurse ( compilation -- ; run-time ?? -- ?? ) \ core |
: recurse ( compilation -- ; run-time ?? -- ?? ) \ core |
| \g calls the current definition. |
\g Call the current definition. |
| lastxt compile, ; immediate restrict |
lastxt compile, ; immediate restrict |
| |
|
| \ \ compiler loop |
\ \ compiler loop |
| here over char+ allot place align ; |
here over char+ allot place align ; |
| |
|
| : SLiteral ( Compilation c-addr1 u ; run-time -- c-addr2 u ) \ string |
: SLiteral ( Compilation c-addr1 u ; run-time -- c-addr2 u ) \ string |
| \G Compilation: compile the string specified by c-addr1, u into |
\G Compilation: compile the string specified by @var{c-addr1}, |
| \G the current definition. Run-time: return c-addr2 u describing |
\G @var{u} into the current definition. Run-time: return |
| \G the address and length of the string. |
\G @var{c-addr2 u} describing the address and length of the |
| |
\G string. |
| postpone (S") here over char+ allot place align ; |
postpone (S") here over char+ allot place align ; |
| immediate restrict |
immediate restrict |
| |
|
| \ \ abort" 22feb93py |
\ \ abort" 22feb93py |
| |
|
| : abort" ( compilation 'ccc"' -- ; run-time f -- ) \ core,exception-ext abort-quote |
: abort" ( compilation 'ccc"' -- ; run-time f -- ) \ core,exception-ext abort-quote |
| |
\G If any bit of @var{f} is non-zero, perform the function of @code{-2 throw}, |
| |
\G displaying the string @var{ccc} if there is no exception frame on the |
| |
\G exception stack. |
| postpone (abort") ," ; immediate restrict |
postpone (abort") ," ; immediate restrict |
| |
|
| \ \ Header states 23feb93py |
\ \ Header states 23feb93py |
| last @ dup 0= abort" last word was headerless" cell+ ; |
last @ dup 0= abort" last word was headerless" cell+ ; |
| |
|
| : immediate ( -- ) \ core |
: immediate ( -- ) \ core |
| |
\G Make the compilation semantics of a word be to @code{execute} |
| |
\G the execution semantics. |
| immediate-mask lastflags cset ; |
immediate-mask lastflags cset ; |
| |
|
| : restrict ( -- ) \ gforth |
: restrict ( -- ) \ gforth |
| |
\G A synonym for @code{compile-only} |
| restrict-mask lastflags cset ; |
restrict-mask lastflags cset ; |
| ' restrict alias compile-only ( -- ) \ gforth |
' restrict alias compile-only ( -- ) \ gforth |
| |
\G Remove the interpretation semantics of a word. |
| |
|
| \ \ Create Variable User Constant 17mar93py |
\ \ Create Variable User Constant 17mar93py |
| |
|
| dup wordlist-map @ rehash-method perform ; |
dup wordlist-map @ rehash-method perform ; |
| |
|
| ' reveal alias recursive ( compilation -- ; run-time -- ) \ gforth |
' reveal alias recursive ( compilation -- ; run-time -- ) \ gforth |
| \g makes the current definition visible, enabling it to call itself |
\g Make the current definition visible, enabling it to call itself |
| \g recursively. |
\g recursively. |
| immediate restrict |
immediate restrict |