Page 1 of 3

Tring to make an OS, need help.

Posted: Sat Jul 16, 2005 7:16 pm
by thoover
I am Tring to make an OS with its own File System, I need to learn how to make a boot code.

Here is a list of drivers I need:

Mouse
SoundBlaster 16
VGA 256 color 800X600

I am tring to make a nice command and visual OS, sort of like windows 95, 98SE.


I'm New and tring to make it with C (C-FREE 32-bit compiler)(MIRICLE C 16-bit compiler), BASIC (FIRST BASIC 16-bit compiler) (ASIC 16-bit compiler)

Re:Tring to make an OS, need help.

Posted: Sat Jul 16, 2005 9:42 pm
by srg_13
Hey

You will need to write the loader in assembly. You probably won't be able to use basic to do any of your kernel, either.

First, see the introduction section of this page from the FAQ, and this . Then you can look at this bootloader tut:"A hello world bootloader", and "Rolling your own boot loader" from the FAQ. Also see this.. It is a tutorial about making an OS, and it uses GRUB.

-Stephen

P.S. Wise words from the FAQ:
It will likely take you several years, starting from scratch, to get to the point where you actually do a Graphical User Interface (GUI).
.

Re:Tring to make an OS, need help.

Posted: Sun Jul 17, 2005 4:24 am
by Dex4u
You could also try "bootprog" has a loader, as it can load a mz EXE or COM file.
http://alexfru.chat.ru/epm.html#bootprog

Re:Tring to make an OS, need help.

Posted: Sun Jul 17, 2005 8:31 am
by Warrior
I'd actually suggest grabbing an intel doc and heading down to www.mega-tokyo.com/osfaq2 and osdever.net, it's good to have a lot of information on how things work especially if you plan to go into protected mode (looks like you do).

Good luck,
Nelson

Re:Tring to make an OS, need help.

Posted: Sun Jul 17, 2005 10:19 am
by thoover
I downloaded an assembly compiler I know the basic part of the code, but not how to make it boot the computer. What do I use a .bin, .boot, .exe or .com? If I want to not make an OS not in protected mode, what do I have to do? ??? :'(

Re:Tring to make an OS, need help.

Posted: Sun Jul 17, 2005 3:02 pm
by GLneo
the otput needs to be flat binary(.bin) then you got to swich to pmode:

Code: Select all

mov eax, cr0
or eax, 1
mov cr0, eax
(intel syntax)
then congragulation welcome to the world of pmode, as for loading your kernel use bios before pmode switch ;)

Re:Tring to make an OS, need help.

Posted: Sun Jul 17, 2005 3:49 pm
by thoover
:o My computer did not reconize mov Dose any one have an assembly compiler that works?

Re:Tring to make an OS, need help.

Posted: Sun Jul 17, 2005 4:44 pm
by Tora OS

Re:Tring to make an OS, need help.

Posted: Sun Jul 17, 2005 6:08 pm
by thoover
FASM was the only one that worked on my PC, I could not download the other.

Now I am still stuck on the boot loader for my OS, any ideas? :)

Re:Tring to make an OS, need help.

Posted: Sun Jul 17, 2005 6:57 pm
by GLneo
i think making your own boot sector is a bad place to start just use mine for now:

Code: Select all

;
;                                         AndrewOS boot sector
;                                           By Andrew Davis
;                        with LoadSectors func from tutorial by Matthew Blagden


[BITS 16]

  [ORG 0x7C00]

    jmp start

    OSID      db "AndrewOS"
    BytesPerSector   dw 0200h
    SectorsPersector   db 01h
    LeadingSectors   dw 0001h
    NumberOfFATs   db 02h
    RootEntryMax   dw 00E0h
    TotalSectors   dw 0B40h
    MediaType      db 0F0h
    SectorsPerFAT   dw 0009h
    SectorsPerTrack   dw 0012h
    NumberOfHeads   dw 0002h
    HiddenSectors   dd 00000000h
    TotalSectors2   dd 00000000h
    DriveNumber    db 00h
    Reserved      db 00h
    BootSignaure   db 29h
    VolumeID      dd 69696969h
    VolumeLabel    db "AndrewOS   "
    FATID      db "FAT12   "

    LoadSectors:
       push ax
       push bx
       push cx
       mov dl, 12h
       div dl
       inc ah
       mov cl, ah
       mov dh, al
       and dh, 01h
       shr al, 1
       mov ch, al
       mov dl, 00h
       Read:
      mov ah, 02h
      mov al, 01h
      int 13h
      jc Read
       pop cx
       pop bx
       pop ax
       add bx, 0200h
       inc ax
       loop LoadSectors
       ret

    start:
       cli
       mov  ax, 07C0h
       mov  ds, ax
       mov  es, ax
       mov  ax, 9000h
       mov  ss, ax
       mov  sp, 0FFFFh
       sti

    floppy_reset:
       mov ah, 0
       int 13h
       or ah, ah
       jnz floppy_reset

    kernel_load:
       mov ax, 0
       mov es, ax
       mov bx, 0x1000
       mov ax, 1
       mov cx, 50
       call LoadSectors


    gdt:
       cli
       xor ax, ax
       mov ds, ax
       lgdt [toc]
    pmode:
       mov eax, cr0
       or eax, 1
       mov cr0, eax
       jmp 08h:clean_up

