Making an operating system

  • (4 Pages)
  • +
  • 1
  • 2
  • 3
  • Last »

54 Replies - 6559 Views - Last Post: 01 January 2010 - 01:54 AM Rate Topic: ***** 2 Votes

#1 MelonSponge  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 35
  • Joined: 11-November 09

Making an operating system

Posted 21 November 2009 - 02:39 PM

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!
thanks
MelonSponge :bananaman:

This post has been edited by MelonSponge: 21 November 2009 - 03:12 PM


Is This A Good Question/Topic? 0
  • +

Replies To: Making an operating system

#2 BetaWar  Icon User is offline

  • #include "soul.h"
  • member icon

Reputation: 1148
  • View blog
  • Posts: 7,145
  • Joined: 07-September 06

Re: Making an operating system

Posted 21 November 2009 - 03:12 PM

Making an Operating System is no easy task. I know.

The best way to go is a combination of ASM, C, and C++.

Here is a thread that covers my attempt:
http://www.dreaminco...topic107438.htm

If you read through its links, and the links on those you will get quite a bit of knowledge about what needs to be done.
Was This Post Helpful? 0
  • +
  • -

#3 Oler1s  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 1395
  • View blog
  • Posts: 3,884
  • Joined: 04-June 09

Re: Making an operating system

Posted 21 November 2009 - 03:43 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.
Was This Post Helpful? 0
  • +
  • -

#4 no2pencil  Icon User is online

  • Toubabo Koomi
  • member icon

Reputation: 5306
  • View blog
  • Posts: 27,200
  • Joined: 10-May 07

Re: Making an operating system

Posted 21 November 2009 - 04:00 PM

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.
Was This Post Helpful? 0
  • +
  • -

#5 Aphex19  Icon User is offline

  • Born again Pastafarian.
  • member icon

Reputation: 615
  • View blog
  • Posts: 1,873
  • Joined: 02-August 09

Re: Making an operating system

Posted 21 November 2009 - 04:03 PM

Im just beginning os dev, the wiki os dev will help you.

http://wiki.osdev.org/Main_Page

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
Was This Post Helpful? 1
  • +
  • -

#6 no2pencil  Icon User is online

  • Toubabo Koomi
  • member icon

Reputation: 5306
  • View blog
  • Posts: 27,200
  • Joined: 10-May 07

Re: Making an operating system

Posted 21 November 2009 - 04:09 PM

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.
Was This Post Helpful? 0
  • +
  • -

#7 MelonSponge  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 35
  • Joined: 11-November 09

Re: Making an operating system

Posted 23 November 2009 - 10:53 AM

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?
thanks
MelonSponge :bananaman:
Was This Post Helpful? 0
  • +
  • -

#8 Aphex19  Icon User is offline

  • Born again Pastafarian.
  • member icon

Reputation: 615
  • View blog
  • Posts: 1,873
  • Joined: 02-August 09

Re: Making an operating system

Posted 23 November 2009 - 12:25 PM

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

hang:
	jmp hang; Infinate loop
 
	times 510-($-$$) db 0 	; Fill the rest of the file with zero's
	dw 0x55AA


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.
Was This Post Helpful? 0
  • +
  • -

#9 Aphex19  Icon User is offline

  • Born again Pastafarian.
  • member icon

Reputation: 615
  • View blog
  • Posts: 1,873
  • Joined: 02-August 09

Re: Making an operating system

Posted 23 November 2009 - 12:31 PM

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
[ORG 0x7C00]						
	
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
	ret

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



I hope this helps
Was This Post Helpful? 0
  • +
  • -

#10 MelonSponge  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 35
  • Joined: 11-November 09

Re: Making an operating system

Posted 23 November 2009 - 12:36 PM

whenever i try to compile the code i get this error:
nasm: fatal: unable to open input file "boot.asm"
Am i supposed to be typing "nasm boot.asm -f bin -o boot.bin" into the NASM batch file?
Was This Post Helpful? 0
  • +
  • -

#11 Aphex19  Icon User is offline

  • Born again Pastafarian.
  • member icon

Reputation: 615
  • View blog
  • Posts: 1,873
  • Joined: 02-August 09

Re: Making an operating system

Posted 23 November 2009 - 12:41 PM

Assuming that you have added NASM to your enviromental variables, first, open a command prompt and navigate to where boot.asm is. Then simply type that command

nasm boot.asm -f bin -o boot.bin

You can navigate around directories using the cd (change directory) command. There are various others too
Was This Post Helpful? 0
  • +
  • -

#12 MelonSponge  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 35
  • Joined: 11-November 09

Re: Making an operating system

Posted 23 November 2009 - 12:50 PM

when adding nasm as a variable, what should its value be?
Was This Post Helpful? 0
  • +
  • -

#13 Aphex19  Icon User is offline

  • Born again Pastafarian.
  • member icon

Reputation: 615
  • View blog
  • Posts: 1,873
  • Joined: 02-August 09

Re: Making an operating system

Posted 23 November 2009 - 12:59 PM

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.

C:\NASM

Make sure you include the semi colon to seperate the different variables for instance

;C:\NASM

Now your command line will search that directory when you type a command, so it should find "nasm" if that makes sense.
Was This Post Helpful? 0
  • +
  • -

#14 MelonSponge  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 35
  • Joined: 11-November 09

Re: Making an operating system

Posted 23 November 2009 - 01:36 PM

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?
thanks! :)
MelonSponge :bananaman:
Was This Post Helpful? 0
  • +
  • -

#15 Aphex19  Icon User is offline

  • Born again Pastafarian.
  • member icon

Reputation: 615
  • View blog
  • Posts: 1,873
  • Joined: 02-August 09

Re: Making an operating system

Posted 23 November 2009 - 02:05 PM

Sorry for this long winded message :blink:

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.

I hope this clears things up
Was This Post Helpful? 0
  • +
  • -

  • (4 Pages)
  • +
  • 1
  • 2
  • 3
  • Last »