rdos/kernel/drive.asm

41 lines
518 B
NASM

section .bss
; drive actually selected for I/O
dsknum: resb 1
; current sector number
dskseek: resd 1
; disk buffer for I/O operations
dskbuf: resb 512
section .text
ret: ret
; select drive
; IN dl drive number
dsksel: cmp dl, 1
jnc ret
mov al, dl
and al, 0x02
ror dl, 1
ror dl, 1
cmp dl, byte [dsknum]
je ret
call dskrst
int 3
ret
dskrst: call flush
mov ax, 0xFFFF
mov [dsknum], al
mov [dskseek], ax
mov [dskseek+2], ax
ret
; flush buffer if dirty
flush: ret