aboutsummaryrefslogtreecommitdiffstats
path: root/src/boot/boot.stage1.asm
diff options
context:
space:
mode:
authorkotorifan <kotorifan05@gmail.com>2026-01-31 15:22:00 +0100
committerkotorifan <kotorifan05@gmail.com>2026-02-04 09:01:10 +0100
commite5c28a46a731a79d02266aa690a90a8f809d0f70 (patch)
tree3dfc555f1ca98c97b3f48f035e897e3d0cca07ba /src/boot/boot.stage1.asm
parentdfe4a33865ef01c5068804f77da844cdebd87f00 (diff)
downloadkotori-os-e5c28a46a731a79d02266aa690a90a8f809d0f70.tar.gz
A20 enable code added
Diffstat (limited to 'src/boot/boot.stage1.asm')
-rw-r--r--src/boot/boot.stage1.asm64
1 files changed, 64 insertions, 0 deletions
diff --git a/src/boot/boot.stage1.asm b/src/boot/boot.stage1.asm
new file mode 100644
index 0000000..801860e
--- /dev/null
+++ b/src/boot/boot.stage1.asm
@@ -0,0 +1,64 @@
+ ;; boot.stage1.asm
+
+ %include "boot.common.asm"
+ %include "boot.stage1.print.asm"
+ [org 0x7c00]
+ [bits 16]
+
+ %define READ_SECTORS_NUM 64
+ %define BOOT_LOAD_ADDR 0x7c00
+ %define SECTOR_SIZE 512
+
+ global _start
+
+_start:
+ ;; Disable interrupts
+ cli
+
+ ;; Setup segment registers
+ xor ax, ax
+ mov ds, ax
+ mov es, ax
+ mov ss, ax
+
+ ;; Adjust Stack
+ mov sp, _start
+
+ clc
+
+ mov si, disk_addr_packet
+ mov ah, 0x42 ; BIOS extended read function
+ mov dl, 0x80 ; Drive number
+ int 0x13 ; BIOS disk services
+ jc _disk_read_err
+
+ mov si, disk_read_success_msg
+ call _print_string
+
+ jmp 0x0000:0x7e00
+
+_disk_read_err:
+ mov si, disk_read_err_msg
+ call _print_string
+
+ hlt
+ jmp _disk_read_err
+
+_end:
+ hlt
+ jmp _end
+
+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
+
+ ;; Padding and magic number
+ times 510 - ($ - $$) db 0
+ dw 0xaa55
+