Disk read error refactor

pull/13/head
E. Almqvist 3 years ago
parent 9260b7c6c6
commit 632566f6c3
  1. 13
      src/bios/disk.asm
  2. 18
      src/bootloader.asm

@ -1,4 +1,5 @@
disk_read: disk_read:
pusha
push dx ; store dx on stack so that we can compare later push dx ; store dx on stack so that we can compare later
mov ah, BIOS_DISK_READ ; specify function mov ah, BIOS_DISK_READ ; specify function
@ -17,6 +18,7 @@ disk_read:
cmp dh, al ; if dh != al then error cmp dh, al ; if dh != al then error
jne sector_error jne sector_error
popa
ret ret
sector_error: sector_error:
@ -24,13 +26,22 @@ sector_error:
call println call println
read_error: read_error:
; Inform the user
mov bx, read_error_string mov bx, read_error_string
call println call println
; Print the error
mov bx, error_code_string
call print
mov dh, ah mov dh, ah
call print_hex call print_hex
mov bx, [ASCII_END]
call println
jmp $ 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 sector_error_string: db "Invalid number of sectors read!", ASCII_END

@ -1,11 +1,25 @@
[org 0x7c00] ; bootsector [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 ; Print the welcome string
mov bx, welcome_string mov bx, welcome_string
call println 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 jmp $ ; inf loop
@ -14,7 +28,7 @@
; Data ; Data
welcome_string: db "e Operating-System (eOS)", ASCII_CARRIAGE_RETURN, ASCII_LINEBREAK, "Version 2021 0.0", ASCII_END 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 ; Bootsector
times 510-($-$$) db 0 times 510-($-$$) db 0

Loading…
Cancel
Save