Sender: shinelight AT detroit DOT crosswinds DOT net Message-Id: <3.0.6.16.19990506021514.2c47eb0c@pop.detroit.crosswinds.net> X-Sender: detr_shinelight AT pop DOT detroit DOT crosswinds DOT net X-Mailer: QUALCOMM Windows Eudora Light Version 3.0.6 (16) Date: Thu, 06 May 1999 02:15:14 -0400 To: djgpp AT delorie DOT com From: "Thomas J. Hruska" Subject: Re: Writing an OS In-Reply-To: References: <199904260406 DOT AAA24563 AT delorie DOT com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Reply-To: djgpp AT delorie DOT com At 01:48 PM 4/27/99 -0400, you wrote: >Thomas Hruska said: > >> I also hate to burst your bubble, but you can't use the >> printf() statement in an OS unless you write your own low level version. > >Bah! If you are writing for an x86 system and have x86 code, why can't >you use it? Build it on another computer, or just write in assembly and >link in the stdlib, right? Then just jump to it...what's so hard about >that? Now if you're writing an OS for a totally *foreign* computer with >different instruction set, yes, you will be up a creek... Umm...you can't just link in a library. The stdlib does NOT work directly with the screen. Instead, it calls an MS-DOS interrupt (after switching out of PMode). This is why all text is buffered until a '\n' is encountered...switching in and out of PMode takes a lot of processor power. If you write an OS, the only text based calls you will be able to use are the BIOS calls. If you switch to PMode, you don't even have that (BIOS only sets up 16-bit interrupts). This means you will have to code your own 32-bit printf(). On top of this, you can't use DJGPP to enter PMode. You have to write a large portion of the OS in assembler (if you want a 32-bit PMode OS). DJGPP can only be used effectively once: 32-bit PMode has been entered (setting up the GDT, LDT, and IDT), interrupts set up to do various things (print text, switch screen modes, HD and disk drive controllers, etc.), and the kernel has been loaded into memory. DJGPP can only be used after these things have been accomplished. Even then, you have to strip ALL information from the files created in DJGPP to get the file down to just the actual code. >That's the yucky part... Everything about writing an OS is "yucky." People write OSes because they want a challenge...this is about as challenging as it gets. >I have taken a look at the FreeDOS source and started hacking a bit at >it, although I don't have much time to do so. The "Gaz" site looks >interesting...thanks for the links. Thomas J. Hruska -- shinelight AT detroit DOT crosswinds DOT net Shining Light Productions -- "Meeting the needs of fellow programmers" http://www.shininglightpro.com/