meta: cosmetix
[urforth.git] / level1 / 94_envquery.f
blob74da7a3119e91d35f89f50dc783016e59bc6b926
1 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2 ;; UrForth level 1: self-hosting 32-bit Forth compiler
3 ;; Copyright (C) 2020 Ketmar Dark // Invisible Vector
4 ;; GPLv3 ONLY
5 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
7 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
8 ;; various modules can add other words
9 ;; floating point module does this, for example
11 vocabulary-nohash (env-queries) (hidden)
12 voc-set-active (env-queries)
14 ;; string with the system version
15 : URFORTH ( -- addr count ) (URVERSION->PAD) ;
16 ;; maximum size of a counted string, in characters
17 : /COUNTED-STRING ( -- n ) 0x000f_ffff ;
18 ;; size of the pictured numeric output string buffer, in characters
19 : /HOLD ( -- n ) #pad-area-resv ;
20 ;; size of the scratch area pointed to by PAD, in characters
21 : /PAD ( -- n ) #pad-area ;
22 ;; size of one address unit, in bits
23 : ADDRESS-UNIT-BITS ( -- n ) 1 ;
24 ;; true if floored division is the default (UrForth is symmetric)
25 : FLOORED ( -- n ) false ;
26 ;; maximum value of any character in the implementation-defined character set
27 : MAX-CHAR ( -- n ) 255 ;
28 ;; largest usable signed double number
29 : MAX-D ( -- d ) 0xffff_ffff 0x7fff_ffff ;
30 ;; largest usable signed integer
31 : MAX-N ( -- n ) 0x7fff_ffff ;
32 ;; largest usable unsigned integer
33 : MAX-U ( -- u ) 0xffff_ffff ;
34 ;; largest usable unsigned double number
35 : MAX-UD ( -- ud ) 0xffff_ffff 0xffff_ffff ;
36 ;; maximum size of the return stack, in cells
37 : RETURN-STACK-CELLS ( -- n ) #rp @ ;
38 ;; maximum size of the data stack, in cells
39 : STACK-CELLS ( -- n ) #sp @ ;
41 voc-set-active forth
44 : ENVIRONMENT? ( addr count -- flag // false // i*x true )
45 dup 1 250 within ifnot 2drop false exit endif
46 vocid: (env-queries) voc-search-noimm if execute true
47 else has-word? ;; otherwise check a word
48 endif