Skip to content

Commit

Permalink
Cleaned up not changed the save-system code for OSX.
Browse files Browse the repository at this point in the history
Added DEC. in index line. test.mak : typo. Using UNLOOP in LEAVE.
  • Loading branch information
albert committed Dec 21, 2016
1 parent 51be9db commit eff9918
Show file tree
Hide file tree
Showing 4 changed files with 80 additions and 32 deletions.
74 changes: 45 additions & 29 deletions blocks.frt
Original file line number Diff line number Diff line change
Expand Up @@ -1214,7 +1214,7 @@ $1B CONSTANT ESC



( H. B. DH. BASE? HEX: DEC: ) \ AvdH B6apr05
( H. B. DH. DEC. BASE? HEX: DEC: ) \ AvdH B6dec18
\ Switch to hex for the duration of the definition.
: HEX: R> BASE @ >R >R HEX CO R> BASE ! ;
: DEC: R> BASE @ >R >R DECIMAL CO R> BASE ! ;
Expand All @@ -1228,7 +1228,7 @@ $1B CONSTANT ESC
: DH. 4 CELLS (DH.) TYPE ; ( print DOUBLE in hex )
( print DOUBLE in decimal )
: DEC. 5 CELLS DEC: <# 1- 0 ?DO # I 3? LOOP # #> TYPE ;
: BASE? BASE @ B. ; ( 0/0 TRUE VALUE OF BASE)
: BASE? BASE @ B. ; ( print true value of base)

( HIDE INCLUDE IVAR ) \ AvdH B4Dec03

Expand Down Expand Up @@ -1671,13 +1671,13 @@ DECIMAL
SM 48 + CONSTANT G-SIZE \ Where to patch for GROW.
\ Return the VALUE of ``HERE'' when this forth started.
: HERE-AT-STARTUP 'DP >DFA @ +ORIGIN @ ;
: SAVE-SYSTEM \ Save the system in a file with NAME .
HERE BM - D-SIZE ! \ Fill in dict size (.text)
U0 @ 0 +ORIGIN 40 CELLS MOVE \ Save user variables
\ Now write it. Consume NAME here.
SM HERE OVER - 2SWAP PUT-FILE ; DECIMAL
: TURNKEY ( Save a system to do ACTION in a file witH NAME .)
ROT >DFA @ 'ABORT >DFA ! SAVE-SYSTEM BYE ; DECIMAL
\ Nothing to be done here.
: _prepare_header ;




DECIMAL
( SAVE-SYSTEM TURNKEY ) CF: ?LI ?64 HEX \ AvdH/CH B5jun24
\ The magic number marking the start of an ELF header
CREATE MAGIC 7F C, &E C, &L C, &F C,
Expand All @@ -1687,29 +1687,45 @@ DECIMAL
D-SIZE 8 + CONSTANT G-SIZE
\ Return the VALUE of ``HERE'' when this forth started.
: HERE-AT-STARTUP 'DP >DFA @ +ORIGIN @ ;
: SAVE-SYSTEM ( ISO ) HERE BM - D-SIZE ! ( dict size)
SM 28 + @ IF 0 SM 28 + ! 1 SM 38 + ! THEN ( Kill sections)
U0 @ 0 +ORIGIN 40 CELLS MOVE ( Save user variables)
\ Kill sections
: _prepare_header SM 28 + @ IF 0 SM 28 + ! 1 SM 38 + ! THEN ;





( SAVE-SYSTEM TURNKEY ) CF: ?OSX ?32 HEX \ RS/AH B6dec21
CREATE MAGIC FEEDFACE ,
: SM BM BEGIN DUP MAGIC 4 CORA WHILE 1- REPEAT ;
: __DATA SM BEGIN DUP "__DATA" CORA WHILE 1+ REPEAT ;
: __LINKEDIT SM BEGIN DUP "__LINKEDIT" CORA
WHILE 1+ REPEAT ;

: _prepare_header 20 10 DO 0 __LINKEDIT I + ! 4 +LOOP
48 38 DO 0 __LINKEDIT I + ! 4 +LOOP ;
\ Forget all segments past __DATA
: _prepare_header 3 SM 10 + ! ;
__DATA 1C + CONSTANT D-SIZE
__DATA 18 + CONSTANT __FILEOFFSET
SM __FILEOFFSET @ + CONSTANT BM

DECIMAL
( SAVE-SYSTEM TURNKEY ) CF: ?HS HEX \ AH B6dec21

\ ISO Save the system in a file with NAME .
: SAVE-SYSTEM _prepare_header
HERE BM - D-SIZE ! \ Fill in dict size (.text)
U0 @ 0 +ORIGIN 40 CELLS MOVE \ Save user variables)
\ Now write it. Consume NAME here.
SM HERE OVER - 2SWAP PUT-FILE ; DECIMAL
SM HERE OVER - 2SWAP PUT-FILE ;

