PekuOS Master Boot Record

What Web We Where

;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
; Assembler: flat assembler 1.67.21 for linux
; Date     : 26th June 2007
; Last fix : 31th August 2007
; Program  : Master Boot Record (MBR) for PekuOS
; Version  : 1.02.00.0
;
; e-mail   : [email protected]
;
; Thanks who ever helped me out of this one!!
; (BTW.. you can still advice me on this.. or if you find BUG to FIX)
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
        format binary
        use16
;=======================================================
boot_program    equ 0x7C00         ;position for boot code
seg_read_kernel equ 0x07E0         ;segment to kernel read
;=======================================================
start_program:
        xor ax,ax
        mov ss,ax
        mov sp,boot_program
        push ss
        pop ds
        mov byte [ds:0x0FFFF],dl      ;booted drive number
;-------
        cld
;=============================
; TEST FOR 386+ (Sorry, my code, my style .. LOL!!)
;=============================
        pushf
        pop ax
        mov dx,ax
        xor ax,0x4000
        push ax
        popf
        pushf
        pop ax
        and ax,0x4000
        and dx,0x4000
        cmp ax,dx
        jnz Here1
        jmp $
;=============================
; Memory
;=============================
Here1:  xor eax,eax
        int 0x12                    ;base memory
        mov dword [ds:0x0FFFB],eax
    ;Now we cheat a bit (HMA.. [Fix that later])
        add dword [ds:0x0FFFB,0x0180
    ;May be we should use 0x0E820
    ;but this is more simple to use.
        xor eax,eax
        mov ax,0x0E801
        int 0x15
        add dword [ds:0x0FFFB],eax
        imul ebx,64
        add dword [ds:0x0FFFB],ebx
;=============================
; Kill the casette/floppy disk motor
;=============================
        mov dx,0x03F2
        xor eax,eax
        out dx,al
;=============================
; Message that we loading kernel to memory (at least trying.. lol!!!)
;=============================
        mov si,msg_001+boot_program
        call Print_Msg
;=============================
; Disk - Get Parametres
;=============================
        pusha
        mov dl,byte [ds:0x0FFFF]
        mov ah,0x08
        int 0x13
;--
        mov byte [ds:0x0F000],dl   ;Disk max dev
        mov byte [ds:0x0F001],dh   ;Disk max head num
;--
        mov al,cl
        and al,0x3F
        mov byte [ds:0x0F002],al   ;Disk max sectors
;--
        mov ah,cl
        mov al,ch
        shr ah,06
        mov word [ds:0x0F003],ax
        popa
;=============================
; DISK - RESET DISK SYSTEM
;=============================
Reset:  push ds
        xor eax,eax
        mov dl,byte [ds:0x0FFFF]
        int 0x13
        pop ds
        jc Reset
;=============================
; Load kernel from disk to memory
; BTW.. yep, I do know that load
; ONLY ONE sector.. 512 byte!!
;=============================
Here2:  mov ax,seg_read_kernel    ;Segment pointer .. es=0x07E0
        mov es,ax                 ;pointer is now ES:BX (0x07E0:0000)
        mov bx,0x0000
;---------
        mov dl,byte [ds:0x0FFFF]  ;Drive no
        mov dh,0x00               ;Head no
        mov cl,0x02               ;Sector no
        mov ch,0x00               ;Track no
;---------
        mov ax,0x0201
        int 0x13
        jc  Here2
;==============================
; Message to done loading kernel
;==============================
        mov si,msg_002+boot_program
        call Print_Msg
;==============================
; Jump to loaded Kernel
;==============================
fly_kernel:
        push word seg_read_kernel
        push word 0x0000
        retf
;&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
; Procedures what we might need here
;&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
Print_Msg:
        lodsb
        or al,al
        jz Here3
        push si
        mov ah,0x0E
        int 0x10
        pop si
        jmp Print_Msg
Here3:
        retn
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
; Data Segment (or sound like.. blaaah.. what eva)
; BTW. Binary mode do NOT have segments..
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
msg_001 db 'Loading...',0x00
msg_002 db 'done.',0x00
;=======================================================
times 0x1fe-$ db 0x00
        dw 0x0AA55                 ;boot signature
Hosted by www.Geocities.ws

1