Porting an 8088/MS-DOS FORTH to 386 Xenix 
Author Message
 Porting an 8088/MS-DOS FORTH to 386 Xenix

The recent discussion in comp.lang.forth covering things such as a
"minimal" FORTH definition, bootstrapping a FORTH, and assembly vs. C
implementations has been absolutely fascinating.  Today I felt inspired
to take another look at a few of the public domain FORTHs I own which came
with source code: FIG 8080, Laxen & Perry's F83, and Roedy Green's
BBL/Abundance -- the latter two are 8088 FORTHs for MS-DOS.  

How hard would it be to port an MS-DOS FORTH to 386 UNIX/Xenix?  F83 includes
an assembler and metacompiler; even though I don't know very much about
FORTH nuts and bolts I was able to make some small modifications to the
F83 source and metacompile a new kernel.

Obviously it would be nicer to have a 386, 32 bit FORTH, but for starters a
small model 8088 version would be okay; I'd think it would be possible to
"grow" F83 into a real 386/32 bit FORTH through successive metacompilations,
yes?  The DOS specific I/O code appears pretty well identified in the F83
implementation and that shouldn't be too difficult to change.

But what else would be necessary to produce an executable 386-XENIX binary?
Obviously F83 would have to be repackaged into the Xenix file format for
small model executables.  Quoting from the Xenix manual, "Files produced
from the [C] compiler/assembler always contain three segments, called _TEXT,
_DATA, and _BSS" -- would you expect there to be problems in getting F83
to conform to this file layout?   Although my questions are specifically
about porting a FORTH, the answers should be of wider interest -- would it
be really difficult to write a program (in any language) which converted
DOS programs into 386 UNIX executables?

Metacompiling a FORTH is one way to get to Xenix.  A less glamorous route
would be to work with a straight 8088 (80386 would be better) assembly
language distribution.  The Microsoft MASM assembler which comes with
Xenix is, I believe, quite compatible with the DOS MASM so if the
FORTH implementation was straightforward, the only remaining porting questions
would likely concern operating system calls for I/O.

I DO have complete 8088 MASM assembly source for BBL/Abundance, the other
FORTH source I mentioned.  However, BBL's architecture is kind of bizarre.
To quote the author:

| BBL is a direct threaded incremental Forth compliler.  High
| level code consists of 2 byte tokens.  The token consists of the
| 16-bit relative-addresses of the CFA's of the words.  All code
| words lie in the first 64k.  All high level definitions have a
| tiny piece of assembler code in low memory to get them started.
| Thus all CFAs are in the first 64K.  This scheme allows directly
| addressing a full megabyte with a quick simple inner interpreter.
| This inner interpreter takes 3 bytes and 23 cycles.
| This inner interpreter was chosen over about ten other
| possibilities.
| This interpreter is faster than segment tokens, mixed length
| tokens, full seg:offset tokens and indirect offset tokens to
| name a few.  It is even faster than using pure assembler FAR CALL/RET
| instructions to implement high level code.  In a way then, we can say
| the BBL Forth compiler generates code that is faster than the equivalent
| modular code written in assembler!  As well as being faster my method
| uses far less RAM -- 2-bytes per token verses a 5 byte far call.

The price paid for all that speed is that (under MS-DOS, at least) "all
addresses are ABSOLUTE addresses ...not CS: relative addresses".  So I'm
concerned that maybe BBL couldn't be easily ported?  Does FIG distribute
source for a good 8088 or 386 FORTH?

Do any FORTH or Xenix gurus care to participate in (or lead--I'm not proud)
such a FORTH porting project?  I think it would be great if a fairly robust,
public domain FORTH were available for 386 UNIX.  A FORTH which ran under
Xenix should also run under true System V.3 implementations such as
Interactive.  If the implementation ran fast and, especially, if it had
support for curses and possibly the standard C libraries it would provide
a nice alternative to C.
{pacbell!sactoh0! OR ucdavis!csusac!}tree!stever

{pacbell!sactoh0! OR ucdavis!csusac!}tree!stever

Mon, 19 Apr 1993 10:57:00 GMT  
 Porting an 8088/MS-DOS FORTH to 386 Xenix
Modify the metacompiler to produce assembly-language (.asm) output.

 'U`  --------------  +1 713 274 5180.
"*Real* wizards don't whine about how they paid their dues"

Mon, 19 Apr 1993 15:13:00 GMT  
 [ 2 post ] 

 Relevant Pages 

1. LMI Forth (was: porting an MS-DOS Forth to a 386 Unix/Xenix)

2. porting an MS-DOS Forth to a 386 Unix/Xenix

3. forth for sco xenix 386

4. Changing from DOS to XENIX and from XENIX to DOS

5. IBM370 emulator for 386 running MS-DOS

6. IBM370 emulator for 386 running MS-DOS

7. looking for a PL/I compiler for 386+ in MSDOS or NT-DOS

8. 386 MS-DOS port of SB-Prolog available for ftp

9. Need help in porting 8088/286 assembly code to 386.

10. prolog for SCO XENIX 386?

11. sbprolog for SCO XENIX 386

12. Anybody ported KCL to SCO XENIX 386?


Powered by phpBB® Forum Software