My Own OS

This is a discussion on My Own OS within the C++ Programming forums, part of the General Programming Boards category; i dont really remember the exact but it could be 2 million....

  1. #16
    Registered User
    Join Date
    Dec 2001
    Posts
    479
    i dont really remember the exact but it could be 2 million.

  2. #17
    xmdvp
    Guest
    ok

    I had to do that at school last year.

    First a little knowledge about the boot sequence on a PC:

    On power up the BIOS looks for the first executable bootable device (floppy bootsector for example) and loads its contents into memory at the address 0:7C00 (512 bytes will be put out there) and then simply 'jumps' the processor to 0:7C00 and executes that code.

    then, your code (at 0:7c00) is supposed to look for the rest of the code because 512 bytes is not enough for a whole OS :P

    this part is in general called stage1.

    that's where it starts getting interesting. the purpose of stage1 is to find stage2 on the floppy disk, load it in memory and then jump to it!

    stage2 is a little bigger that stage1 and it purpose is to load the kernel somewhere in memory (before the 1MB mark obviously), disable interrupts, enable the A20 gate (= access to the rest of the memory), setup the GDT and IDT registry which is used by the protected mode and then jump into protected mode.

    Then stage2 must move the kernel at the 1MB memory mark (just above the I/O area) an jump to it.

    The kernel can be written in flat C++, but you'll have to write printf yourself and access the video card yourself. Also, you might need to program the keyboard and make a fgets() function.

    because there will be no libraries available for you.

    still intersted in writing an OS ?

    Just for the record, I am not a newbie in assembly, neither in C, and neither in compiling and linking, and it still took me a whole month (fulltime) to debug that and make it work. The only reason why I did that is because we needed it at school to run some tests. Otherwise there is no way I would have done that.

    if you're still interested, drop me a line at xmdvp@hotmail.com and I'll email you some of the code and interesting links

  3. #18
    Registered User
    Join Date
    Jan 2003
    Posts
    88
    Originally posted by xmdvp
    ok

    I had to do that at school last year.

    First a little knowledge about the boot sequence on a PC:

    On power up the BIOS looks for the first executable bootable device (floppy bootsector for example) and loads its contents into memory at the address 0:7C00 (512 bytes will be put out there) and then simply 'jumps' the processor to 0:7C00 and executes that code.

    then, your code (at 0:7c00) is supposed to look for the rest of the code because 512 bytes is not enough for a whole OS :P

    this part is in general called stage1.

    that's where it starts getting interesting. the purpose of stage1 is to find stage2 on the floppy disk, load it in memory and then jump to it!

    stage2 is a little bigger that stage1 and it purpose is to load the kernel somewhere in memory (before the 1MB mark obviously), disable interrupts, enable the A20 gate (= access to the rest of the memory), setup the GDT and IDT registry which is used by the protected mode and then jump into protected mode.

    Then stage2 must move the kernel at the 1MB memory mark (just above the I/O area) an jump to it.

    The kernel can be written in flat C++, but you'll have to write printf yourself and access the video card yourself. Also, you might need to program the keyboard and make a fgets() function.

    because there will be no libraries available for you.

    still intersted in writing an OS ?

    i cannot imagine anything more exciting than what you described above (not that I dont understanf /have not heard it before)

  4. #19
    ! |-| /-\ +3 1337 Yawgmoth's Avatar
    Join Date
    Dec 2002
    Posts
    187
    Really, or are u being sarcastic?
    L33t sp3@k sux0rz (uZ it t@k3s 10 m1|\|ut3s 2 tr@nzl@te 1 \/\/0rd & th3n j00 h@\/3 2 g3t p@$t d@ m1zpelli|\|gz, @tr0(i0u$ gr@mm@r @|\|d 1n(0/\/\pr3#3|\|$1bl3 $l@|\|g. 1t p\/\/33nz j00!!

    Speling is my faverit sujekt

    I am a signature virus. Add me to your signature so that I may multiply.

  5. #20
    Registered User
    Join Date
    Sep 2002
    Posts
    1,640
    Originally posted by xmdvp

    still intersted in writing an OS ?
    I love it

  6. #21
    xmdvp
    Guest
    Originally posted by Travis Dane
    I love it
    it always makes me smile when I read this. People love doing things when the dirty job's been done before, or when they don't know what they are talking about.

    someone said: there's 10 kinds of people: those who understand binary and those who don't

    xmdvp

  7. #22
    Registered User
    Join Date
    Sep 2002
    Posts
    1,640
    Originally posted by xmdvp
    or when they don't know what they are talking about.
    I've read through your post and what i made up of it is that
    writing your own OS takers time and has to be done on a low
    level meaning you have to do everything yourself (like printf),
    And that's what i love.

  8. #23
    xmdvp
    Guest
    I agree that I had fun writing my own printf() and getc() function.

Page 2 of 2 FirstFirst 12
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Detecting if OS is Windows???
    By Ktulu in forum Windows Programming
    Replies: 2
    Last Post: 11-19-2006, 01:49 AM
  2. a simple OS
    By DavidP in forum A Brief History of Cprogramming.com
    Replies: 8
    Last Post: 06-06-2004, 10:47 PM
  3. Linux OS to Windows OS code
    By sw9830 in forum C Programming
    Replies: 2
    Last Post: 02-28-2003, 02:11 PM
  4. How do they compile code for an OS ?
    By Nutshell in forum A Brief History of Cprogramming.com
    Replies: 49
    Last Post: 03-27-2002, 11:16 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21