flat assembler
Message board for the users of flat assembler.

Index > OS Construction > About OS construction

Author
Thread Post new topic Reply to topic
fdxx



Joined: 26 May 2008
Posts: 4
fdxx 26 May 2008, 17:17
Hi, first sorry for my bad english, it is not my first language. I am starting getting into the world of the development of operative systems. My problem is the following one:
I have a BootLoader (boot.bin), and a Kernel (kernel.bin) The boot it I have in the sector 0 of a diskette, and it is executed without problems, but I do not manage to do start the Kernel.bin, which I must to do?

The Kernel this written in C and ASM, and then compiled to a file .BIN

THX Twisted Evil
Post 26 May 2008, 17:17
View user's profile Send private message MSN Messenger Reply with quote
nihilist:P



Joined: 26 May 2008
Posts: 7
nihilist:P 26 May 2008, 17:35
Does your bootsector load the contents of the next sectors into RAM?
Post 26 May 2008, 17:35
View user's profile Send private message Reply with quote
fdxx



Joined: 26 May 2008
Posts: 4
fdxx 26 May 2008, 17:44
Boot.asm

Code:
[BITS 16] 
[ORG 0x7C00]

main:
   mov ax,0x000
        mov ds,ax
   mov si, MSJ
 call PutStr
 jmp $

PutStr:

        mov ah,0x0E
 mov bh,0x00
 mov bl,0x07
 .nextchar
   lodsb

   or al,al
    jz .return
  int 0x10
    jmp .nextchar
       .return
     ret
 MSJ db 'bootloader',13,10,0

   times 510-($-$$) db 0
       dw 0xAA55    
Post 26 May 2008, 17:44
View user's profile Send private message MSN Messenger Reply with quote
nihilist:P



Joined: 26 May 2008
Posts: 7
nihilist:P 26 May 2008, 18:12
You have to copy your kernel.bin to sector 1 and then load it using BIOS Interrupt 13h. Searching this forum you will find many examples for that.

Quote:

Hi, first sorry for my bad english, it is not my first language.

Many people have that problem... Where are you from? (I am from germany)

PS: I am not really new but I forgot my password and lost the EMail-Adress Sad I hat to create a new account...feeling sorry for that, really
Post 26 May 2008, 18:12
View user's profile Send private message Reply with quote
fdxx



Joined: 26 May 2008
Posts: 4
fdxx 26 May 2008, 18:19
Thank you Very Happy


ps: I am from Argentine Razz
Post 26 May 2008, 18:19
View user's profile Send private message MSN Messenger Reply with quote
nihilist:P



Joined: 26 May 2008
Posts: 7
nihilist:P 26 May 2008, 19:10
This could help you:

Code:
 DriveInfo:
         .DriveNumber   db 0
         .Heads         dd 0;2
         .Cylinders     dd 0;335
         .SectPerTrack  dd 0;2
;**************************************************************************
        f_LBA_to_CHS:          ;In: ECX = Sector  Out: CH, CL, DH, DL
                push    eax
                push    ebx
                mov     eax, ecx
                xor     edx, edx
                div     [DriveInfo.SectPerTrack]
                mov     cl, dl                     ;Set the sector
                inc     cl
                xor     edx, edx
                div     [DriveInfo.Heads]
                mov     dh, dl                     ;Set the head
                mov     ch, al                     ;set the cyl
                ;shl     ah, 6
                ;or      ah, 11000000b
                ;and     cl, ah
                pop     ebx
                pop     eax
        ret
        ;**************************************************************************
        f_read_sector:
                push    ax
                push    bx
                push    cx
                push    dx
                call    f_LBA_to_CHS
                mov     ax, 201h  ;Service 2, Read 1 sector
                mov     dl, [DriveInfo.DriveNumber]
                int     13h
                pop     dx
                pop     cx
                pop     bx
                pop     ax
        ret
        ;**************************************************************************
        f_read_driveinfo:
                mov     dl, [DriveInfo.DriveNumber]
                mov     ah, 8h
                int     13h
                mov     byte [DriveInfo.Heads], dh
                inc     [DriveInfo.Heads]
                mov     byte [DriveInfo.Cylinders], ch
                inc     [DriveInfo.Cylinders]
                and     cl, 00111111b
                mov     byte [DriveInfo.SectPerTrack], cl
                ;don't inc, coz ind of sect starts with 1
        ret

    


3 functions I use for that purpose.
f_read_driveinfo does what the name says... should be called once at the beginning.
To read your 2nd sector just store 1 in ecx ant then call f_LBA_to_CHS first and then f_read_sector.

Code:
 call    f_read_driveinfo
        ;load next OS sectors 
    LoadLoaders:
        mov     ax, 50h
        mov     es, ax
        xor     bx, bx
        xor     ecx, ecx
      .readloop:
        call    f_read_sector
        add     bx, 200h
        inc     cx
        cmp     cx, WORD [moskrnlsectend]
        jb      LoadLoaders.readloop
    

note: moskrnlsectend is the end-sector (count-1) to load.
Post 26 May 2008, 19:10
View user's profile Send private message Reply with quote
edfed



Joined: 20 Feb 2006
Posts: 4333
Location: Now
edfed 26 May 2008, 19:37
this will help you very much

bootloader & bootwriter

shell.com and comwriter

for win9x & dos, execute comloader/bw05.com and shell/cw05.com

ask for Xw05.com or seek on the forum

Very Happy
Post 26 May 2008, 19:37
View user's profile Send private message Visit poster's website Reply with quote
fdxx



Joined: 26 May 2008
Posts: 4
fdxx 26 May 2008, 20:18
Thanks!, very useful
Post 26 May 2008, 20:18
View user's profile Send private message MSN Messenger Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.