Annotation of gforth/kernel/tools.fs, revision 1.27
1.1 anton 1: \ TOOLS.FS Toolkit extentions 2may93jaw
2:
1.26 anton 3: \ Copyright (C) 1995,1998,1999,2001,2003,2006,2007 Free Software Foundation, Inc.
1.1 anton 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
1.27 ! anton 9: \ as published by the Free Software Foundation, either version 3
1.1 anton 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
1.27 ! anton 18: \ along with this program. If not, see http://www.gnu.org/licenses/.
1.1 anton 19:
20: \ May be cross-compiled
21:
1.13 jwilke 22: require ./io.fs \ type ...
23: require ./nio.fs \ . <# ...
24: require ./int.fs \ wordlist-id ..
25:
1.1 anton 26: hex
27:
28: \ .S CORE / CORE EXT 9may93jaw
29:
1.25 anton 30: variable maxdepth-.s ( -- addr ) \ gforth maxdepth-dot-s
1.23 pazsan 31: \G A variable containing 9 by default. @code{.s} and @code{f.s}
1.22 anton 32: \G display at most that many stack items.
1.1 anton 33: 9 maxdepth-.s !
34:
1.7 crook 35: : .s ( -- ) \ tools dot-s
1.22 anton 36: \G Display the number of items on the data stack, followed by a list
37: \G of the items (but not more than specified by @code{maxdepth-.s};
38: \G TOS is the right-most item.
1.1 anton 39: ." <" depth 0 .r ." > "
40: depth 0 max maxdepth-.s @ min
41: dup 0
42: ?do
43: dup i - pick .
44: loop
45: drop ;
46:
47: \ DUMP 2may93jaw - 9may93jaw 06jul93py
48: \ looks very nice, I know
49:
50: Variable /dump
51:
52: : .4 ( addr -- addr' )
53: 3 FOR -1 /dump +! /dump @ 0<
1.9 anton 54: IF ." " ELSE dup c@ 0 <<# # # #> type #>> space THEN
1.1 anton 55: char+ NEXT ;
56: : .chars ( addr -- )
57: /dump @ bounds
58: ?DO I c@ dup 7f bl within
59: IF drop [char] . THEN emit
60: LOOP ;
61:
62: : .line ( addr -- )
63: dup .4 space .4 ." - " .4 space .4 drop 10 /dump +! space .chars ;
64:
1.7 crook 65: : dump ( addr u -- ) \ tools dump
1.10 crook 66: \G Display @var{u} lines of memory starting at address @var{addr}. Each line
1.7 crook 67: \G displays the contents of 16 bytes. When Gforth is running under
68: \G an operating system you may get @file{Invalid memory address} errors
69: \G if you attempt to access arbitrary locations.
1.1 anton 70: cr base @ >r hex \ save base on return stack
71: 0 ?DO I' I - 10 min /dump !
72: dup 8 u.r ." : " dup .line cr 10 +
73: 10 +LOOP
74: drop r> base ! ;
75:
76: \ ? 17may93jaw
77:
1.7 crook 78: : ? ( a-addr -- ) \ tools question
1.10 crook 79: \G Display the contents of address @var{a-addr} in the current number base.
1.7 crook 80: @ . ;
1.1 anton 81:
1.2 jwilke 82: \ words visible in roots 14may93py
83:
1.12 jwilke 84: include ./../termsize.fs
1.2 jwilke 85:
1.17 anton 86: : wordlist-words ( wid -- ) \ gforth
87: \G Display the contents of the wordlist wid.
1.20 pazsan 88: [ has? ec 0= [IF] ] wordlist-id [ [THEN] ]
89: 0 swap cr
1.2 jwilke 90: BEGIN
91: @ dup
92: WHILE
1.3 pazsan 93: 2dup name>string nip 2 + dup >r +
1.2 jwilke 94: cols >=
95: IF
96: cr nip 0 swap
97: THEN
1.3 pazsan 98: dup name>string type space r> rot + swap
1.2 jwilke 99: REPEAT
100: 2drop ;
1.17 anton 101:
102: : words
103: \G ** this will not get annotated. See other defn in search.fs .. **
104: \G It does not work to use "wordset-" prefix since this file is glossed
105: \G by cross.fs which doesn't have the same functionalty as makedoc.fs
1.21 pazsan 106: [ has? ec 0= [IF] ] context @ [ [ELSE] ] forth-wordlist [ [THEN] ]
107: wordlist-words ;
1.2 jwilke 108:
109: ' words alias vlist ( -- ) \ gforth
110: \g Old (pre-Forth-83) name for @code{WORDS}.
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>