home *** CD-ROM | disk | FTP | other *** search
- \ SAVESYS.SEQ SAVE-SYSTEM and TURNKEY by Tom Zimmer
-
- .comment:
-
-
-
- This file allows saving the Forth memory image as a .COM file. This
- .COM file can include the Forth HEADs, or they may optionally be omitted.
- The word SAVE-SYSTEM will save Forth with HEADs. The word TURNKEY used
- in the following manner:
-
- ' MYAPPLICATION TURNKEY MYAPP.COM <enter>
-
- This will create a .COM file on disk which contains ONLY the Forth code
- up to HERE, without HEADs. The .COM file will automatically execute the
- word MYAPPLICATION after cold start initialization. This results in a
- pseudo minimized Forth application. The program can be made smaller by
- omitting many of the Forth utilities loaded in the file SDF.SEQ.
-
- comment;
-
- ONLY FORTH ALSO DEFINITIONS
-
- : SAVE ( Addr len filename --- )
- SHNDL+ !HCB
- SHNDL+ HDELETE DROP
- SHNDL+ HCREATE ABORT" Save Create ERR!"
- SHNDL+ HWRITE 0= ABORT" Save Write ERR!"
- SHNDL+ HCLOSE ABORT" Save Close ERR!" ;
-
- : SAVE-SYSTEM ( -- )
- HERE 0 XHERE 0 D+ YHERE 0 D+ 20. D+ SP@ 0 D>
- ABORT" Too big. Use FSAVE."
- HERE XSTART ! 0 XS: ?CS: HERE XHERE DUP ALLOT CMOVEL
- HERE YSTART ! 0 YS: ?CS: HERE YHERE DUP ALLOT CMOVEL
- XMOVED OFF
- 256 HERE SAVE
- XSTART @ DP !
- YSTART OFF
- XMOVED ON ;
-
- DEFER TBOOT ' NOOP IS TBOOT \ Turnkey BOOT
-
- : TSETSEGS ( --- )
- DOSVER 2 < ABORT" Must have DOS 2 or higher."
- #CODESEGS #LISTSEGS +
- MEMSET MEMCHK \ Allocate proper memory
- YSEG OFF \ No heads
- ?ES: XSEG !
- ?CS: DUP SSEG ! VTSEG ! \ Set segments
- XSTART @ DP ! \ Reset DP
- #OUT 0! 24 #LINE ! ; \ set #OUT and #LINE
-
- : TSTART ( --- )
- SP0 @ 'TIB ! >IN OFF SPAN OFF #TIB OFF LOADING OFF
- DEFAULT TBOOT BYE ;
-
- : TURNKEY ( A1 | name.COM --- ) \ A! is CFA of BOOT function
- HERE 0 XHERE 0 D+ 20. D+ SP@ 0 D>
- ABORT" Too big. Use FSAVE."
- 1 ?ENOUGH \ Assure enough params
- IS TBOOT \ Save into TBOOT
- ['] TSETSEGS IS SEGSET \ Set segments
- ['] TSTART IS BOOT \ TSTART is BOOT
- HERE XSTART ! 0 XS: ?CS: HERE XHERE DUP ALLOT CMOVEL
- YSTART OFF
- XMOVED OFF
- 256 HERE SAVE \ Save the code space
- XSTART @ DP ! \ Reset DP
- YSTART OFF \ Clear Head flag
- XMOVED ON ;
-
-