split . into .TEMP rendering, then stdout writing
[rrq/rrqforth.git] / adoc / p_begin.adoc
1 // control.asm: WORD p_begin,'BEGIN',fasm
2
3 anchor:p_begin[]
4
5 === Word: BEGIN
6
7 ....
8 Data stack: Compiling: ( -- a 0 )
9 ....
10
11 "BEGIN" is an immediate function word that is used together with
12 <<p_ifbreak,IFBREAK>>, <<p_ifagain,IFAGAIN>> and <<p_end,END>> to
13 implement structured execution control. BEGIN simply places the
14 address for resolving branches back to this point during execution,
15 and then a 0 as a marker so as to allow for an unknown number of block
16 exit points.
17
18 ====
19 .Usage example {counter:example}: 
20 ----
21 : WTELL ( tfa -- ; Print word pname )
22   24 + DUP 8 + SWAP @ TELL SP EMIT
23 ;
24
25 : WORDS ( wordlist -- ; Print all words of word list )
26   BEGIN
27     @ DUP 0= IFBREAK
28     DUP WTELL
29   END
30   DROP
31   NL EMIT
32 ;
33 ----
34 ====