From mboxrd@z Thu Jan 1 00:00:00 1970 From: "jerryc@innerpeace.org" Subject: Re: using Turbo C compiler to generate ELKS executables Date: Thu, 06 Feb 2003 21:22:28 -0500 Sender: linux-8086-owner@vger.kernel.org Message-ID: <3E431864.9010006@innerpeace.org> References: <200302061328.27317.a.martone@retepnet.it> Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Return-path: List-Id: Content-Type: text/plain; charset="us-ascii"; format="flowed" To: linux-8086@vger.kernel.org Dear Alfonso, This is exciting. Before we discovered ELKS, we were looking at using FreeDOS and, from what we had heard, the Borland "Antique Software" seemed like the way to go. Now that you say we can use it with ELKS, that's exciting. While it would be ideal to use a free (as in speech) or open source compiler, I could live with using the Borland one to compile free and open source programs. Questions: Did you post your smallibc.lib somewhere for downloading? The program we're planning to make for 8086's will need to use some version of a curses or ncurses library (conio might work but is known to compile much slower in most cases). It's basically an expert system chatterbot that outputs text to the screen. It has no learning, it just echoes a combination of prewritten phrases combined with variables based upon user input. The most significant math functions it does are add and subtract integers totalling from 0 to 100. Other than that, it echoes text to the screen, takes in user input, and echoes back more text. Are you aware of what would be the best libraries for such a thing for ELKS, either with the Borland or other compilers, and which compiler would be best for such an application. Thanks for whatever help you can be on this important project. Yours in peace, Jerry P.S. Even though we're moving this project to ELKS, we still have the old link up, but the concept is the same: http://innerpeace.org/innerpeace3freedos Alfonso wrote: > I did it!! > > I found on Borland Intl. site (www.borland.com) that they placed > their historic Turbo C 2.01 in freeware, because "Antique Software". > > Well, one can use it also to develop programs for the ELKS platform. > I explain here just the basics. Go to my home site ELKS-dedicated > pages for technical stuff and download the full TCC4ELKS.ZIP source: > http://www.alfonsomartone.itb.it > > > (1) Borland...? > > In May 1989 Borland released the version 2.01 of Turbo C, surely > the most used C compiler in the DOS world in the "pioneer's era". > It could be used for creating DOS executables from "tiny" COM files > to "huge" EXE files. A rock-solid compiler with a nice text-based > IDE interface and a *good* debugging tool (you could step-into > functions without altering screen, look for variable values, etc). > > After years and years, that software (now released as freeware) > is still good. But, as I demonstrate here, you can use it also to > develop for 8086 (or 80186) environments. > > > (2) ELKS...? > > The only known C compiler suitable for ELKS was the bcc (Bruce > Evans C Compiler) and the Dev86 package. The bcc has (only) a > peep-hole optimizer, which output isn't as fast as the Turbo C > one. > > I think that it happens to be easier working on an already > optimized 8088-family compiler than creating a new one, which > would be almost pointless because today 8088-class and 80286-class > machines are "things for museums" (on *these* museum things ELKS > runs!!!). > > > (3) From DOS EXE format to ELKS. > > It's really easy (at least theoretically): ELKS executables have > a fixed header, then the code section, then the data section. > > For this release, to make things simple, I consider *only* the > "small" memory model executable (64k code + 64k data/bss/stack). > So, any 8088-class compiler producing a "small" memory model > executable can be used. > > Turbo C can generate a DOS executable file (.EXE) and a link map > text information file (.MAP): grabbing information from the EXE > header and MAP file, one can build an ELKS header and append > generated code and data segments. This work is done by the > exe2elks DOS utility program. > > > (4) Standard C libraries. > > Obviously you cannot use DOS-based Turbo C libraries (CS.LIB, etc) > to build ELKS programs, because in *many* points their routines > refer to DOS environment and startup code block (C0*.OBJ): DOS > interrupts (21h, 20h, etc), PSP structure, anarchic heap handling, > interrupt vectors (like division-by-zero), internal variables, etc. > > I think that a good part of the standard Turbo C libraries could > be used in almost any environment (e.g.: a "strcpy" function does > not require anything from the underlying operating system), but > one should examine and study the library source (or, harder, the > disassembled code) to select "good" routines one by one... > > So I had to develop a minimal library (smallibc.lib) for a number > of ELKS system calls (syscalls) of general use, and a small (very > small) set of general functions (strcpy, minimalistic printf, etc). > > > (5) It runs! > > I compiled some example programs (requiring very little library > functions) to show how it actually runs. The bcc generates for the > "cento.c" program a 5500+ bytes executable file, while the Turbo C > version (with register variables, a decent optimizer, etc) with the > minimalistic library, generates a 1540 bytes file (including about > 550 bytes for the only printf/sprintf functions). Start "cento" in > a (true or emulated) 8088-based ELKS environment and enjoy...! :-) > > I think that larger programs (the standard library, the ELKS kernel > itself, etc) could be compiled with Turbo C. There are a number of > Turbo C features that should be explored (for example, the > floating-point stuff - emulated or 8087-native; far pointers and > far calls; etc). The ELKS kernel may actually need a decently > optimized compiler, to save some few kilobytes of precious code > space. > > The nasty part of all: Turbo C expects only CR/LF terminated lines, > while bcc expects LF only. But the translation from DOS style to > Unix style can be done with a simple filter program. Also, Turbo C > has to be used in a DOS environment (maybe a DEXE file solution > could help). > > > (6) Get the Turbo C now! > > Please do not ask me for a copy of Turbo C: go download it from > Borland site (section Museum) site. Yes, they ask you for your > email address... I gave mine but they didn't ever send me any > advertisement. > > I'm not related in any manner with Borland: they just did a good > thing that only a few software companies do -- place in freeware > a great piece of their commercial software ("Antique"? it doesn't > care too much). Go download it from Borland site, and make them > know what a great thing is to release it in freeware! Maybe one > day they will release *also* source code of their old stuff, and > other famous compilers or newer versions of Turbo C and Turbo C++, > letting people using them and porting them to other operating > environments. > > > (7) Future... > > I do not plan to expand smallibc to a decent libc; I know there > are already efforts to port uClibc (www.uclibc.org) to ELKS and > do not want to duplicate work (I hope *already* to not to have > duplicate work from others). > > The package TCC4ELKS.ZIP is to be used in a DOS environment, > e.g.: MS/DOS 5.0 under DOSemu 1.0 (other combinations, real or > emulated DOS box, FreeDOS, etc, are untested but expected to > work). > > Maybe one could create a modified version of DOSELKS linux-86 > package program for use the Turbo C integrated debugger, and > develop and debug in a DOS box...! > > The license for using my work (this TCC4ELKS package) is GPL > (GNU General Public License) and won't change in future releases. > > > alf > > - > To unsubscribe from this list: send the line "unsubscribe linux-8086" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html >