[gforth] / gforth / environ.fs  

gforth: gforth/environ.fs


1 : anton 1.2 \ environmental queries
2 : anton 1.1
3 : anton 1.8 \ Copyright (C) 1995 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 : pazsan 1.3 \ wordlist constant environment-wordlist
22 : anton 1.1
23 : pazsan 1.3 Create environment-wordlist wordlist drop
24 :    
25 : anton 1.10 : environment? ( c-addr u -- false / ... true ) \ core environment-query
26 : anton 1.2 environment-wordlist search-wordlist if
27 :     execute true
28 :     else
29 :     false
30 :     endif ;
31 :    
32 : jwilke 1.13 : e? name environment? ; immediate
33 :    
34 : anton 1.2 environment-wordlist set-current
35 :     get-order environment-wordlist swap 1+ set-order
36 :    
37 :     \ assumes that chars, cells and doubles use an integral number of aus
38 :    
39 :     \ this should be computed in C as CHAR_BITS/sizeof(char),
40 :     \ but I don't know any machine with gcc where an au does not have 8 bits.
41 : anton 1.7 8 constant ADDRESS-UNIT-BITS ( -- n ) \ environment
42 : anton 1.2 1 ADDRESS-UNIT-BITS chars lshift 1- constant MAX-CHAR
43 :     MAX-CHAR constant /COUNTED-STRING
44 :     ADDRESS-UNIT-BITS cells 2* 2 + constant /HOLD
45 :     &84 constant /PAD
46 :     true constant CORE
47 : anton 1.9 true constant CORE-EXT
48 : anton 1.2 1 -3 mod 0< constant FLOORED
49 :    
50 :     1 ADDRESS-UNIT-BITS cells 1- lshift 1- constant MAX-N
51 :     -1 constant MAX-U
52 : anton 1.1
53 : anton 1.2 -1 MAX-N 2constant MAX-D
54 :     -1. 2constant MAX-UD
55 : pazsan 1.3
56 : anton 1.12 version-string 2constant gforth \ version string (for versions>0.3.0)
57 :     \ the version strings of the various versions are guaranteed to be
58 :     \ sorted lexicographically
59 : anton 1.1
60 : anton 1.10 : return-stack-cells ( -- n )
61 :     [ forthstart 6 cells + ] literal @ cell / ;
62 :    
63 :     : stack-cells ( -- n )
64 :     [ forthstart 4 cells + ] literal @ cell / ;
65 :    
66 :     : floating-stack ( -- n )
67 : pazsan 1.11 [ forthstart 5 cells + ] literal @
68 :     [IFDEF] float float [ELSE] [ 1 floats ] Literal [THEN] / ;
69 : anton 1.10
70 : anton 1.5 \ !! max-float
71 : anton 1.6 15 constant #locals \ 1000 64 /
72 :     \ One local can take up to 64 bytes, the size of locals-buffer is 1000
73 : anton 1.5 maxvp constant wordlists
74 : anton 1.2
75 :     forth definitions
76 :     previous
77 : anton 1.1

CVS Admin

Powered by ViewCVS 1.0-dev
(Powered by ViewCVS)

ViewCVS and CVS Help