diff --git a/src/bios/disk.asm b/src/bios/disk.asm index e717981..0f1b171 100644 --- a/src/bios/disk.asm +++ b/src/bios/disk.asm @@ -1,4 +1,5 @@ disk_read: + pusha push dx ; store dx on stack so that we can compare later mov ah, BIOS_DISK_READ ; specify function @@ -16,7 +17,8 @@ disk_read: pop dx cmp dh, al ; if dh != al then error jne sector_error - + + popa ret sector_error: @@ -24,13 +26,22 @@ sector_error: call println read_error: + ; Inform the user mov bx, read_error_string call println + ; Print the error + mov bx, error_code_string + call print + mov dh, ah call print_hex + mov bx, [ASCII_END] + call println + jmp $ -read_error_string: db "Disk read error!", ASCII_END +read_error_string: db ASCII_CARRIAGE_RETURN, ASCII_LINEBREAK, "ERROR! Disk read failed.", ASCII_END +error_code_string: db "Error code: ", ASCII_END sector_error_string: db "Invalid number of sectors read!", ASCII_END diff --git a/src/bootloader.asm b/src/bootloader.asm index c7d97b8..a1cab27 100644 --- a/src/bootloader.asm +++ b/src/bootloader.asm @@ -1,11 +1,25 @@ [org 0x7c00] ; bootsector + ; Save the boot drive index + mov [BOOT_DRIVE], dl + + ; Move the stack pointer somewhere safe + mov bp, 0x8000 ; move it to 0x8000 + mov sp, bp ; Print the welcome string mov bx, welcome_string call println - ; Read second sector + ; Read second sector (outside bootsector) + mov bx, 0x9000 ; LOAD LOCATION + mov dh, 3 ; SECTOR-COUNT + mov dl, [BOOT_DRIVE] ; DISK-INDEX + call disk_read + + ; Print out whatever bloated data that was read + mov dx, [0x9000] + call print_hex jmp $ ; inf loop @@ -14,7 +28,7 @@ ; Data welcome_string: db "e Operating-System (eOS)", ASCII_CARRIAGE_RETURN, ASCII_LINEBREAK, "Version 2021 0.0", ASCII_END -read_test_string: db "Read bytes: ", ASCII_END +BOOT_DRIVE: db 0 ; Bootsector times 510-($-$$) db 0