TCOMGEN.TXT Notes on this GENERIC TCOM compiler by: Tom Zimmer Date: 09/09/91 Welcome to the wonderful world of TCOM. Information and phylosophy TCOM stands for (T)arget (COM)piler. TCOM is a space and speed optimizing Forth (and now BASIC) compiler available for the 8086 family of processors. It is intended to make compiling of Forth source code into "small" standalone applications easy. TCOM for the 8086 creates ".COM" files. I am sometimes asked why TCOM doesn't create ".EXE" file. The reason is simple. TCOM was designed and is intended for making small things. If you want to make "BIG" things, then you should use the F-PC Forth system with all of its tools and large model architecture. While TCOM86 is wonderful for creating programs the the 8086 family, I also wanted TCOM to be used as a base for compilers for other processors. Mike Mayo developed the 80196 target, Andrew McKewen developed the 6805 target. Targets for several SAMSUNG processors (where I work) have been developed. Unfortunately a common thread through most of these targets is: The difficulty each designers had in figuring out how to interface their targets to TCOM. Thus I have developed this generic target to provide some illumination to this process. TCOM for any given target consists of several parts as listed below: 1. TCOM itself: COMPILE1.SEQ, COMPILE2.SEQ, HEAD2.SEQ, TCOMNDX.SEQ and HOST.SEQ 2. A target assembler. 3. A target optimizer or interface file. 4. A target library of functions. All of these pieces must be present for TCOM to function. In addition, TCOM provides a separate program to generate listing files from a set of symbol and index files that TCOM can build during a compile. If you are planning to generate listing files then you must also provide a disassembler to use with the listing generation program. Creating a NEW Target You can, and will probably want to, build your new target from one of the exsiting targets. This is desirable, and is in fact "THE WAY TO GO". BUT, you should probably begin by looking at this generic target to try to understand how TCOM works FIRST! The four parts of TCOM listed above begin with TCOM the compiler itself. While TCOM is the compiler, it does not itself actually do any compiling. TCOM itself is (intended to be) generic with respect to the processor and architecture of your target. The compiling is done by your target assembler and optimizer files. TCOM provides words that store and fetch from the targets address space, which your assembler and optimizer use, but the target must make decisions about what and how many bytes are placed into the target application for each instruction or function referenced. So, if TCOM doesn't really do any compiling, then what does it do? TCOM essentially handles: symbols, target memory references, and target defining words for each target. TCOM also allows you to build a library of target functions that will automatically be included in your target application when they are referenced. TCOM is in effect the DIRECTOR of the compile process, directing the assembler and optimizers to generate code from target applications requests and references. While this may not sound like much, it does simplify much of the work when building a new target. Building a new target for TCOM is essentially the process of "filling in the blanks" for a set of relatively simple optimizer (compiler interface) functions, writing an assembler for your target and writing the set of functions that make up the targets function library. The library can start small, and expand as your needs expand, but it will consist minimally of functions to handle literals in the target, and conditional branches. The optimizers are simply linkage routines that tell TCOM how to start and end the compiling of a colon definitions, and how to start up your target application (initialization routines). If you are writing a target for TCOM that is subroutine threaded, then you may want to write a disassembler to be linked into TCOM's listing program. The file LS86.SEQ and its associated files should provide some insite into the process of creating a new disassembler. Implementation of a TCOM target should begin on top of the full F-PC Forth system, so all of the F-PC debugging tools are available. It is useful to debug the word "TARG:" and trace through the compiling process when debugging your optimizer functions. I realize this is very minimal documentation to start on a new target, and IF YOU AREN'T A VERY EXPERIENCED FORTH PROGRAMMER, then you probably should just stop at this point and just use the provided compilers. I can only provide very minimal support to persons implementing targets, so you will not only have to do most of the work yourself, but you will have to figure out most of the questions and problems yourself as well. I hope at least a few people will be brave enough to try implementing new targets for TCOM, and those of you that are successful should contact me. I will definitely want to hear about your work, and I would like to distribute additional public domain targets as they become available. I can also provide additional targets to implementers as I receive them. As an implementer donating a target, you can receive free updates to TCOM and F-PC from me free on request. If you are thinking of starting a new TCOM target project, contact me first and I will try to get you together with others that may be working on the same target. Existing TCOM targets: 6805 subroutine threaded 8-bit (public domain) 8080 Indirect threaded (public domain) 8086 subroutine threaded (public domain) 8086 indirect threaded (public domain) 8086 BASIC compiler, subroutine threaded (public domain) 80196 subroutine threaded (public domain) SSP1600 SAMSUNG, digital signal processor, subroutine threaded (public domain) * 56000 SAMSUNG, subroutine threaded 8-bit (propriatary) * SAM8 SAMSUNG, subroutine threaded 8-bit (propriatary) SAM8 SAMSUNG, BASIC compiler, subroutine threaded (public domain) TCOMGEN genaric tutorial compiler (public domain) * These targets are currently only available from SAMSUNG, for use in developing application programs. These compilers also produce highly space optimized code. Targets I would LIKE to see done: 80C51, RTX2000, 68000