adding some documentation
[rrq/rrqforth.git] / adoc / p_literal.adoc
1 Word: LIT
2 ---------
3
4 anchor:p_literal[]
5 ----
6 compile.asm:    WORD p_literal,'LIT',fasm
7 ----
8
9 Data stack: compiling ( v -- ) interpreting ( -- v )
10
11 "LIT" is a function word for, in compiling mode, creating a literal
12 value the gets pushed in interpreting mode. In compiling mode, it a
13 lays out its own CFA pointer, then grabs the current stack value onto
14 the heap. In interpreting mode it recreates the value onto the stack.
15
16 Note that the value is layed out as if a subsequent CFA poitnter in
17 the containing definition, but the LIT execution will make the
18 execution skip past that and instead contine with the CFA pointer
19 folling the value.
20
21 It's not a good idea to use "LIT" interactively.
22
23 .Execution semantics expressed in RRQFORTH
24 ====
25 : LIT IMMEDIATE
26   STATE @ IF p_literal , ELSE R> DUP 8 + >R @ THEN
27 ;
28 ====
29
30