aboutsummaryrefslogtreecommitdiffstats
path: root/src/boot/boot.stage1.asm
diff options
context:
space:
mode:
Diffstat (limited to 'src/boot/boot.stage1.asm')
-rw-r--r--src/boot/boot.stage1.asm50
1 files changed, 34 insertions, 16 deletions
diff --git a/src/boot/boot.stage1.asm b/src/boot/boot.stage1.asm
index 801860e..5fa3b7a 100644
--- a/src/boot/boot.stage1.asm
+++ b/src/boot/boot.stage1.asm
@@ -1,11 +1,11 @@
;; boot.stage1.asm
- %include "boot.common.asm"
- %include "boot.stage1.print.asm"
[org 0x7c00]
[bits 16]
- %define READ_SECTORS_NUM 64
+ %include "boot.common.asm"
+
+ %define READ_SECTORS_NUM 1
%define BOOT_LOAD_ADDR 0x7c00
%define SECTOR_SIZE 512
@@ -26,9 +26,10 @@ _start:
clc
+ mov [drive], dl
mov si, disk_addr_packet
mov ah, 0x42 ; BIOS extended read function
- mov dl, 0x80 ; Drive number
+ mov dl, [drive] ; Drive number
int 0x13 ; BIOS disk services
jc _disk_read_err
@@ -44,21 +45,38 @@ _disk_read_err:
hlt
jmp _disk_read_err
+_print_string:
+ pusha
+ mov ah, 0x0e
+ mov bh, 0x00
+
+.print_loop:
+ lodsb
+ test al, al
+ je .print_return
+ int 0x10
+ jmp .print_loop
+
+.print_return:
+ popa
+ ret
+
_end:
- hlt
- jmp _end
+ hlt
+ jmp _end
+drive: db 0
disk_read_err_msg: db "Failed to read disk", 13, 10, 0
disk_read_success_msg: db "Read the disk successfully", 13, 10, 0
disk_addr_packet:
- db 0x10
- db 0x00
- dw READ_SECTORS_NUM
- dw 0x0000
- dw 0x7e00
- dq 1
+ db 0x10
+ db 0x00
+ dw READ_SECTORS_NUM
+ dw 0x7e00
+ dw 0x0000
+ dq 1
- ;; Padding and magic number
- times 510 - ($ - $$) db 0
- dw 0xaa55
-
+ ;; Padding and magic number
+ times 510 - ($ - $$) db 0
+ dw 0xaa55
+