54 lines
731 B
NASM
54 lines
731 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
|
|
|
|
dpt: resb DPTSIZE
|
|
|
|
section .text
|
|
|
|
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]
|
|
je ret
|
|
|
|
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
|
|
|
|
dskrst: call flush
|
|
mov ax, 0xFFFF
|
|
mov [dsknum], al
|
|
mov [dskseek], ax
|
|
mov [dskseek+2], ax
|
|
ret
|
|
|
|
; flush buffer if dirty
|
|
flush: ret
|