File:  [gforth] / gforth / savesys.fs
Revision 1.6: download - view: text, annotated - select for diffs
Sun Mar 9 15:16:52 2003 UTC (16 years, 2 months ago) by anton
Branches: MAIN
CVS tags: v0-6-2, v0-6-1, v0-6-0, HEAD
updated copyright years

    1: \ image dump                                           15nov94py
    2: 
    3: \ Copyright (C) 1995,1997,2003 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., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
   20: 
   21: : save-string-dict { addr1 u -- addr2 u }
   22:     here { addr2 }
   23:     u allot
   24:     addr1 addr2 u move
   25:     addr2 u ;
   26: 
   27: : update-image-included-files ( -- )
   28:     included-files 2@ { addr cnt }
   29:     image-included-files 2@ { old-addr old-cnt }
   30:     align here { new-addr }
   31:     cnt 2* cells allot
   32:     new-addr cnt image-included-files 2!
   33:     old-addr new-addr old-cnt 2* cells move
   34:     cnt old-cnt
   35:     U+DO
   36:         addr i 2* cells + 2@ save-string-dict
   37: 	new-addr i 2* cells + 2!
   38:     LOOP
   39:     maxalign ;
   40: 
   41: : dump-fi ( addr u -- )
   42:     w/o bin create-file throw >r
   43:     update-image-included-files
   44:     update-image-order
   45:     here forthstart - forthstart 2 cells + !
   46:     forthstart
   47:     begin \ search for start of file ("#! " at a multiple of 8)
   48: 	8 -
   49: 	dup 3 s" #! " str=
   50:     until ( imagestart )
   51:     here over - r@ write-file throw
   52:     r> close-file throw ;
   53: 
   54: : savesystem ( "name" -- ) \ gforth
   55:     name dump-fi ;

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