Make a real mode OS with C

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
User avatar
matias_beretta
Member
Member
Posts: 101
Joined: Mon Feb 26, 2007 3:39 pm

Make a real mode OS with C

Post by matias_beretta »

Well, i want to make a real mode os with C...

Questions
-----------

1. What compiler can i use ? Maybe Turbo C?
2. What parameteres must i use for compile it?
3. How can i boot it? Can i save it to a sector and then from assembler call it with int 13h and jump to it?

Lots of thanks
INF1n1t
Member
Member
Posts: 60
Joined: Fri Dec 22, 2006 5:32 pm
Location: Somewhere Down...

Post by INF1n1t »

I think you should do like all the other people do: create a boot code, put it on a floppy diskette and then play with it to load your os. If you want, you can enter protected mode from there, if you don't want - then you don't write code to enter pmode. So, you stay in real mode.
About the compiler and the parameters - I can't tell you nothing!
I think, I have problems with Bochs. The biggest one: Bochs hates me!
User avatar
matias_beretta
Member
Member
Posts: 101
Joined: Mon Feb 26, 2007 3:39 pm

thanks

Post by matias_beretta »

lots of tanks infinit... i will start "playing" a little...

anyone has more information about the compiler???
earlz
Member
Member
Posts: 1546
Joined: Thu Jul 07, 2005 11:00 pm
Contact:

Post by earlz »

Turbo C really is the only real mode C compiler out there now..
Though you will probably need TASM, and last time I checked they haven't made the old versions free

anyone heard of a GCC based 16bit C compiler that has been ported to windows?
User avatar
mystran
Member
Member
Posts: 670
Joined: Thu Mar 08, 2007 11:08 am

Post by mystran »

GCC can compile into "16-bits" theoretically.. you can put ".code16" in an inline asm block, and the result will get compiled as 16-bit, though it'll still use 32-bit registers so it'll get prefixed to 32-bit all the way, and it won't obviously understand anything about segments. But it theoretically "works" if you're happy with the small (or is it tiny?) memory model.

The reason that's the best there is for GCC, is that GCC is designed all the way to assume a flat memory model. AFAIK that's the limit of it's portability. As long as memory's flat, GCC can do, but as soon as it's not, you're better off writing another compiler.
The real problem with goto is not with the control transfer, but with environments. Properly tail-recursive closures get both right.
earlz
Member
Member
Posts: 1546
Joined: Thu Jul 07, 2005 11:00 pm
Contact:

Post by earlz »

I heard a Watcom compiler supports segmentation, though I haven't really looked into it, maybe it compiles to 16bit..
User avatar
Happy Egghead
Member
Member
Posts: 32
Joined: Thu Oct 19, 2006 5:25 am
Location: Adelaide, Australia
Contact:

Post by Happy Egghead »

Turbo C 2.00 was released into the Public Domain years ago by Borland. I downloaded it off their site once but they ditched it due to it being old.
It's now available from other sources such as http://www.programmersheaven.com/downlo ... nload.aspx.
The Borland download page links directly to here if you want a bit more info on getting it to work http://dn.codegear.com/article/20841.

Turbo C 2.00 takes bit of getting used to as some of the menus are non standard and the in-line assembler sucks. If you can find a copy of Turbo C++ 3 or even better Turbo C++ 4 (DOS version), it's a bit more 'standardised' and a lot more functional (386 assembler instructions, support for both 16 bit and 32 bit targets). Version 3 or 4 is not Public Domain though.

TASM is kind of hard to get hold of but MASM (Microsoft Assembler) isn't. Microsoft used to sell this for a packet then began bundling it with their Windows DDK's (which are free!). So you download the windows DDK for Win 95/98, find the wierdly named ml614.exe file and you have a free assembler. See this link for more details and other assemblers/linkers http://www.thefreecountry.com/compilers ... lers.shtml.

For old software packages - eBay is your friend! (And mostly legal too)
User avatar
Brynet-Inc
Member
Member
Posts: 2426
Joined: Tue Oct 17, 2006 9:29 pm
Libera.chat IRC: brynet
Location: Canada
Contact:

Post by Brynet-Inc »

There are other 16bit C compilers, Why does everyone forget Bruce C Compiler? bcc..

http://homepage.ntlworld.com/robert.debath/
Image
Twitter: @canadianbryan. Award by smcerm, I stole it. Original was larger.
Post Reply