6517157c5b91501c46b67bd937056767d12dc751
[rrq/rrqforth.git] / adoc / p_does.adoc
1 WORD: DOES>
2 -----------
3 anchor:p_does[]
4 ----
5 compile.asm:    WORD p_does,'DOES>',fasm,IMMEDIATE
6 ----
7
8 Data stack: ( -- )
9
10 "DOES>" is a function that in execution mode does nothing but in
11 compilation mode it changes the execution semantics assignments for
12 the most recent word to use the "dodoes" sematics with adjustment
13 offset to the current heap address. I.e., the word being defined will
14 have its execution start at whatever comes after "DOES>".
15
16 .Execution semantics expressed in RRQFORTH
17 ====
18 : DOES> IMMEDIATE
19 STATE @ != IF ( only for compilation mode )
20   CURRENT-WORDLIST @ @ TFA>CFA    ( cfa of current word )
21     doDOES OVER !                 ( set up doer )
22     HERE @ OVER 8 + - SWAP 8 - !  ( set up offset
23 THEN
24 ;
25 ====
26