Path: utzoo!utgpu!utstat!jarvis.csri.toronto.edu!mailrus!ames!killer!dono From: dono@killer.Dallas.TX.US (Don OConnell) Newsgroups: comp.os.minix Subject: Re: Cross compiling under Turbo C Keywords: turboc->minix general rules Message-ID: <7632@killer.Dallas.TX.US> Date: 24 Mar 89 18:10:29 GMT Organization: The Unix(R) Connection, Dallas, Texas Lines: 111 This describes the general changes needed to compile MINIX under the Turbo C 1.5 compiler, with the Microsoft assembler. I have used TC15 and Masm to go from v1.1 to 1.4+, and haven't had many problems in compiling. An added advantage is 1/2 to 3/4 savings in compilation time. The executables tend to be smaller, also. 1. Make a complete copy of your current Minix system. 2. Create subdirectory's like these (dos side): turboc ---- Main TURBO C directory minix ---- Sources Main directory commands ---- Source directories commands\mined ---- commands\sh ---- fs ---- kernel ---- lib ---- mlib ---- mm ---- tools ---- 3. Boot Minix and use the doswrite program to copy the sources to DOS-formatted disks (NOTE * below). The compiler-specific modules are stored in subdirectories like MINIX, PCIX and C86; use the ones for the C86 compiler and modify them appropriately. After this, reboot under DOS and copy the files to your Minix-directory. * If you have cpio or a compatible tar and compress/uncompress/zcat that runs under Minix and Dos use it, it takes less disks to transfer files. * 4. You're now ready to build the Minix library; when Turbo C does long arithmetic, it uses a number of library routines that are unique to Turbo C and therefore not included in the Minix library. These modules will have to be retrieved from the CS.LIB that came with your Turbo C compiler. Using a librarian, extract the following modules from CS.LIB; ldiv.obj lrsh.obj lxmul.obj spush.obj scopy.obj Next step is compiling the files in the LIB-directory. * Use these files: prologue.h -- needed by .asm files getutil.asm, catchsig.asm, portio.asm, sendrec.asm, setjmp.asm These are executable headers: crtso.asm, head.asm -- See * below You won't need these files under TC: brksize.asm, end.asm -- incorporated into crtso/head csv.asm -- not used diskio.asm -- Turbo has functions to do this Using a librarian make the library. The order that I use for my v14a lib, along with most of the assembler needed files, have been previously posted * Head.obj and crtso.obj do not go in the lib. They are linked in from the command line. The head/crtso module, that I use are modified from the turbo c file - c0.asm. As a result of this, I compile in tiny model, but head/crtso are written in such a way, that split I/D programs are created automatically. * 5. Having created the library, you can proceed and compile FS, MM and the KERNEL by going to their respective directories and compiling the sources. The klib88.s and mpx88.s will have to be converted to masm syntax. 6. Next items are the files in the TOOLS directory; to write a boot-disk you'll need to compile DOS2OUT, BUILD, INIT and FSCK. FSCK1.s will have to be converted to masm syntax. Bootblok.s will also have to be converted to masm syntax. I use an ega monitor, and added code to mine to set the pallette colors(yellow on blue), and put the monitor in 43 line mode). * Dos2out and build are files that have to be compiled with the standard turbo c libraries and run as .exe files on the dos side. * ** To create a boot disk use a freshly formatted disk To create file-systems for Minix from DOS, you'll need MKFS; it's in the COMMANDS directory. Just copy it to the TOOLS dir and compile it. ** BEWARE: Any program containing setjmp() and longjmp() *MUST* be compiled with the -r- option (note: that's "-r-" !) as Turbo C doesn't store it's register variables into memory before a setjmp()/longjmp(). This is a documented "feature" of the standard Turbo C library version of setjmp() so you can use it to implement a kind of task-switches (co-routines). In the part of the book concerned with using DOS as a development system for Minix, AST mentions the routines csv and cret. So far, I have used Turbo C with stack-overflow testing OFF so I haven't needed them. In case you would like to do this sort of checking, all you have to do is write a replacement for the OVERFLOW@ routine that is called just after the routine is entered. You cannot use the Turbo C version since it does a direct DOS call if my information correct. You can however use that version as a basis for further development; best thing to do is to compile a short program with Stack Overflow Test ON and Map File ON and then use SYMDEB or something like that to peek at the code generated. Don O'Connell Mar. 23, 1988 killer!dono