aboutsummaryrefslogtreecommitdiffstats
path: root/src/boot/boot.stage1.asm
diff options
context:
space:
mode:
authorkotorifan <kotorifan05@gmail.com>2026-01-31 17:13:17 +0100
committerkotorifan <kotorifan05@gmail.com>2026-02-04 09:01:10 +0100
commit35f3e16135b371e11d540a8b6bd5395cb40b2c96 (patch)
tree60b8a3361b71bfd47f32d402ceeba5be351f8336 /src/boot/boot.stage1.asm
parente5c28a46a731a79d02266aa690a90a8f809d0f70 (diff)
downloadkotori-os-35f3e16135b371e11d540a8b6bd5395cb40b2c96.tar.gz
Whatever...
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
+