foo
[eightysix] / kern / src / boot.asm
index 5be618b..25486e6 100644 (file)
@@ -3,18 +3,19 @@
        bits 16
        section .bootsect
 
+extern _bootsect_start
 extern _kern_start_seg
 extern _kern_size
 
-boot_driveno   equ 7b00h
-num_read_tries equ 7b06h       ; 2 bytes
-sect_pending   equ 7b08h       ; 2 bytes
-sect_per_track equ 7b0ah       ; 2 bytes
-cur_head       equ 7b0ch       ; 2 bytes - current head
-start_sect     equ 7b0eh       ; 2 bytes - start sector in track
-destptr                equ 7b10h       ; 2 bytes - destination pointer
-num_heads      equ 7b12h       ; 2 bytes - number of heads
-cur_cyl                equ 7b14h       ; 2 bytes - current cylinder
+boot_driveno   equ 0500h
+num_read_tries equ 0506h       ; 2 bytes
+sect_pending   equ 0508h       ; 2 bytes
+sect_per_track equ 050ah       ; 2 bytes
+cur_head       equ 050ch       ; 2 bytes - current head
+start_sect     equ 050eh       ; 2 bytes - start sector in track
+destptr                equ 0510h       ; 2 bytes - destination pointer
+num_heads      equ 0512h       ; 2 bytes - number of heads
+cur_cyl                equ 0514h       ; 2 bytes - current cylinder
 
 %macro floppy_motor_off 0
        pushf
@@ -66,10 +67,17 @@ start:
        mov ds, ax
        mov es, ax
        mov ss, ax
+       mov [boot_driveno], dl  ; save boot drive number
+
+       ; relocate boot sector to 600h
+       mov si, 0x7c00
+       mov di, _bootsect_start
+       mov cx, 256
+       rep movsw
+
        jmp 00:.setcs
 .setcs:
-       mov sp, 0x7b00  ; temp stack below our vars
-       mov [boot_driveno], dl
+       mov sp, _bootsect_start ; temp stack below our relocated address
 
        ; query sectors per track
        mov ah, 8       ; get drive parameters call, dl already has the drive