[gforth] / gforth / kernel / vars.fs  

gforth: gforth/kernel/vars.fs


1 : anton 1.1 \ VARS.FS Kernal variables
2 :    
3 : anton 1.6 \ Copyright (C) 1995,1996,1997,1998 Free Software Foundation, Inc.
4 : anton 1.1
5 :     \ This file is part of Gforth.
6 :    
7 :     \ Gforth is free software; you can redistribute it and/or
8 :     \ modify it under the terms of the GNU General Public License
9 :     \ as published by the Free Software Foundation; either version 2
10 :     \ of the License, or (at your option) any later version.
11 :    
12 :     \ This program is distributed in the hope that it will be useful,
13 :     \ but WITHOUT ANY WARRANTY; without even the implied warranty of
14 :     \ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 :     \ GNU General Public License for more details.
16 :    
17 :     \ You should have received a copy of the GNU General Public License
18 :     \ along with this program; if not, write to the Free Software
19 :     \ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 :    
21 :     hex \ everything now hex! 11may93jaw
22 :    
23 :     \ important constants 17dec92py
24 :    
25 :     \ dpANS6 (sect 3.1.3.1) says
26 :     \ "a true flag ... [is] a single-cell value with all bits set"
27 :     \ better definition: 0 0= constant true ( no dependence on 2's compl)
28 : crook 1.10 -1 Constant true ( -- f ) \ core-ext
29 : crook 1.14 \G CONSTANT: @var{f} is a cell with all bits set.
30 : crook 1.10 \ see starts looking for primitives after this word!
31 :    
32 :     0 Constant false ( -- f ) \ core-ext
33 : crook 1.14 \G CONSTANT: @var{f} is a cell with all bits clear.
34 : anton 1.1
35 :     1 cells Constant cell ( -- u ) \ gforth
36 :     1 floats Constant float ( -- u ) \ gforth
37 :    
38 : crook 1.10 20 Constant bl ( -- c-char ) \ core
39 : crook 1.14 \G @var{c-char} is the character value for a space.
40 : crook 1.10 \ used by docon:, must be constant
41 : anton 1.1
42 :     FF Constant /line
43 :    
44 :     40 Constant c/l
45 :     10 Constant l/s
46 :     400 Constant chars/block
47 :    
48 : anton 1.2 $20 8 2* cells + 2 + cell+ constant word-pno-size ( -- u )
49 : anton 1.11 create holdbuf word-pno-size chars allot
50 :     holdbuf word-pno-size chars + aconstant holdbuf-end
51 :     avariable holdptr holdbuf-end holdptr a!
52 : anton 1.12 avariable holdend holdbuf-end holdend a!
53 : anton 1.11
54 : anton 1.2 84 constant pad-minsize ( -- u )
55 : anton 1.11
56 : anton 1.2
57 : anton 1.1 \ that's enough so long
58 :    
59 :     \ User variables 13feb93py
60 :    
61 :     \ initialized by COLD
62 :    
63 : pazsan 1.7 Create main-task has? OS [IF] 100 [ELSE] 40 [THEN] cells allot
64 : jwilke 1.3
65 :     \ set user-pointer from cross-compiler right
66 :     main-task
67 :     UNLOCK tup ! LOCK
68 : anton 1.1
69 : anton 1.8 Variable udp \ user area size? -anton
70 : anton 1.1
71 :     AUser next-task main-task next-task !
72 :     AUser prev-task main-task prev-task !
73 :     AUser save-task 0 save-task !
74 : crook 1.10 AUser sp0 ( -- a-addr ) \ gforth
75 :     \G USER VARIABLE: Initial value of the data stack pointer.
76 :     \ sp0 is used by douser:, must be user
77 :     ' sp0 Alias s0 ( -- a-addr ) \ gforth
78 :     \G OBSOLETE alias of @code{sp0}
79 :    
80 :     AUser rp0 ( -- a-addr ) \ gforth
81 :     \G USER VARIABLE: Initial value of the return stack pointer.
82 :     ' rp0 Alias r0 ( -- a-addr ) \ gforth
83 :     \G OBSOLETE alias of @code{rp0}
84 :    
85 :     AUser fp0 ( -- a-addr ) \ gforth
86 :     \G USER VARIABLE: Initial value of the floating-point stack pointer.
87 :     \ no f0, because this leads to unexpected results when using hex
88 :    
89 :     AUser lp0 ( -- a-addr ) \ gforth
90 :     \G USER VARIABLE: Initial value of the locals stack pointer.
91 :     ' lp0 Alias l0 ( -- a-addr ) \ gforth
92 :     \G OBSOLETE alias of @code{lp0}
93 :    
94 : jwilke 1.3 AUser handler \ pointer to last throw frame
95 : anton 1.13 User backtrace-empty \ true if the next THROW should store a backtrace
96 :     AUser backtrace-rp0 \ rp at last call of interpret
97 : anton 1.1 \ AUser output
98 :     \ AUser input
99 :    
100 :     AUser errorhandler
101 :    
102 :     AUser "error 0 "error !
103 :    
104 : jwilke 1.3 [IFUNDEF] #tib \ in ec-Version we may define this ourself
105 :     User tibstack \ saves >tib in execute
106 :     User >tib \ pointer to terminal input buffer
107 : crook 1.10 User #tib ( -- a-addr ) \ core-ext
108 : crook 1.14 \G USER VARIABLE: @var{a-addr} is the address of a cell containing
109 : crook 1.10 \G the number of characters in the terminal input buffer.
110 :     \G OBSOLESCENT: @code{source} superceeds the function of this word.
111 :    
112 :     User >in ( -- a-addr ) \ core
113 : crook 1.14 \G USER VARIABLE: @var{a-addr} is the address of a cell containing the
114 : crook 1.10 \G char offset from the start of the terminal input buffer to the
115 :     \G start of the parse area
116 :     0 >in ! \ char number currently processed in tib
117 : jwilke 1.3 [THEN]
118 : pazsan 1.7 has? file [IF]
119 : crook 1.10 User blk ( -- a-addr ) \ block
120 : crook 1.14 \G USER VARIABLE: @var{a-addr} is the address of a cell containing zero
121 : crook 1.10 \G (in which case the input source is not a block and can be identified
122 :     \G by @code{source-id}) or the number of the block currently being
123 :     \G interpreted. A Standard program should not alter @code{blk} directly.
124 :     0 blk !
125 :    
126 : anton 1.1 User loadfile 0 loadfile !
127 :    
128 :     User loadfilename# 0 loadfilename# !
129 :    
130 :     User loadline \ number of the currently interpreted
131 :     \ (in TIB) line if the interpretation
132 :     \ is in a textfile
133 :     \ the first line is 1
134 :    
135 :     2User linestart \ starting file postition of
136 :     \ the current interpreted line (in TIB)
137 : pazsan 1.7 [THEN]
138 : anton 1.1
139 : crook 1.10 User base ( -- a-addr ) \ core
140 : crook 1.14 \G USER VARIABLE: @var{a-addr} is the address of a cell that stores the
141 : crook 1.10 \G number base used by default for number conversion during input and output.
142 :     A base !
143 : anton 1.1 User dpl -1 dpl !
144 :    
145 : crook 1.10 User state ( -- a-addr ) \ core,tools-ext
146 : anton 1.12 \G Recommended reading: @cite{@code{State}-smartness--Why it is evil
147 :     \G and how to exorcise it},
148 :     \G @url{http://www.complang.tuwien.ac.at/papers/ertl98.ps.gz}; short
149 :     \G version: Don't use @code{state}! @xref{Interpretation and
150 : crook 1.14 \G Compilation Semantics} for an alternative. USER VARIABLE: @var{a-addr}
151 : anton 1.12 \G is the address of a cell containing the compilation state flag. 0
152 :     \G => interpreting, -1 => compiling. A program shall not directly
153 :     \G alter the value of @code{state}. The following Standard words
154 :     \G alter the value in @code{state}: @code{:} (colon) @code{;}
155 :     \G (semicolon) @code{abort} @code{quit} @code{:noname} @code{[}
156 :     \G (left-bracket) @code{]} (right-bracket) @code{;code}
157 : crook 1.10 0 state !
158 :    
159 : anton 1.1 AUser normal-dp \ the usual dictionary pointer
160 :     AUser dpp normal-dp dpp !
161 :     \ the pointer to the current dictionary pointer
162 :     \ ist reset to normal-dp on (doerror)
163 :     \ (i.e. any throw caught by quit)
164 :     AUser LastCFA
165 :     AUser Last
166 :    
167 : pazsan 1.7 has? glocals [IF]
168 : anton 1.1 User locals-size \ this is the current size of the locals stack
169 :     \ frame of the current word
170 : pazsan 1.7 [THEN]
171 : anton 1.1

CVS Admin

Powered by ViewCVS 1.0-dev
(Powered by ViewCVS)

ViewCVS and CVS Help