[gforth] / gforth / savesys.fs  

gforth: gforth/savesys.fs


1 : anton 1.1 \ image dump 15nov94py
2 :    
3 : anton 1.2 \ Copyright (C) 1995,1997 Free Software Foundation, Inc.
4 : anton 1.1
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 : anton 1.3 \ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
20 : anton 1.1
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 : anton 1.5 update-image-order
45 : anton 1.1 here forthstart - forthstart 2 cells + !
46 :     forthstart
47 :     begin \ search for start of file ("#! " at a multiple of 8)
48 :     8 -
49 : anton 1.4 dup 3 s" #! " str=
50 : anton 1.1 until ( imagestart )
51 :     here over - r@ write-file throw
52 :     r> close-file throw ;
53 :    
54 :     : savesystem ( "name" -- ) \ gforth
55 :     name dump-fi ;

CVS Admin

Powered by ViewCVS 1.0-dev
(Powered by ViewCVS)

ViewCVS and CVS Help