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

CVS Admin

Powered by ViewCVS 1.0-dev
(Powered by ViewCVS)

ViewCVS and CVS Help