\ Save a system to do ACTION in a file with NAME .
: TURNKEY ROT >DFA @ 'ABORT >DFA ! SAVE-SYSTEM BYE ;
( SAVE-SYSTEM TURNKEY ) CF: ?OSX ?32 HEX \ RS A8
CREATE MAGIC FEEDFACE , CREATE __DATA &_ C, &_ C, &D C, &A
C, &T C, &A C, CREATE __LINKEDIT &_ C, &_ C, &L C, &I C, &N
C, &K C, &E C, &D C, &I C, &T C, : HERE-AT-STARTUP'DP >DFA @
+ORIGIN @ ; : SM BM BEGIN DUP MAGIC 4 CORA WHILE 1- REPEAT ;
: FIND__DATA SM BEGIN DUP __DATA 6 CORA WHILE 1+ REPEAT ;
: FIND__LINKEDIT SM BEGIN DUP __LINKEDIT A CORA
WHILE 1+ REPEAT ; : KILL__LINKEDIT 20 10 DO 0 FIND__LINKEDIT
I + ! 4 +LOOP 48 38 DO 0 FIND__LINKEDIT I + ! 4 +LOOP ;
FIND__DATA 1C + CONSTANT __DATASIZE FIND__DATA 18 +
CONSTANT __FILEOFFSET
: SAVE-SYSTEM \ Save the system in a file
KILL__LINKEDIT HERE SM - __FILEOFFSET @ - __DATASIZE !
U0 @ 0 +ORIGIN 40 CELLS MOVE \ Save user variables
SM HERE OVER - 2SWAP PUT-FILE ; DECIMAL
: TURNKEY ROT >DFA @ 'ABORT >DFA ! SAVE-SYSTEM BYE ;




DECIMAL
( SAVE-SYSTEM TURNKEY ) CF: ?PC HEX \ AvdH A7feb28
\ Write an MSDOS ``EXEHEADER'' structure over the PSP.
VARIABLE HEAD-DP \ Fill in pointer
Expand Down
4 changes: 2 additions & 2 deletions ci86.gnr
Original file line number Diff line number Diff line change
Expand Up @@ -1216,7 +1216,7 @@ _C{ ############################################################################
_C{ FORTH ITSELF}
_C{ ########################################################################################}
_C
dnl fasm has no multiline comments, appropiate for an assembler.
dnl fasm has no multiline comments, which is appropiate for an assembler.
dnl So the following is suppressed from the assembler file.
_COMMENT
FORTH REGISTERS
Expand Down Expand Up @@ -2594,7 +2594,7 @@ forthcode({LOOP}) or forthcode({+LOOP}) .},{},
{ {: GS1 10 1 DO I 4 = IF LEAVE THEN I . LOOP ; GS1},{1 2 3} },
enddoc)
_HEADER({LEAVE},{LLEAV},{DOCOL}) _C{LIMIT <- INDEX}
DC RDROP, RDROP, RDROP
DC UNLOOP
DC SEMIS
_C
worddoc( {STACKS},{>R},{to_r},{n ---},{ISO,FIG,C},
Expand Down
32 changes: 32 additions & 0 deletions logforth.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14007,6 +14007,38 @@ The colors show off.
A cvs archive is backuped up in the Dropbox.
xina 5.1 has been made official and added to the hcc website.

2016 dec 17
Since nov some improved versions of xina have been put on the
website.
Thanks to Chris I've discovered that forth.lab was no good.
Moreover he reports this for grow:
dyld: malformed mach-o image: __LINKEDIT has fileoff==0
which overlaps mach_header
Abort trap: 6
This may be due to better checks.

2016 dec 19
Working with klis , checked out 5.2
Turns out that 5.2 32 bits doesn't work with fasm.
fasm cannot generate mach header. So the fasm version now
is adapted to ELF object:
FORMAT ELF
...
.text
...
.bss
It then must be converted to a macho object, then linked with the
command that Spykerman provided.
This doesn't pan out. So we are forced to stay with the nasm assembler.

I managed to get everything converted to git.
1. get the /usr/local/cvsroot of sparc into a tar archive.
2. untar in subdirectory of scratch, rename that to cvs
3. apt-get install cvs-git
4. run
git cvsimport -v -a -k -d `pwd`/cvs -C ciforth ciforth



-
Greg Egan
Expand Down
2 changes: 1 addition & 1 deletion test.mak
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ asgen.frt : RCS-as/asgen.frt,v ; co $<
asi386.frt : RCS-as/asi386.frt,v ; co $<

# A Forth with the analyser built-in.
lina-ana : lina32 asgen.frt asi386.frt #(ANASRC)
lina-ana : lina32 asgen.frt asi386.frt $(ANASRC)
echo '"analyser.frt" INCLUDED "SAVE-SYSTEM" WANTED "$@" SAVE-SYSTEM' |./lina32

# Test the optimiser. FIXME! Gives ERROR 22 ( --> not called from block).
Expand Down

0 comments on commit eff9918

Please sign in to comment.