Page 1 of 1

Turbo C .bin compile

Posted: Sun Jan 20, 2002 12:00 am
by Venkatesh Prabu
I am using Turbo C (DOS), how can I Compile and Link my kernel
(kernel.c) into a binary file(.bin).

RE:Turbo C .bin compile

Posted: Sun Jan 20, 2002 12:00 am
by Chris Giese
>On 2002-01-20 12:36:18, Venkatesh Prabu wrote:
>I am using Turbo C (DOS), how can I Compile and Link my kernel
>(kernel.c) into a binary file(.bin).

Use /t option to TLINK and give the output file a
.BIN extension. I think that's all you need to do.

RE:Turbo C .bin compile

Posted: Mon Jan 21, 2002 12:00 am
by Venkatesh Prabu
I Compiled kernel.c using tcc then I used
Tlink /n option(/n - no std. libraries).
Tlink outputs a .exe file, I used exe2bin and
it outputs a .bin file. The offset address of the
variables I used in the program are pointing to
illegal addresses when I debuged the kernel.bin
file using DEBUG.EXE. So I compiled Kernel.c using
tcc -mt (tiny model) and then I used Tlink /t option it
gives an error message 'segment-reloctable items present'
(even though i compiled in tiny model).
I tried my whole night.
How can i solve this problem ?
I want to compile a .bin file which will clearly
execute when i loaded ?
It is possible to use Turbo C (dos) to write
an OS ?

RE:Turbo C .bin compile

Posted: Wed Jan 23, 2002 12:00 am
by Chris Giese
I don't know why TLINK won't work, but here are some ideas:

- Get the Free DOS source code to see how they do it: http://www.freedos.org

- Leave the kernel in .EXE format and use a bootloader such as: http://www.execpc.com/~geezer/osd/boot/los4d.zip
that knows how to do .EXE-style relocations.

- If you are using your own bootloader, add support for .EXE relocations. The code in LOS4D.ZIP that does this is about 60 lines (with comments) of asm code.

- Get a program called LOCATE:
http://www.electric-solutions.com/embed/808x/locate.zip
It will process the relocations in the .EXE file, changing it from relocatable .EXE to absolute .EXE