[gforth] / gforth / kernel / vars.fs  

gforth: gforth/kernel/vars.fs


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

CVS Admin

Powered by ViewCVS 1.0-dev
(Powered by ViewCVS)

ViewCVS and CVS Help