A poorly written OS for the x86 arch. (WIP)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
eOS/bootloader/bios/disk.asm

46 lines
862 B

4 years ago
disk_read:
push dx ; store dx on stack so that we can compare later
mov ah, BIOS_DISK_READ ; specify function
4 years ago
mov al, dh ; read dh amount of sectors
mov ch, 0x00 ; CYLINDER
mov dh, 0x00 ; HEAD
mov cl, 0x02 ; SECTOR
4 years ago
int BIOS_DISK_INT ; interrupt
; Error checks
jc read_error ; carry flag set -> error
4 years ago
4 years ago
pop dx
cmp dh, al ; if dh != al then error
4 years ago
jne sector_error
ret
4 years ago
sector_error:
mov bx, sector_error_string
call println
read_error:
; Inform the user
4 years ago
mov bx, read_error_string
4 years ago
call println
; Print the error
mov bx, error_code_string
call print
4 years ago
mov dh, ah
call print_hex
4 years ago
mov bx, [ASCII_END]
call println
4 years ago
jmp $
4 years ago
3 years ago
read_error_string: db ASCII_CARRIAGE_RETURN, ASCII_LINEBREAK, "Disk read failed.", ASCII_END
error_code_string: db "Error code: ", ASCII_END
sector_error_string: db "Invalid number of sectors read!", ASCII_END