hi, i was wondering if anyone could fill me in on how to begin making an operating system? I have made one before but it was done using a template which basicly did everything for you, but now i want to start from scratch. Which language should i use? I know a a bit of C++, and C# but i doubt that my VB knowledge will mean anything. Do i need to learn assembly? if i do which program should i use to compile the assembly? but mainly i want to know where to begin!
This post has been edited by MelonSponge: 21 November 2009 - 03:12 PM
The OSDev Wiki sums it up to a good extent. You need significant background knowledge, toolset knowledge, and experience in problem solving and not needing hand holding.
Programming is never just about the code, and if you're still at the stage where all you can focus is on the code itself and not the behind the scenes design decisions and problem solving, it's far too early to think about developing operating systems.
I always suggest before starting an OS, make a boot loader, then you'll know if you are in it for the long haul. It's going to take much more than just a weekend w/ Pizza, as well as ideally more than just one coder.
You will need to know assembly yes. You will HAVE to program atleast your bootstrap in assembly.
** Removed **
To compile assembly code, NASM is a good compiler. Probs the best out there. Good luck and remember that os development doesnt yeild quick results, it may take an experienced programmer many years just to get to the point of a GUI
Aphex, If you wish to discussion the topic, you are welcome to do so here, but please do not ask to take the discussion off the forums. It doesn't help anyone else if you share information where no one can read it.
ive had a look around and downloaded BOCHS and NASM. The only thing is that i can find no info anywhere on actualy using NASM to compile my code. any help?
All the information on making bootloaders that ive found have been very vague, does anyone have any good links?
Here is a very simple bootloader that simply hangs and does nothing much.
[ORG 0x7C00] ; The BIOS loads the boot sector into memory location 0x7C00, so we offset to that point
jmp hang; Infinate loop
times 510-($-$$) db 0 ; Fill the rest of the file with zero's
Assuming you call the file, "boot.asm", you can compile that with
nasm boot.asm -f bin -o boot.bin
This will produce a 512 Byte binary file that you can boot from.
To use Boch, when it opens, select "Disk & Boot", then a 1.44 MB floppy from the combo box. Now navigate to your file "boot.bin" and select 1.44 MB again for "type of floppy media"
Now make sure you click on "inserted" check box and then run the emulation. It should just hang there...
If you want to print something to the screen, start by using the BIOS interupt 10, its pretty simple, osDev has lots of info on that.
Just one more thing, here is a slightly better example of a bootsector that usus the BIOS interupts (just real mode, not protected, important to remember) This program reads a key press and then echos it
[BITS 16] ; Tells the assembler that its a 16 bit code
readKey: ; Read key label
mov ah, 0 ; Sub function to read key from keyboard
int 16h ; Await key press
call printChar ; Print character just pressed (ascii value stored in al)
call readKey ; Loop
printChar: ; Procedure to print character on screen
mov ah, 0x0E ; Tell BIOS that we need to print one charater on screen.
mov bh, 0x00 ; Page no.
mov bl, 0x07 ; Text attribute 0x07 is lightgrey font on black background
int 10h ; Call video interrupt
ret ; Return to calling procedure
TIMES 510 - ($ - $$) db 0 ; Fill the rest of sector (512 Bytes) with 0
DW 0xAA55 ; Add boot signature at the end of bootloader
To add enviromental variables in XP, do the following. (for Vista or Windows 7, skip a few steps and just open the enviromental settings by seraching for it in control panel)
1: Open Control Panel
2: Click the System icon and the window pops up
3: Go to the Advanced pane
4: Click the Environment Variables button
5: In the bottom pan select "Path" and then click "Edit"
6: Now you need to append the path of nasm.exe to the end of the string you see.
For instance, mine is.
Make sure you include the semi colon to seperate the different variables for instance
Now your command line will search that directory when you type a command, so it should find "nasm" if that makes sense.
Command prompt shows "NASM is not recognised as an internal or external command, operable program or batch file"
this is what i have in the environment variables:
Variable name: NASM
Variable Value: C:\Program Files\NASM
i assume that the value is the folder where the NASM batch file is located. do i have to put the NASM.bat file on the end of the Variable value section? and is it definite that a ; must be placed before the file location?
We dont need to use batch files to compile this program, personally, I only use batch files for more complex builds, like if I have to input lots of commands that never change.
Ill try to explain this a little better. When you type in a command in the command prompt (just like inside a batch file) Windows will search your enviromental variables for a executable file with the name you typed. For instance, lets say you type in "test". Windows will then check to see if you have a program called "test.exe" or "test.com" (etc..) in your enviromental variables path.
If the program is found, Windows will then execute that program from the command line. If not then you will get the error "NASM is not recognised as an...etc"
the reason that programs are executed from the command line is because the programmer will make use of command line arguments (learn C and C++ to learn how to program these, infact, its a good idea to start learning now if you wanna program an os)
for instance, to invoke nasm to compile a file you will specifiy the executable "nasm" then you will specify an argument, like "-o" for example. The argument will tell nasm how to compile the file.
Just add the directory that the file nasm.exe is in to the enviromental variables, if its in your program files then you add that.