16bit kernel what compiler????

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
Patrick Lindenbergh

16bit kernel what compiler????

Post 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
Tim

Re: 16bit kernel what compiler????

Post 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.
Patrick Lindenbergh

Re: 16bit kernel what compiler????

Post 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?
Tim

Re: 16bit kernel what compiler????

Post 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/
Silenger

Re: 16bit kernel what compiler????

Post 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
Silenger

Re: 16bit kernel what compiler????

Post 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.
Silenger

Re: 16bit kernel what compiler????

Post 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;
Silenger

Re: 16bit kernel what compiler????

Post 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.
Patrick Lindenberg

Re: 16bit kernel what compiler????

Post 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!
Post Reply