Nyanix

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | LICENSE

commit 05ad17d873d24586ef97f224a531d1ae18ef7205
parent 81102f3c913b7c0589e72c7421ba17c2d94ba438
Author: k4m1 <k4m1@proton.intra.silverskin.com>
Date:   Fri,  6 Jul 2018 13:40:47 +0300

Added comments & cleaned code

Diffstat:
src/boot.s | 28+++++++++++++++++++---------
1 file changed, 19 insertions(+), 9 deletions(-)

diff --git a/src/boot.s b/src/boot.s @@ -1,17 +1,20 @@ -;*** -; The entrypoint for bootloader. -;*** -bits 16 -align 4 -org 0x7c00 +; ============================================================================ ; +; The entrypoint for bootloader. ;; ============================================================================ ; + +bits 16 +align 4 +org 0x7c00 section .text -global _entry + +; Clearing out the Code-Segment, as some BIOSes start the bootloader +; by setting CS=0x7c00 instead of just jmp 0x0000:0x7c00 jmp 0x0000:_entry _entry: cld cli + ; back-uping boot device id & clearing registers mov [BOOT_DEVICE_DB], dl xor ax, ax xor bx, bx @@ -24,12 +27,17 @@ _entry: mov ss, ax mov es, ax mov fs, ax + ; stack starts at 0x7c00 mov sp, 0x7c00 +; ============================================================================ ; +; We'll load 2nd stage of bootloader with BIOS interrupts +; (int 13h, ah=2) + load_2nd_stage: sti mov bx, _start - mov dh, 2 + mov dh, 1 mov dl, [BOOT_DEVICE_DB] mov byte [BL_SECTORS], dh xor ch, ch @@ -60,16 +68,18 @@ load_2nd_stage: cli hlt .read_done: - jmp 0x0000:_start + jmp _start msg_loader_failed db "Failed to load bootloader.", 0x0A, 0x0D, 0 BOOT_DEVICE_DB db 0 BL_SECTORS db 0 +; Filling rest of the sector with null-bytes until signature. times 510-($-$$) db 0x00 db 0x55 db 0xAA +; Rest of the bootloader code comes here. %include "src/2nd_stage.s"