File:
[gforth] /
gforth /
kernel /
vars.fs
Revision
1.10:
download - view:
text,
annotated -
select for diffs
Wed Feb 3 00:10:26 1999 UTC (25 years, 2 months ago) by
crook
Branches:
MAIN
CVS tags:
HEAD
New "docclean" target for makefile (removes glossary dependencies when
rebuilding documentation). Changes to .fs files and prim are restricted
to glossary (\G) additions for the documentation; this has necessitated
the addition of new white-space in places to stop the \G stuff from
obscuring the code. Many additions to doc/gforth.ds - new sections
added, a few things moved and some sections re-written slightly. There
are a set of things to tidy up before this rev. is suitable for
release, and those will be my highest priority. I have also used
"@comment TODO" to highlight other sections I plan to work on, and
added a set of comments at the start to indicate other things I plan
to modify in the medium-term.
1: \ VARS.FS Kernal variables
2:
3: \ Copyright (C) 1995,1996,1997,1998 Free Software Foundation, Inc.
4:
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: -1 Constant true ( -- f ) \ core-ext
29: \G CONSTANT: f is a cell with all bits set.
30: \ see starts looking for primitives after this word!
31:
32: 0 Constant false ( -- f ) \ core-ext
33: \G CONSTANT: f is a cell with all bits clear.
34:
35: 1 cells Constant cell ( -- u ) \ gforth
36: 1 floats Constant float ( -- u ) \ gforth
37:
38: 20 Constant bl ( -- c-char ) \ core
39: \G c-char is the character value for a space.
40: \ used by docon:, must be constant
41:
42: FF Constant /line
43:
44: 40 Constant c/l
45: 10 Constant l/s
46: 400 Constant chars/block
47:
48: $20 8 2* cells + 2 + cell+ constant word-pno-size ( -- u )
49: 84 constant pad-minsize ( -- u )
50:
51: \ that's enough so long
52:
53: \ User variables 13feb93py
54:
55: \ initialized by COLD
56:
57: Create main-task has? OS [IF] 100 [ELSE] 40 [THEN] cells allot
58:
59: \ set user-pointer from cross-compiler right
60: main-task
61: UNLOCK tup ! LOCK
62:
63: Variable udp \ user area size? -anton
64:
65: AUser next-task main-task next-task !
66: AUser prev-task main-task prev-task !
67: AUser save-task 0 save-task !
68: AUser sp0 ( -- a-addr ) \ gforth
69: \G USER VARIABLE: Initial value of the data stack pointer.
70: \ sp0 is used by douser:, must be user
71: ' sp0 Alias s0 ( -- a-addr ) \ gforth
72: \G OBSOLETE alias of @code{sp0}
73:
74: AUser rp0 ( -- a-addr ) \ gforth
75: \G USER VARIABLE: Initial value of the return stack pointer.
76: ' rp0 Alias r0 ( -- a-addr ) \ gforth
77: \G OBSOLETE alias of @code{rp0}
78:
79: AUser fp0 ( -- a-addr ) \ gforth
80: \G USER VARIABLE: Initial value of the floating-point stack pointer.
81: \ no f0, because this leads to unexpected results when using hex
82:
83: AUser lp0 ( -- a-addr ) \ gforth
84: \G USER VARIABLE: Initial value of the locals stack pointer.
85: ' lp0 Alias l0 ( -- a-addr ) \ gforth
86: \G OBSOLETE alias of @code{lp0}
87:
88: AUser handler \ pointer to last throw frame
89: AUser backtrace-empty \ true if the next THROW should store a backtrace
90: \ AUser output
91: \ AUser input
92:
93: AUser errorhandler
94:
95: AUser "error 0 "error !
96:
97: [IFUNDEF] #tib \ in ec-Version we may define this ourself
98: User tibstack \ saves >tib in execute
99: User >tib \ pointer to terminal input buffer
100: User #tib ( -- a-addr ) \ core-ext
101: \G USER VARIABLE: a-addr is the address of a cell containing
102: \G the number of characters in the terminal input buffer.
103: \G OBSOLESCENT: @code{source} superceeds the function of this word.
104:
105: User >in ( -- a-addr ) \ core
106: \G USER VARIABLE: a-addr is the address of a cell containing the
107: \G char offset from the start of the terminal input buffer to the
108: \G start of the parse area
109: 0 >in ! \ char number currently processed in tib
110: [THEN]
111: has? file [IF]
112: User blk ( -- a-addr ) \ block
113: \G USER VARIABLE: a-addr is the address of a cell containing zero
114: \G (in which case the input source is not a block and can be identified
115: \G by @code{source-id}) or the number of the block currently being
116: \G interpreted. A Standard program should not alter @code{blk} directly.
117: 0 blk !
118:
119: User loadfile 0 loadfile !
120:
121: User loadfilename# 0 loadfilename# !
122:
123: User loadline \ number of the currently interpreted
124: \ (in TIB) line if the interpretation
125: \ is in a textfile
126: \ the first line is 1
127:
128: 2User linestart \ starting file postition of
129: \ the current interpreted line (in TIB)
130: [THEN]
131:
132: User base ( -- a-addr ) \ core
133: \G USER VARIABLE: a-addr is the address of a cell that stores the
134: \G number base used by default for number conversion during input and output.
135: A base !
136: User dpl -1 dpl !
137:
138: User state ( -- a-addr ) \ core,tools-ext
139: \G USER VARIABLE: a-addr is the address of a cell containing
140: \G the compilation state flag. 0 => interpreting, -1 => compiling.
141: \G A program shall not directly alter the value of @code{state}. The
142: \G following Standard words alter the value in @code{state}:
143: \G @code{:} (colon) @code{;} (semicolon) @code{abort} @code{quit}
144: \G @code{:noname} @code{[} (left-bracket) @code{]} (right-bracket)
145: \G @code{;code}
146: 0 state !
147:
148: AUser normal-dp \ the usual dictionary pointer
149: AUser dpp normal-dp dpp !
150: \ the pointer to the current dictionary pointer
151: \ ist reset to normal-dp on (doerror)
152: \ (i.e. any throw caught by quit)
153: AUser LastCFA
154: AUser Last
155:
156: has? glocals [IF]
157: User locals-size \ this is the current size of the locals stack
158: \ frame of the current word
159: [THEN]
160:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>