[BITS 32]
    clean_up:
       mov ax, 10h
       mov ds, ax
       mov ss, ax
       mov esp, 090000h
    stop_floppy:
       mov dx,3F2h
       xor al,al
       out dx,al
    kernel:
       jmp 08h:01000h

    gdt_data:
       dd 0
       dd 0
       dw 0FFFFh
       dw 0
       db 0
       db 10011010b
       db 11001111b
       db 0
       dw 0FFFFh
       dw 0
       db 0
       db 10010010b
       db 11001111b
       db 0
    end_of_gdt:

    toc:
       dw end_of_gdt - gdt_data - 1
       dd gdt_data

    times 510-($-$$) db 0
    dw 0AA55h
(nasm syntax)


this gets you in to pmode and loads the first 50 sectors(your kernel) and runs them
p.s. if you want i can explain what that code does ;)

Re:Tring to make an OS, need help.

Posted: Mon Jul 18, 2005 3:39 am
by Solar
Well, a bootloader launching him into Protected Mode is of little help if he doesn't want to do Protected Mode...?!
If I want to not make an OS not in protected mode, what do I have to do?
Nothing - your computer starts in Real Mode, and unless you tell it to do so it won't switch to protected mode.

I'd strongly suggest checking out the OS-FAQ in general, and the BabyStep tutorial in special. Also check out the various FAQ links provided above, and give the "QuickLinks" sticky thread of this board a try, too.

Re:Tring to make an OS, need help.

Posted: Mon Jul 18, 2005 9:28 am
by GLneo
sorry heres real mode version :)

Code: Select all

[BITS 16]

  [ORG 0x7C00]

    jmp start

    LoadSectors:
       push ax
       push bx
       push cx
       mov dl, 12h
       div dl
       inc ah
       mov cl, ah
       mov dh, al
       and dh, 01h
       shr al, 1
       mov ch, al
       mov dl, 00h
       Read:
           mov ah, 02h
           mov al, 01h
           int 13h
           jc Read
       pop cx
       pop bx
       pop ax
       add bx, 0200h
       inc ax
       loop LoadSectors
       ret

    start:
       cli
       mov  ax, 07C0h
       mov  ds, ax
       mov  es, ax
       mov  ax, 9000h
       mov  ss, ax
       mov  sp, 0FFFFh
       sti

    floppy_reset:
       mov ah, 0
       int 13h
       or ah, ah
       jnz floppy_reset

    kernel_load:
       mov ax, 0
       mov es, ax
       mov bx, 0x1000
       mov ax, 1
       mov cx, 50
       call LoadSectors

    kernel:
       jmp 0:01000h

    times 510-($-$$) db 0
    dw 0AA55h


Re:Tring to make an OS, need help.

Posted: Mon Jul 18, 2005 10:20 am
by thoover
Can any one tell me how to draw pitzles on the screen in assembly? >:)

frogive my spelling I am in a little hurry.

Re:Tring to make an OS, need help.

Posted: Mon Jul 18, 2005 10:30 am
by thoover
What if I take out

[BITS 16]
[ORG 0x7C00]
and
[BITS 32]

The thing is my compiler dosn't allow it I am using fasm and masm. >:)

Re:Tring to make an OS, need help.

Posted: Mon Jul 18, 2005 11:21 am
by GLneo
[ORG 0x7C00], tells the asmbler were the code is in memory, this only works in nasm, for fasm use:

Code: Select all

org 7C00h
see how well that works, as for bits if you like real mode you need 16-bit code:

Code: Select all

use16