File:  [gforth] / gforth / kernel / tools.fs
Revision 1.11: download - view: text, annotated - select for diffs
Mon Mar 29 22:52:35 1999 UTC (23 years, 8 months ago) by crook
Branches: MAIN
CVS tags: HEAD
Added section talking about different memory regions, and glossed
associated words. Glossed words associated with user input; the
manual still needs a bunch of examples for these.

    1: \ TOOLS.FS     Toolkit extentions                      2may93jaw
    2: 
    3: \ Copyright (C) 1995,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: \ May be cross-compiled
   22: 
   23: hex
   24: 
   25: \ .S            CORE / CORE EXT                         9may93jaw
   26: 
   27: variable maxdepth-.s
   28: 9 maxdepth-.s !
   29: 
   30: : .s ( -- ) \ tools dot-s
   31:     \G Display the number of items on the data stack,
   32:     \G followed by a list of the items; TOS is the right-most item.
   33:     ." <" depth 0 .r ." > "
   34:     depth 0 max maxdepth-.s @ min
   35:     dup 0
   36:     ?do
   37: 	dup i - pick .
   38:     loop
   39:     drop ;
   40: 
   41: \ DUMP                       2may93jaw - 9may93jaw    06jul93py
   42: \ looks very nice, I know
   43: 
   44: Variable /dump
   45: 
   46: : .4 ( addr -- addr' )
   47:     3 FOR  -1 /dump +!  /dump @ 0<
   48:         IF  ."    "  ELSE  dup c@ 0 <<# # # #> type #>> space  THEN
   49:     char+ NEXT ;
   50: : .chars ( addr -- )
   51:     /dump @ bounds
   52:     ?DO I c@ dup 7f bl within
   53: 	IF  drop [char] .  THEN  emit
   54:     LOOP ;
   55: 
   56: : .line ( addr -- )
   57:   dup .4 space .4 ." - " .4 space .4 drop  10 /dump +!  space .chars ;
   58: 
   59: : dump  ( addr u -- ) \ tools dump
   60:     \G Display @var{u} lines of memory starting at address @var{addr}. Each line
   61:     \G displays the contents of 16 bytes. When Gforth is running under
   62:     \G an operating system you may get @file{Invalid memory address} errors
   63:     \G if you attempt to access arbitrary locations.
   64:     cr base @ >r hex        \ save base on return stack
   65:     0 ?DO  I' I - 10 min /dump !
   66: 	dup 8 u.r ." : " dup .line cr  10 +
   67: 	10 +LOOP
   68:     drop r> base ! ;
   69: 
   70: \ ?                                                     17may93jaw
   71: 
   72: : ? ( a-addr -- ) \ tools question
   73:     \G Display the contents of address @var{a-addr} in the current number base.
   74:     @ . ;
   75: 
   76: \ words visible in roots                               14may93py
   77: 
   78: include  ../termsize.fs
   79: 
   80: : words
   81:     \G ** this will not get annotated. See other defn in search.fs .. **
   82:     \G It does not work to use "wordset-" prefix since this file is glossed
   83:     \G by cross.fs which doesn't have the same functionalty as makedoc.fs
   84:     cr 0 context @ wordlist-id
   85:     BEGIN
   86: 	@ dup
   87:     WHILE
   88: 	2dup name>string nip 2 + dup >r +
   89: 	cols >=
   90: 	IF
   91: 	    cr nip 0 swap
   92: 	THEN
   93: 	dup name>string type space r> rot + swap
   94:     REPEAT
   95:     2drop ;
   96: 
   97: ' words alias vlist ( -- ) \ gforth
   98: \g Old (pre-Forth-83) name for @code{WORDS}.
   99: 

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>