[gforth] / gforth / kernel / vars.fs  

gforth: gforth/kernel/vars.fs


1 : anton 1.1 \ VARS.FS Kernal variables
2 :    
3 : anton 1.50 \ Copyright (C) 1995,1996,1997,1998,2000,2003,2006,2007,2011 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 : anton 1.47 \ as published by the Free Software Foundation, either version 3
10 : anton 1.1 \ 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 : anton 1.47 \ along with this program. If not, see http://www.gnu.org/licenses/.
19 : anton 1.1
20 :     hex \ everything now hex! 11may93jaw
21 :    
22 :     \ important constants 17dec92py
23 :    
24 :     \ dpANS6 (sect 3.1.3.1) says
25 :     \ "a true flag ... [is] a single-cell value with all bits set"
26 :     \ better definition: 0 0= constant true ( no dependence on 2's compl)
27 : crook 1.10 -1 Constant true ( -- f ) \ core-ext
28 : crook 1.19 \G @code{Constant} -- @i{f} is a cell with all bits set.
29 : crook 1.10 \ see starts looking for primitives after this word!
30 :    
31 :     0 Constant false ( -- f ) \ core-ext
32 : crook 1.19 \G @code{Constant} -- @i{f} is a cell with all bits clear.
33 : anton 1.1
34 : jwilke 1.16 [IFUNDEF] cell
35 : anton 1.1 1 cells Constant cell ( -- u ) \ gforth
36 : anton 1.22 \G @code{Constant} -- @code{1 cells}
37 : jwilke 1.16 [THEN]
38 : crook 1.17
39 : pazsan 1.25 has? floating [IF]
40 : anton 1.1 1 floats Constant float ( -- u ) \ gforth
41 : crook 1.19 \G @code{Constant} -- the number of address units corresponding to a floating-point number.
42 : pazsan 1.25 [THEN]
43 : anton 1.1
44 : crook 1.20 20 Constant bl ( -- c-char ) \ core b-l
45 : crook 1.17 \G @i{c-char} is the character value for a space.
46 : crook 1.10 \ used by docon:, must be constant
47 : anton 1.1
48 : pazsan 1.48 has? EC [IF] 20 cells [ELSE] FF [THEN] Constant /line
49 : anton 1.1
50 : pazsan 1.39 has? file [IF]
51 : anton 1.1 40 Constant c/l
52 :     10 Constant l/s
53 :     400 Constant chars/block
54 : pazsan 1.38 [THEN]
55 : anton 1.1
56 : jwilke 1.18 20 8 2* cells + 2 + cell+ constant word-pno-size ( -- u )
57 : pazsan 1.40
58 :     has? EC 0= [IF]
59 : anton 1.11 create holdbuf word-pno-size chars allot
60 :     holdbuf word-pno-size chars + aconstant holdbuf-end
61 :     avariable holdptr holdbuf-end holdptr a!
62 : anton 1.12 avariable holdend holdbuf-end holdend a!
63 : pazsan 1.40 [THEN]
64 : anton 1.11
65 : anton 1.2 84 constant pad-minsize ( -- u )
66 : anton 1.11
67 : pazsan 1.25 $400 Value def#tib
68 :     \G default size of terminal input buffer. Default size is 1K
69 : anton 1.2
70 : anton 1.1 \ that's enough so long
71 :    
72 :     \ User variables 13feb93py
73 :    
74 :     \ initialized by COLD
75 :    
76 : pazsan 1.38 has? no-userspace 0= [IF]
77 : jwilke 1.35 Create main-task has? OS [IF] 100 [ELSE] 40 [THEN] cells dup allot
78 : jwilke 1.3
79 :     \ set user-pointer from cross-compiler right
80 :     main-task
81 : jwilke 1.35 UNLOCK swap region user-region user-region setup-region LOCK
82 : anton 1.1
83 : crook 1.19 Variable udp ( -- a-addr ) \ gforth
84 : pazsan 1.28 \G user area size
85 : anton 1.1
86 :     AUser next-task main-task next-task !
87 :     AUser prev-task main-task prev-task !
88 :     AUser save-task 0 save-task !
89 : pazsan 1.38 [THEN]
90 : crook 1.10 AUser sp0 ( -- a-addr ) \ gforth
91 : crook 1.19 \G @code{User} variable -- initial value of the data stack pointer.
92 : crook 1.10 \ sp0 is used by douser:, must be user
93 : pazsan 1.38 \ ' sp0 Alias s0 ( -- a-addr ) \ gforth
94 : crook 1.10 \G OBSOLETE alias of @code{sp0}
95 :    
96 :     AUser rp0 ( -- a-addr ) \ gforth
97 : crook 1.19 \G @code{User} variable -- initial value of the return stack pointer.
98 : pazsan 1.38 \ ' rp0 Alias r0 ( -- a-addr ) \ gforth
99 : crook 1.10 \G OBSOLETE alias of @code{rp0}
100 :    
101 : pazsan 1.25 has? floating [IF]
102 : crook 1.10 AUser fp0 ( -- a-addr ) \ gforth
103 : crook 1.19 \G @code{User} variable -- initial value of the floating-point stack pointer.
104 : crook 1.10 \ no f0, because this leads to unexpected results when using hex
105 : pazsan 1.25 [THEN]
106 : crook 1.10
107 : pazsan 1.25 has? glocals [IF]
108 : crook 1.10 AUser lp0 ( -- a-addr ) \ gforth
109 : crook 1.19 \G @code{User} variable -- initial value of the locals stack pointer.
110 : pazsan 1.38 \ ' lp0 Alias l0 ( -- a-addr ) \ gforth
111 : crook 1.10 \G OBSOLETE alias of @code{lp0}
112 : pazsan 1.25 [THEN]
113 : crook 1.10
114 : jwilke 1.3 AUser handler \ pointer to last throw frame
115 : jwilke 1.18 has? backtrace [IF]
116 : anton 1.13 AUser backtrace-rp0 \ rp at last call of interpret
117 : jwilke 1.18 [THEN]
118 : anton 1.1 \ AUser output
119 :     \ AUser input
120 :    
121 :     AUser errorhandler
122 :    
123 :     AUser "error 0 "error !
124 :    
125 : pazsan 1.25 has? new-input [IF]
126 :     User current-input
127 :     [ELSE]
128 :     [IFUNDEF] #tib \ in ec-Version we may define this ourself
129 :     User tibstack \ saves >tib in execute
130 :     User >tib \ pointer to terminal input buffer
131 :     User #tib ( -- a-addr ) \ core-ext number-t-i-b
132 :     \G @code{User} variable -- @i{a-addr} is the address of a cell containing
133 :     \G the number of characters in the terminal input buffer.
134 :     \G OBSOLESCENT: @code{source} superceeds the function of this word.
135 :    
136 :     User >in ( -- a-addr ) \ core to-in
137 :     \G @code{User} variable -- @i{a-addr} is the address of a cell containing the
138 :     \G char offset from the start of the input buffer to the start of the
139 :     \G parse area.
140 :     0 >in ! \ char number currently processed in tib
141 :     [THEN]
142 :    
143 : pazsan 1.7 has? file [IF]
144 : crook 1.20 User blk ( -- a-addr ) \ block b-l-k
145 : crook 1.19 \G @code{User} variable -- @i{a-addr} is the address of a cell containing zero
146 : crook 1.10 \G (in which case the input source is not a block and can be identified
147 :     \G by @code{source-id}) or the number of the block currently being
148 :     \G interpreted. A Standard program should not alter @code{blk} directly.
149 :     0 blk !
150 :    
151 : anton 1.1 User loadfile 0 loadfile !
152 :    
153 : anton 1.32 2user loadfilename 0 0 loadfilename 2! \ addr u for sourcefilename
154 : anton 1.37
155 : anton 1.1 User loadline \ number of the currently interpreted
156 :     \ (in TIB) line if the interpretation
157 :     \ is in a textfile
158 :     \ the first line is 1
159 :    
160 :     2User linestart \ starting file postition of
161 :     \ the current interpreted line (in TIB)
162 : pazsan 1.25 [THEN]
163 : pazsan 1.7 [THEN]
164 : anton 1.37
165 :     2user includefilename 0 0 includefilename 2! \ innermost included file
166 :    
167 : anton 1.1
168 : anton 1.26 User base ( -- a-addr ) \ core
169 : anton 1.45 \G @code{User} variable -- @i{a-addr} is the address of a cell that
170 :     \G stores the number base used by default for number conversion during
171 :     \G input and output. Don't store to @code{base}, use
172 :     \G @code{base-execute} instead.
173 : anton 1.26 A base !
174 :     User dpl ( -- a-addr ) \ gforth
175 :     \G @code{User} variable -- @i{a-addr} is the address of a cell that stores the
176 :     \G position of the decimal point in the most recent numeric conversion.
177 :     \G Initialised to -1. After the conversion of a number containing no
178 : anton 1.36 \G decimal point, @code{dpl} is -1. After the conversion of @code{2.} it holds
179 : anton 1.26 \G 0. After the conversion of 234123.9 it contains 1, and so forth.
180 :     -1 dpl !
181 : anton 1.1
182 : anton 1.26 User state ( -- a-addr ) \ core,tools-ext
183 :     \G @code{User} variable -- @i{a-addr} is the address of a cell
184 :     \G containing the compilation state flag. 0 => interpreting, -1 =>
185 :     \G compiling. A program shall not directly alter the value of
186 :     \G @code{state}. The following Standard words alter the value in
187 :     \G @code{state}: @code{:} (colon) @code{;} (semicolon) @code{abort}
188 :     \G @code{quit} @code{:noname} @code{[} (left-bracket) @code{]}
189 :     \G (right-bracket) @code{;code}. Don't use @code{state}! For an
190 :     \G alternative see @ref{Interpretation and Compilation Semantics}.
191 :     \ Recommended reading: @cite{@code{State}-smartness--Why it is evil
192 :     \ and how to exorcise it},
193 :     \ @url{http://www.complang.tuwien.ac.at/papers/ertl98.ps.gz}; short
194 :     \ version: Don't use @code{state}!
195 :     0 state !
196 : crook 1.10
197 : anton 1.1 AUser normal-dp \ the usual dictionary pointer
198 :     AUser dpp normal-dp dpp !
199 :     \ the pointer to the current dictionary pointer
200 :     \ ist reset to normal-dp on (doerror)
201 :     \ (i.e. any throw caught by quit)
202 : pazsan 1.49 has? ec [IF]
203 :     AUser LastCFA
204 :     [THEN]
205 : anton 1.1 AUser Last
206 : anton 1.26
207 : pazsan 1.41 has? flash [IF]
208 :     AUser flash-dp
209 :     : rom flash-dp dpp ! ;
210 :     : ram normal-dp dpp ! ;
211 :     [THEN]
212 :    
213 : anton 1.33 User max-name-length \ maximum length of all names defined yet
214 :     32 max-name-length !
215 :    
216 :     \ has? peephole [IF]
217 :     \ 0 value peeptable \ initialized in boot
218 :     \ [THEN]
219 : anton 1.1
220 : pazsan 1.7 has? glocals [IF]
221 : anton 1.1 User locals-size \ this is the current size of the locals stack
222 :     \ frame of the current word
223 : pazsan 1.7 [THEN]
224 : anton 1.1

CVS Admin

Powered by ViewCVS 1.0-dev
(Powered by ViewCVS)

ViewCVS and CVS Help