If writing an OS you will need eventually to make it work without the usual support of debuggers, editors and drivers that you have under an existing OS. You will need to supply these things yourself. But, initially, you can carry out a significant part of the development under another operating system that you have available. This section will assist you to build up an environment that helps you develop your OS.
What language should I use?
You will need a programming language which allows manipulation of fixed-format in-memory data structures so it cannot be of too high level such as by allocating and freeing memory behind the scenes. It will also need to be able to generate code which does not rely on external libraries until you supply them. Many people use assembly language and C though the language used is not a major issue as long as it gives you control. Beware that a subsequent release of a compiler does not modify your data alignment without your knowledge.
Can I get by without using assembly language?
Some parts of the operating system will need to be written in assembly. Only using assembly can you get access to all CPU registers and features that are needed in an OS. Some compilers may provide inline assembly, but that may not always be sufficient. You will also need assembly knowledge if you are to write your own boot and loader code and for at least some levels of interrupt handling. Some compilers and boot loaders are mentioned below.
Do I have to develop on real hardware?
Fortunately, no. Rather than compiling your early OS on one machine and moving it to another for testing you can use an emulator on the same machine you use for development. An emulator can mimic - quite accurately - a real machine. When you are ready you can run your OS on real hardware.
The links below provide guidance on helpful development tools.
- NASM The Netwide Assembler
- Using the GNU Assembler
- Writing 16-bit code in GNU assembler
- NBASM. See FAQ2001 for an example. (The NBASM IDE)
- GCC normally installed on Linux systems
- DJGPP for DOS-based development
- Open Watcom
- Borland Turbo C
- BCC for development of 16-bit object code on Unix
- Smaller C
Alexei A. Frounze has made an SDK to help develop 16-bit portions of the OS (it can be a boot loader or some code to work with the BIOS in the virtual 8086 mode or it can even be an application, if a 16-bit application support is desired). Go to http://alexfru.narod.ru to get the SDK and info.
Linkers and loaders
Since your OS has its own requirements for the execution image you generally need to write the loader code yourself. See Linkers and Loaders - an online book by John Levine: http://www.iecc.com/linker
What IDEs can I use?
An IDE, or Intergrated Development Environment, is simply that, a tool that allows you to keep all of your project in a well kept environment, be able to compile and build your project with in that environment, and easily modify any part of your project. Any IDE that will allow you to do that is sufficient. See http://en.wikipedia.org/wiki/Comparison_of_integrated_development_environments.
What emulators can I use?
Any pre-made toolkits?
Any boot loaders?
Writing a bootloader is not compulsory. You can use a preexisting one but bear in mind that you will have to learn how it interfaces with your code and adapt your code to suit the bootloader's requirements.
- Multi-format-boot which can be used to boot from floppy, CD, or USB flash using either floppy or hard disk emulation.
- Fatbootsect is floppy only but will allow you to use a standard FAT-formatted floppy.