Annotation of gforth/savesys.fs, revision 1.2

1.1       anton       1: \ image dump                                           15nov94py
                      2: 
1.2     ! anton       3: \ Copyright (C) 1995,1997 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
                      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: : 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:     here forthstart - forthstart 2 cells + !
                     45:     forthstart
                     46:     begin \ search for start of file ("#! " at a multiple of 8)
                     47:        8 -
                     48:        dup 3 s" #! " compare 0=
                     49:     until ( imagestart )
                     50:     here over - r@ write-file throw
                     51:     r> close-file throw ;
                     52: 
                     53: : savesystem ( "name" -- ) \ gforth
                     54:     name dump-fi ;

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