Commit bb79a8a8 authored by pazsan's avatar pazsan

*Added:

* configure.bat configures on MS-DOS machines
* io-dos.h provides IO for MS-DOS
* makefile.dos is a GNU make Makefile for MS-DOS
*Changed:
* Merged gray/gforth and gray/gray4, added conditional compilation for
  gray ports (gforth and bigFORTH first)
* added gforth recognising string in environment
* added interpreter support for images (starts now with magic)
* changed make rule for ds2texi, so that it can run with Messy-DOS
* added SAVESYSTEM in dumpimage.fs
* fixed bug in Makefile for big endian systems (->configure)
parent 421154c9
......@@ -392,11 +392,18 @@ else
ln -s kernl32l.fi gforth.fi
fi
if [ x$bigendian = x1 ]
then
kernalswap='s|kernl32l.fi kernl32b.fi|kernl32b.fi kernl32l.fi|'
kernalexec='-e'
fi
sed -e "s|^XCFLAGS[ ]*=*\(.*\)$|XCFLAGS = \1 $flags|" \
-e "s|^XDEFINES[ ]*=*\(.*\)$|XDEFINES = \1 $defines|" \
-e "s|^OBJECTS[ ]*=*\(.*\)$|OBJECTS = \1 $extra_obs|" \
-e "s|^CFLAGS[ ]*=*\(.*\)$|CFLAGS = $debugging\1|" \
-e "s|^LDFLAGS[ ]*=*\(.*\)$|LDFLAGS = $debugging\1|" \
$kernalexec "$kernalswap" \
Makefile.in > Makefile
exit 0
......
@ECHO OFF
REM Copyright 1994 by the GNU FORTH Team
ECHO *** Configuring for MS-DOS with DJGPP GNU C ***
COPY MAKEFILE MAKEFILE.DOS
COPY IO-DOS.H IO.H
COPY KERNL32L.FI GFORTH.FI
\ CROSS.FS The Cross-Compiler 06oct92py
\ $Id: cross.fs,v 1.15 1994-11-15 15:55:34 pazsan Exp $
\ $Id: cross.fs,v 1.16 1994-11-17 15:53:07 pazsan Exp $
\ Idea and implementation: Bernd Paysan (py)
\ Copyright 1992-94 by the GNU Forth Development Group
......@@ -738,8 +738,10 @@ bigendian Constant bigendian
: save-cross ( "name" -- )
bl parse ." Saving to " 2dup type
w/o bin create-file throw >r
image @ there r@ write-file throw
bit$ @ there 1- cell>bit rshift 1+ r@ write-file throw
s" gforth00" r@ write-file throw \ write magic
image @ there r@ write-file throw \ write image
bit$ @ there 1- cell>bit rshift 1+
r@ write-file throw \ write tags
r> close-file throw ;
\ words that should be in minimal
......
......@@ -7,6 +7,13 @@
\ The glossary entries are generated from data present in the wordlist
\ `documentation'. Each word resides there under its own name.
script? [IF]
warnings off
include search-order.fs
include struct.fs
include debugging.fs
[THEN]
wordlist constant documentation
struct
......@@ -92,3 +99,9 @@ create docline doclinelength chars allot
docline swap process-line
repeat
drop rdrop ;
script? [IF]
include prims2x.fs
s" primitives.b" ' register-doc process-file
s" gforth.ds" r/o open-file throw ds2texi bye
[THEN]
\ image dump 15nov94py
: dump-fi ( addr u -- ) w/o open-file throw >r
: dump-fi ( addr u -- ) w/o bin create-file throw >r
s" gforth00" r@ write-file throw
forthstart here over - dup forthstart cell+ !
r@ write-file throw
relinfo here forthstart - 1- 8 cells / 1+ r@ write-file throw
r> close-file throw ;
: savesystem ( "name" -- ) name dump-fi ;
\ environmental queries
wordlist constant environment-wordlist
\ wordlist constant environment-wordlist
Create environment-wordlist wordlist drop
: environment? ( c-addr u -- false / ... true )
environment-wordlist search-wordlist if
......@@ -31,6 +33,8 @@ true constant CORE
-1 MAX-N 2constant MAX-D
-1. 2constant MAX-UD
0 0 2constant gforth \ minor mayor version
\ !! RETURN-STACK-CELLS
\ !! STACK-CELLS
......
\ Copyright 1990 Martin Anton Ertl
\
\ TERMS AND CONDITIONS FOR USE, COPYING, MODIFICATION AND DISTRIBUTION
\
\ 1. You may use this product provided that
\ a) you DO NOT USE IT FOR MILITARY PURPOSES; and
\ b) cause the terms of parapraph 1 to apply to any products
\ developed using this product and make these terms known to all
\ users of such product;
\ By using this product, you indicate the acceptance of the terms of
\ this paragraph.
\
\ 2. Except for the restrictions mentioned in paragraph 1, you may use
\ the Program.
\
\ 3. You may distribute verbatim or modified copies of this program,
\ provided that
\ a) you keep intact all copyright notices, this license, and the notices
\ referring to this license and to the absence of warranty; and
\ b) you cause any work that you distribute or publish that contains the
\ Program or part of it to be licensed to all third parties under the
\ terms of this license. You may not impose any further restriction
\ on the recipients exercise of the rights granted herein. Mere
\ aggregation of another independent work with the Program or its
\ derivative on a volume of storage or distribution medium does not
\ bring the other work under the scope of these terms; and
\ c) you cause the derivative to carry prominent notices saying that
\ you changed the Program.
\
\ 4. You may distribute the Program or its derivative in intermediate,
\ object or executable code, if you accompany it with the complete
\ machine-readable source code.
\
\ 5. By using, modifying, copying or distributing the Program you
\ indicate your acceptance of this license and all its terms and
\ conditions.
\
\ 6. This Program is provided WITHOUT WARRANTY of any kind, either
\ express or implied, including, but not limited to, the implied
\ warranties of merchantability and fitness for a particular purpose. In
\ no event, unless required by applicable law or agreed to in writing,
\ will any copyright holder, or any other party who may modify and or
\ redistribute the Program, be liable to you for any damages, even if
\ such holder or other party has been advised of the possibility of such
\ damages.
\ END OF TERMS AND CONDITIONS )
\ Copyright 1990, 1991, 1994 Martin Anton Ertl
\ This program is free software; you can redistribute it and/or modify
\ it under the terms of the GNU General Public License as published by
\ the Free Software Foundation; either version 2 of the License, or
\ (at your option) any later version.
\ This program is distributed in the hope that it will be useful,
\ but WITHOUT ANY WARRANTY; without even the implied warranty of
\ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\ GNU General Public License for more details.
\ You should have received a copy of the GNU General Public License
\ along with this program; if not, write to the Free Software
\ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
\ recursive descent parser generator )
\ ANS FORTH prolog
: defined? ( "word" -- flag ) bl word find nip ;
defined? WARNINGS 0=
[IF]
Variable warnings
warnings on
[THEN]
\ end of ANS FORTH prolog
warnings @ [IF]
.( Loading Gray ... Copyright 1990 Martin Anton Ertl; NO WARRANTY ) cr
.( Loading Gray ... Copyright 1990-1994 Martin Anton Ertl; NO WARRANTY ) cr
[THEN]
\ misc )
: noop ;
1 cells constant cell
cell 8 * constant bits/cell \ !! implementation dependent )
s" address-unit-bits" environment? 0=
[IF]
warnings @ [IF]
cr .( environmental attribute address-units-bits unknown, computing... ) cr
[THEN]
\ if your machine has more bits/au, this assumption wastes space
\ if your machine has fewer bits/au, gray will not work
: (bits/cell) ( -- n ) 1 0 invert dup 1 rshift xor
BEGIN dup 1 = 0= WHILE 1 rshift swap 1+ swap REPEAT drop ;
(bits/cell)
warnings @ [IF]
.( You seem to have ) dup 1 cells / . .( bits/address unit) cr
[THEN]
[ELSE]
cells
[THEN]
constant bits/cell \ !! implementation dependent )
: ?not? ( f -- f )
0= ;
postpone 0= ; immediate
: 2, ( w1 w2 -- )
here 2 cells allot 2! ;
......@@ -138,6 +134,11 @@ variable empty-ptr 0 empty-ptr ! \ updatd by max-member )
bits/cell /mod
cells rot +
swap ;
\ the /mod could be optimized into a RSHIFT and an AND, if bits/cell is
\ a power of 2, but in an interpreted implementation this would only be
\ faster if the machine has very slow division and in a native code
\ implementation the compiler should be intelligent enough to optimize
\ without help.
: add-member \ u set -- )
\ changes set to include u )
......@@ -280,18 +281,42 @@ struct
\ true if the syntax-expr can derive eps )
aligned cell context-var follow-set
\ the tokens of the terminals that can follow the syntax-expr )
s" gforth" environment?
[IF] 2drop \ clear gforth's version numbers )
aligned 2 cells context-var source-location \ for error msgs )
constant syntax-expr \ length of a syntax-expr )
[ELSE]
s" bigFORTH" environment?
[IF] 2drop \ clear bigFORTH' version numbers )
aligned cell context-var source-location
\ for error msgs
[ELSE]
\ !! replace the stuff until constant with something working on your system
aligned 3 cells context-var source-location
\ for error msgs
80 chars context-var error-info
\ string
[THEN] [THEN]
aligned constant syntax-expr \ length of a syntax-expr )
: make-syntax-expr \ map -- syntax-expr )
\ allocate a syntax-expr and initialize it )
here swap , false c, false c,
align 0 , false c, align empty ,
\ source location !! implementation dependent )
\ source location. !! replace the stuff until `;' with your stuff
\ if you use blocks, use:
\ blk @ >in @ 2,
\ the following is just a dummy
[ s" gforth" environment? ]
[IF] [ 2drop ]
0 loadline @ 2,
[ELSE]
[ s" bigFORTH" environment? ]
[IF] [ 2drop ]
makeview w, >in @ w,
[ELSE]
source 80 min >r here 3 cells + r@ cmove
here 3 cells + , r@ , >in @ 80 min , r> chars allot align
[THEN] [THEN]
;
......@@ -300,8 +325,17 @@ constant syntax-expr \ length of a syntax-expr )
\ !! implementation dependent )
\ prints the info stored in source-location in a usable way )
\ prints where the error happened )
[ s" gforth" environment? ]
[IF] [ 2drop ]
source-location 2@ ." line" . drop ." :" ;
[ELSE]
[ s" bigFORTH" environment? ]
[IF] [ 2drop ]
source-location dup w@ $3FF and scr ! 2+ w@ r# ! ;
[ELSE]
source-location 2@ swap cr type cr
error-info @ 2 - spaces ." ^" cr ." ::: " ;
[THEN] [THEN]
: gray-error abort ;
......
/* Input driver header */
#define prep_terminal()
#define deprep_terminal()
#define install_signal_handlers()
#include <conio.h>
#include <setjmp.h>
extern jmp_buf throw_jmp_buf;
#define key() getch()
#define key_query FLAG(kbhit())
......@@ -1421,7 +1421,7 @@ Defer 'cold ' noop IS 'cold
." GNU Forth 0.0alpha, Copyright (C) 1994 Free Software Foundation, Inc." cr
." GNU Forth comes with ABSOLUTELY NO WARRANTY; for details type `license'" cr
." Type `bye' to exit"
quit ;
loadline off quit ;
: license ( -- ) cr
." This program is free software; you can redistribute it and/or modify" cr
......
/*
$Id: main.c,v 1.17 1994-11-15 16:54:57 pazsan Exp $
$Id: main.c,v 1.18 1994-11-17 15:53:16 pazsan Exp $
Copyright 1993 by the ANSI figForth Development Group
*/
......@@ -44,6 +44,8 @@ char *progname;
/* image file format:
* preamble (is skipped off), size multiple of 8
* magig: "gforth00" (means format version 0.0)
* size of image with stacks without tags (in bytes)
* size of image without stacks and tags (in bytes)
* size of data and FP stack (in bytes)
......@@ -94,10 +96,23 @@ Cell *loader(FILE *imagefile)
{
Cell header[3];
Cell *image;
Char magic[8];
int wholesize;
int imagesize; /* everything needed by the image */
fread(header,1,3*sizeof(Cell),imagefile);
do
{
if(fread(magic,sizeof(Char),8,imagefile) < 8) {
fprintf(stderr,"This file doesn't seam to be a gforth image\n");
exit(1);
}
#ifdef DEBUG
printf("Magic found: %s\n",magic);
#endif
}
while(memcmp(magic,"gforth00",8));
fread(header,sizeof(Cell),3,imagefile);
if (dictsize==0)
dictsize = header[0];
if (dsize==0)
......
#Copyright 1992 by the ANSI figForth Development Group
RM = xdel
CP = copy
GCC = gcc
FORTH = gforth
CC = gcc
MAKE = make
XCFLAGS = -fforce-mem -fforce-addr -fomit-frame-pointer -fno-defer-pop -fcaller-saves
XDEFINES = -DDIRECT_THREADED -DUSE_GETOPT
SWITCHES = $(XCFLAGS) $(XDEFINES) -DDEFAULTBIN='"/forth/ansforth"' #-DNDEBUG #turn off assertions
CFLAGS = -g -O4 -Wall $(SWITCHES)
#-Xlinker -n puts text and data into the same 256M region
#John Wavrik should use -Xlinker -N to get a writable text (executable)
LDFLAGS = -g -Xlinker -N
LDLIBS = -lm -lpc
EMACS = emacs
INCLUDES = forth.h io.h getopt.h
MACHINES = apollo68k.h decstation.h 386.h hppa.h sparc.h
FORTH_SRC = add.fs assert.fs blocks.fs bufio.fs cross.fs debug.fs \
debugging.fs dumpimage.fs environ.fs errore.fs etags.fs \
extend.fs filedump.fs float.fs glocals.fs glosgen.fs gray.fs \
hash.fs kernal.fs locals-test.fs look.fs mach32b.fs \
mach32l.fs main.fs other.fs prims2x.fs search-order.fs \
see.fs sieve.fs startup.fs struct.fs test2.fs tools.fs \
toolsext.fs vars.fs vt100.fs wordinfo.fs
SOURCES = Makefile primitives engine.c main.c ecvt.c \
gforth.ds $(MACHINES) $(INCLUDES) $(FORTH_SRC)
RCS_FILES = $(SOURCES) INSTALL ToDo model high-level
GEN = gforth
GEN_PRECIOUS = primitives.i prim_labels.i primitives.b aliases.fs
OBJECTS = engine.o ecvt.o main.o getopt1.o getopt.o
# things that need a working forth system to be generated
# this is used for antidependences,
FORTH_GEN = primitives.i prim_labels.i aliases.fs \
kernl32l.fi kernl32b.fi gforth.texi
all:
if not exist gforth.exe $(MAKE) first
$(MAKE) more
first: gforth
more: $(FORTH_GEN) gforth
#from the gcc Makefile:
#"Deletion of files made during compilation.
# There are four levels of this:
# `mostlyclean', `clean', `distclean' and `realclean'.
# `mostlyclean' is useful while working on a particular type of machine.
# It deletes most, but not all, of the files made by compilation.
# It does not delete libgcc.a or its parts, so it won't have to be recompiled.
# `clean' deletes everything made by running `make all'.
# `distclean' also deletes the files made by config.
# `realclean' also deletes everything that could be regenerated automatically."
clean:
-$(RM) $(GEN) *.o *.s
distclean: clean
-$(RM) machine.h
realclean: distclean
-$(RM) $(GEN_PRECIOUS)
#does not work
#gforth.tar.gz: $(SOURCES) $(GEN_PRECIOUS) CVS
# cd ..; tar cvf gforth/gforth.tar gforth/{$^}; gzip -9 gforth/gforth.tar
gforth: $(OBJECTS)
-$(CP) gforth gforth~
$(GCC) $(LDFLAGS) $(OBJECTS) $(LDLIBS) -o $@
coff2exe gforth
kernl32l.fi: main.fs search-order.fs cross.fs aliases.fs vars.fs add.fs \
errore.fs kernal.fs extend.fs tools.fs toolsext.fs \
mach32l.fs $(FORTH_GEN)
-$(CP) kernl32l.fi kernl32l.fi~
$(FORTH) -e 's" mach32l.fs"' main.fs
-$(CP) kernl32l.fi gforth.fi
kernl32b.fi: main.fs search-order.fs cross.fs aliases.fs vars.fs add.fs \
errore.fs kernal.fs extend.fs tools.fs toolsext.fs \
mach32b.fs $(FORTH_GEN)
-$(CP) kernl32b.fi kernl32b.fi~
$(FORTH) -e 's" mach32b.fs"' main.fs
engine.s: engine.c primitives.i prim_labels.i machine.h $(INCLUDES)
$(GCC) $(CFLAGS) -S engine.c
engine.o: engine.c primitives.i prim_labels.i machine.h $(INCLUDES)
primitives.b: primitives
m4 primitives >$@
primitives.i : primitives.b prims2x.fs
$(FORTH) prims2x.fs -e "s\" primitives.b\" ' output-c process-file bye" >$@
prim_labels.i : primitives.b prims2x.fs
$(FORTH) prims2x.fs -e "s\" primitives.b\" ' output-label process-file bye" >$@
aliases.fs: primitives.b prims2x.fs
$(FORTH) prims2x.fs -e "s\" primitives.b\" ' output-alias process-file bye" >$@
primitives.fs: primitives.b prims2x.fs
$(FORTH) prims2x.fs -e "s\" primitives.b\" ' output-forth process-file bye" >$@
gforth.texi: gforth.ds primitives.b ds2texi.fs prims2x.fs
$(FORTH) ds2texi.fs >$@
gforth.dvi: gforth.texi
tex gforth.texi
#GNU make default rules
#% :: RCS/%,v
# co $@
%.s : %.c $(INCLUDES)
$(CC) $(CFLAGS) -S $< -o $@
%.o : %.s
$(CC) $(CFLAGS) -c $< -o $@
......@@ -21,7 +21,8 @@
warnings off
[IFUNDEF] vocabulary include search-order.fs [THEN]
[IFUNDEF] vocabulary include search-order.fs [THEN]
[IFUNDEF] environment? include environ.fs [THEN]
include gray.fs
100 constant max-effect \ number of things on one side of a stack effect
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment