|
|
@ -1,18 +1,39 @@ |
|
|
|
|
|
|
|
;disk_read: |
|
|
|
|
|
|
|
; push dx |
|
|
|
|
|
|
|
; mov ah, BIOS_DISK_READ |
|
|
|
|
|
|
|
; mov al, dh ; sector count |
|
|
|
|
|
|
|
; mov cl, 0x02 ; second sector (after bootsection) |
|
|
|
|
|
|
|
; |
|
|
|
|
|
|
|
; mov ch, 0x00 ; read from first cylinder |
|
|
|
|
|
|
|
; mov dh, 0x00 ; head |
|
|
|
|
|
|
|
; |
|
|
|
|
|
|
|
; ; data pointer: es:bx (standard) |
|
|
|
|
|
|
|
; int BIOS_DISK_INT ; do the interrupt |
|
|
|
|
|
|
|
; jc read_error ; if flag is set then jump to error |
|
|
|
|
|
|
|
; |
|
|
|
|
|
|
|
; pop dx |
|
|
|
|
|
|
|
; cmp al, dh |
|
|
|
|
|
|
|
; jne sector_error |
|
|
|
|
|
|
|
; |
|
|
|
|
|
|
|
; ret |
|
|
|
|
|
|
|
|
|
|
|
disk_read: |
|
|
|
disk_read: |
|
|
|
push dx |
|
|
|
push dx ; store dx on stack so that we can compare later |
|
|
|
mov ah, BIOS_DISK_READ |
|
|
|
|
|
|
|
mov al, dh ; sector count |
|
|
|
mov ah, BIOS_DISK_READ ; specify function |
|
|
|
mov cl, 0x02 |
|
|
|
|
|
|
|
|
|
|
|
mov al, dh ; read dh amount of sectors |
|
|
|
|
|
|
|
mov ch, 0x00 ; CYLINDER |
|
|
|
|
|
|
|
mov dh, 0x00 ; HEAD |
|
|
|
|
|
|
|
mov cl, 0x02 ; SECTOR |
|
|
|
|
|
|
|
|
|
|
|
mov ch, 0x00 ; read from first cylinder |
|
|
|
int BIOS_DISK_INT ; interrupt |
|
|
|
mov dh, 0x00 ; head |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
; data pointer: es:bx (standard) |
|
|
|
; Error checks |
|
|
|
int BIOS_DISK_INT ; do the interrupt |
|
|
|
jc read_error ; carry flag set -> error |
|
|
|
jc read_error ; if flag is set then jump to error |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pop dx |
|
|
|
pop dx |
|
|
|
cmp al, dh |
|
|
|
cmp dh, al ; if dh != al then error |
|
|
|
jne sector_error |
|
|
|
jne sector_error |
|
|
|
|
|
|
|
|
|
|
|
ret |
|
|
|
ret |
|
|
@ -31,5 +52,5 @@ read_error: |
|
|
|
disk_loop: |
|
|
|
disk_loop: |
|
|
|
jmp $ |
|
|
|
jmp $ |
|
|
|
|
|
|
|
|
|
|
|
read_error_string: db "Disk read error", ASCII_END |
|
|
|
read_error_string: db "Disk read error!", ASCII_END |
|
|
|
sector_error_string: db "Invalid number of sectors read", ASCII_END |
|
|
|
sector_error_string: db "Invalid number of sectors read!", ASCII_END |
|
|
|