28 lines
751 B
NASM
28 lines
751 B
NASM
|
[bits 16]
|
||
|
|
||
|
i_disk16_error_message: db "Disk read error!", 0
|
||
|
|
||
|
disk16_load:
|
||
|
push dx ; keep track of the # of sectors requested to be read
|
||
|
|
||
|
mov ah, 0x02 ; bios read sector
|
||
|
mov al, dh ; read dh # sectors
|
||
|
mov ch, 0x00 ; select cylinder 0
|
||
|
mov dh, 0x00 ; select head 0
|
||
|
mov cl, 0x02 ; start reading from 2nd sector
|
||
|
; (i.e. the sector after the boot sector)
|
||
|
|
||
|
int 0x13 ; bios interrupt to trigger read
|
||
|
|
||
|
jc disk16_on_error ; jump if carry (fault) flag was set
|
||
|
|
||
|
pop dx ; restore original # of registers in case it was modified
|
||
|
cmp dh, al ; compare # sectors read (al) to # sectors expected (dh)
|
||
|
jne disk16_on_error ; error if # sectors differs
|
||
|
ret
|
||
|
|
||
|
disk16_on_error:
|
||
|
mov bx, i_disk16_error_message
|
||
|
call print16
|
||
|
jmp g_infinite_loop
|