summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/boot.s57
1 files changed, 51 insertions, 6 deletions
diff --git a/src/boot.s b/src/boot.s
index 28da384..3e86770 100644
--- a/src/boot.s
+++ b/src/boot.s
@@ -1,15 +1,59 @@
- mov ax, 0x7c0
+ ; TODO: Check which MBR partition is bootable and it's type
+
+ cld ; clear the direction flag so that sto* and lod* increment di
+
+ ; Test for EDD
+ mov ah, 0x41
+ mov bx, 0x55AA ; boot signature word, why ?
+ mov dl, 0x80 ; drive index (HDD 1)
+ int 0x13
+ jc exit
+ cmp bx, 0xAA55
+ jne exit
+
+ ; Read sector 1
+ ; fill disk address packet (read 1 sector at offset 1)
+ mov ax, 0
+ mov es, ax
+ mov di, 0x200
+ mov ax, 16 ; size of packet
+ stosb
+ mov ax, 0 ; always 0
+ stosb
+ mov ax, 1 ; number of sectors
+ stosb
+ mov ax, 0 ; always 0
+ stosb
+ mov ax, 0x200 ; offset
+ stosw
+ mov ax, 0x7c0 ; segment
+ stosw
+ mov ax, 0x1 ; lower 4 bytes of LBA
+ stosd
+ mov ax, 0x0 ; upper 2 bytes of LBA
+ stosd
+ mov ax, 0
mov ds, ax
- mov ax, 0xb800 ; protected mode video memory segment (addr / 16)
- mov es, ax
- mov si, msg
+ mov si, 0x200
+ mov ah, 0x42
+ mov dl, 0x80 ; drive index (HDD 1)
+ int 0x13
+
+main_continuation:
- cld
+ mov ax, 0xb800 ; protected mode video memory segment (seg / 16 + off)
+ mov es, ax
+ mov ax, 0x7c0
+ mov ds, ax
+ mov si, 0x22b
+ ; mov si, msg
call print
cli
+ jmp hang
+
; print using BIOS functions
; print_loop:
; lodsb ; load byte from DS:SI into al
@@ -34,7 +78,6 @@ print:
mov dx, 160
mul dx
- xor di, di
mov di, bx
add di, ax
@@ -79,3 +122,5 @@ hang:
; db 'TEST'
; times 0x800000 - ($-$$) db 0
+
+exit: