Commit f1ac3e26 authored by pazsan's avatar pazsan

Changed magic, endianess and word size is now encoded.

Make gforth before redoing kernals (old images still work).
parent a5fb7ce1
......@@ -28,7 +28,7 @@ XCFLAGS = @CFLAGS@
XDEFINES = @DEFS@
SWITCHES = $(XCFLAGS) $(XDEFINES) #-DNDEBUG #turn off assertions
ENGINE_FLAGS = -fno-defer-pop -fcaller-saves
CFLAGS = @DEBUGFLAG@ -O4 -Wall $(SWITCHES) -DDEFAULTPATH=\"$(datadir)/gforth/$(VERSION):$(libdir)/gforth/$(VERSION):.\"
CFLAGS = @DEBUGFLAG@ -pipe -O4 -Wall $(SWITCHES) -DDEFAULTPATH=\"$(datadir)/gforth/$(VERSION):$(libdir)/gforth/$(VERSION):.\"
#John Wavrik should use -Xlinker -N to get a writable text (executable)
LDFLAGS = @DEBUGFLAG@ @LDFLAGS@ @GCCLDFLAGS@
......
\ CROSS.FS The Cross-Compiler 06oct92py
\ $Id: cross.fs,v 1.25 1995-07-06 15:57:25 pazsan Exp $
\ $Id: cross.fs,v 1.26 1995-07-25 15:28:04 pazsan Exp $
\ Idea and implementation: Bernd Paysan (py)
\ Copyright 1992-94 by the GNU Forth Development Group
......@@ -820,10 +820,14 @@ Cond: [ELSE] [ELSE] ;Cond
bigendian Constant bigendian
Create magic s" gforth00" here over allot swap move
[char] 1 bigendian + cell + magic 7 + c!
: save-cross ( "name" -- )
bl parse ." Saving to " 2dup type
w/o bin create-file throw >r
s" gforth00" r@ write-file throw \ write magic
magic 8 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
......
\ image dump 15nov94py
Create magic s" gforth00" here over allot swap move
'1 1 cells + 0 pad ! -1 pad c! pad @ 0< + magic 7 chars + c!
: dump-fi ( addr u -- ) w/o bin create-file throw >r
s" gforth00" r@ write-file throw
magic 8 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
\ relinfo here forthstart - 1- 8 cells / 1+ r@ write-file throw
r> close-file throw ;
: savesystem ( "name" -- ) name dump-fi ;
/*
$Id: main.c,v 1.24 1995-02-23 20:17:22 pazsan Exp $
$Id: main.c,v 1.25 1995-07-25 15:28:07 pazsan Exp $
Copyright 1993 by the ANSI figForth Development Group
*/
......@@ -43,6 +43,9 @@ char *progname;
/* image file format:
* preamble (is skipped off), size multiple of 8
* magig: "gforth00" (means format version 0.0)
* "gforth0x" means format 0.1,
* whereas x in 2 4 8 for big endian and 3 5 9 for little endian
* and x & -2 is the size of the cell in byte.
* 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)
......@@ -98,17 +101,45 @@ Cell *loader(FILE *imagefile)
int wholesize;
int imagesize; /* everything needed by the image */
static char* endsize[10]=
{
"no size information", "",
"16 bit big endian", "16 bit little endian",
"32 bit big endian", "32 bit little endian",
"n/n", "n/n",
"64 bit big endian", "64 bit little endian",
};
do
{
if(fread(magic,sizeof(Char),8,imagefile) < 8) {
fprintf(stderr,"This file doesn't seem to be a gforth image\n");
fprintf(stderr,"This image doesn't seem to be a gforth image.\n");
exit(1);
}
#ifdef DEBUG
printf("Magic found: %s\n",magic);
#endif
}
while(memcmp(magic,"gforth00",8));
while(memcmp(magic,"gforth0",7));
if(!(magic[7]=='0' || magic[7] == sizeof(Cell) +
#ifdef WORDS_BIGENDIAN
'0'
#else
'1'
#endif
))
{ fprintf(stderr,"This image is %s, whereas the machine is %s.\n",
endsize[magic[7]-'0'],
endsize[sizeof(Cell) +
#ifdef WORDS_BIGENDIAN
0
#else
1
#endif
]);
exit(-2);
};
fread(header,sizeof(Cell),3,imagefile);
if (dictsize==0)
......
......@@ -14,7 +14,8 @@ include cross.fs \ include cross-compiler
decimal
256 KB makekernal , 0 , 0 , 0 A, 0 A, 0 A,
cell 2 = [IF] 32 [ELSE] 256 [THEN] KB
makekernal , 0 , 0 , 0 A, 0 A, 0 A,
UNLOCK ghost - drop \ ghost must exist because - would be treated as number
LOCK
......
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