Page 1 of 1

16bit kernel what compiler????

Posted: Sun Mar 03, 2002 9:31 pm
by Patrick Lindenbergh
Hi All,

i'm need a compiler wich outputs raw binary 16bit code for
realmode kernel, but i don't know how to make it in Turbo C 3.1.
Seems that the C preprocessor can not be overwritten....
Does anybody know how to do this? Can i even use Pascal?

Thanx in advance

Re: 16bit kernel what compiler????

Posted: Mon Mar 04, 2002 1:22 am
by Tim
You need a linker which outputs flat binary. TC can do this, by getting the linker to output a .COM file (IIRC you need to use the tiny memory model and give the linker the /t switch, but check up on that).

A drawback of using the tiny model with 16-bit code is that the compiler will output code that can access a maximum of 64KB (code, data and stack combined). If you're writing a real-mode OS, you might want to write your loader as a .COM program (which can be run off a boot floppy or even from the DOS command line) and get it to load the kernel which is in a special format.

Re: 16bit kernel what compiler????

Posted: Mon Mar 04, 2002 3:18 am
by Patrick Lindenbergh
Thanx for your help, but i know that...my problem is that the linker outputs a .com file with dos-system calls at the start
(C StartUpCode) but how can i default this?

Re: 16bit kernel what compiler????

Posted: Mon Mar 04, 2002 9:31 am
by Tim
You'll need to override the startup assembly code that your compiler uses.

For an example, see Chris Giese's BING boot loader:
http://www.execpc.com/~geezer/os/bing.zip

Web page:
http://www.execpc.com/~geezer/os/

Re: 16bit kernel what compiler????

Posted: Fri Mar 15, 2002 9:46 pm
by Silenger
You can use TP7 or other free Tp compiler. Use a asm boot code, that loads a exe with MZ at the begining. So you write special procedures or functions in Tp that don't use dos.
Like:

procedure WriteChr(Chr: Char);
begin
    asm
     MOV      Al, Chr
     PUSHA
     MOV      Ah, 0Eh
     INT      10h
     POPA
    end;
end;

You can test your progr

Re: 16bit kernel what compiler????

Posted: Fri Mar 15, 2002 9:48 pm
by Silenger
am in dos and boot it with your boot code.
So you have to write functions to get on the disk and harddisk.
You can still use functions in TP that not use dos.

Re: 16bit kernel what compiler????

Posted: Fri Mar 15, 2002 9:50 pm
by Silenger
Like this you can use the pascal string unit to write the str with the writechr procedure.

procedure WriteStr(Str: String);
var
  Pos: Integer;
  Chr: array[0..254] of Char;
begin
    StrPCopy(Chr, Str);

    for Pos := 0 to (Length(Str) - 1)  do
    begin
         WriteChr(Chr[Pos]);
    end;
end;

Re: 16bit kernel what compiler????

Posted: Fri Mar 15, 2002 9:53 pm
by Silenger
Go to http://membres.lycos.fr/placr/os/picodos.html.
You can remove the interupts when you write then in Tp.
So the the boot code is very small.

Re: 16bit kernel what compiler????

Posted: Tue Mar 19, 2002 3:28 am
by Patrick Lindenberg
Thank you for the help!

But i need more information about exe-files...didnt found on web :(

how works the relocation? how can i load exe-files under TP?

Thanx!