File:  [gforth] / gforth / Attic / dumpimage.fs
Revision 1.5: download - view: text, annotated - select for diffs
Tue Nov 7 18:06:37 1995 UTC (28 years, 4 months ago) by anton
Branches: MAIN
CVS tags: gforth-0_1beta, HEAD
added copyright headers
changes to loadfilename & co. to make savesystem transparent to
 assertions and ~~

    1: \ image dump                                           15nov94py
    2: 
    3: \ 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: Create magic  s" gforth00" here over allot swap move
   22: 
   23: '1 1 cells + 0 pad ! -1 pad c! pad @ 0< +  magic 7 chars + c!
   24: 
   25: : save-string-dict { addr1 u -- addr2 u }
   26:     here { addr2 }
   27:     u allot
   28:     addr1 addr2 u move
   29:     addr2 u ;
   30: 
   31: : update-image-included-files ( -- )
   32:     included-files 2@ { addr cnt }
   33:     image-included-files 2@ { old-addr old-cnt }
   34:     align here { new-addr }
   35:     cnt 2* cells allot
   36:     new-addr cnt image-included-files 2!
   37:     old-addr new-addr old-cnt 2* cells move
   38:     cnt old-cnt
   39:     U+DO
   40:         addr i 2* cells + 2@ save-string-dict
   41: 	new-addr i 2* cells + 2!
   42:     LOOP ;
   43: 
   44: : dump-fi ( addr u -- )
   45:     w/o bin create-file throw >r
   46:     magic 8 r@ write-file throw
   47:     update-image-included-files
   48:     forthstart here over - dup forthstart cell+ !
   49:                          r@ write-file throw
   50: \  relinfo here forthstart - 1- 8 cells / 1+ r@ write-file throw
   51:   r> close-file throw ;
   52: 
   53: : savesystem ( "name" -- ) \ gforth
   54:     name dump-fi ;

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