rdos/kernel/drive.asm

54 lines
731 B
NASM
Raw Normal View History

2020-08-15 23:15:31 +02:00
section .bss
2020-10-13 22:10:23 +02:00
; drive actually selected for I/O
2020-10-11 23:33:01 +02:00
dsknum: resb 1
; current sector number
dskseek: resd 1
; disk buffer for I/O operations
2020-10-11 23:33:01 +02:00
dskbuf: resb 512
dpt: resb DPTSIZE
2020-08-15 23:15:31 +02:00
section .text
2020-10-11 23:33:01 +02:00
ret: ret
; Convert drive number into DL for int 13h
; IN dl dos drive number
; OUT dl bios drive number
getdl: cmp dl, 2
jc ret
mov dl, 0x80
ret
; select drive
; IN dl drive number
dsksel: cmp dl, byte [dsknum]
2020-10-11 23:33:01 +02:00
je ret
2020-10-11 23:33:01 +02:00
call dskrst
call getdl
mov ah, 8
les di, [0x1E*4]
int 0x13
; copy dpt
mov bx, di
mov dx, dpt
mov cx, DPTSIZE
call lod
ret
2020-10-11 23:33:01 +02:00
dskrst: call flush
mov ax, 0xFFFF
mov [dsknum], al
mov [dskseek], ax
mov [dskseek+2], ax
ret
2020-10-11 23:33:01 +02:00
; flush buffer if dirty
flush: ret