Newsgroups: comp.sys.ibm.pc
Path: utzoo!utgpu!jarvis.csri.toronto.edu!godzilla.eecg.toronto.edu!noworol
From: noworol@eecg.toronto.edu (Mark Noworolski)
Subject: ROM code still continued
Message-ID: <89Jan4.141140est.2375@godzilla.eecg.toronto.edu>
Summary: Turbo C stupidity
Organization: EECG, University of Toronto
Distribution: na
Date: Wed, 4 Jan 89 14:11:29 EST

Well- for those of you who have been following my saga here's the next piece
For those of you who have helped me along- I'm forever grateful.

How to ROM code (absolutely ugly brute force method- works only for .com
files- sort of).

Final result: your program executes from the basica rom slot on bootup.

Instructions:
1. Make sure your rom bios jumps to the basic rom location (at f600 or so)
Some phoenix bios's just jump to a message 'Faulty boot disk'. You'll need
to get a technical hardware reference manual to do this- but it's pretty
easy (modify the vector table for int 18h- @ 1f13 in the rom).

2. Make sure your rom (when you plug it in) actually starts where you think
it does. ie. program it with something like 00 01 02 03 04 05 06 and then
do a search for these bytes in debug (f f000:0 l0 00 01 02 03 04 05 ...)

3. Write a little loader program (in assembly) to move everything after
it into low ram and then jump to that ram location (this is actually a
bit of a pain- you have to be very careful about where you ORG this code
when assembling it). Run this through exe2bin to get a binary (.com) file.
If you org this thing at f600 for example exe2bin wont COMify it- I then
loaded the exe file into debug and saved the appropriate length from the
approporiate starting location. Maybe there's an easier way to do this?

4. Compile your Turbo C program in tiny model.
The trick here is not to use ANY library functions (or floating point I
think- since fp is not supported in the tiny memory model (?)). Also
you need to link your program WITHOUT the nasty C start up code c0x.obj
since this seems to do a lot of stupid dos calls (and since you don't have
dos when this rom runs - usually- you don't want these). The way I do this
is to use the assembly output option and then assemble and link that using
an assembler (like MASM). Is there a cleaner way? There should be a way to
link in library functions and avoid the startup scum dos code- but I sure
haven't found it (anybody volunteer for this one?).

5. Merge your loader code with your .com file:
copy loader.bin+tccode.com romcode.bin

6. Program your ROM with the result.

Hope this helps some of you and once again thanks to all those who helped.

mark
-- 
There's a really fine line between stupid and clever.

	Nigel - Lead Guitar, Spinal Tap

noworol@ecf.toronto.edu

