51 lines
882 B
NASM
51 lines
882 B
NASM
|
%define drive_struct_len 0x0C
|
||
|
|
||
|
drive_table:
|
||
|
dw 0
|
||
|
.count:
|
||
|
dw 4
|
||
|
|
||
|
; Drive table
|
||
|
; 00 BYTE DL number
|
||
|
; 01 BYTE file system type
|
||
|
; 02 BYTE CHS heads (ignored if LBA)
|
||
|
; 03 BYTE CHS sectors per track (ignored if LBA)
|
||
|
; 04 DWORD total number of sectors
|
||
|
; 08 DWORD partition offset
|
||
|
|
||
|
; DI is incremented for the space taken
|
||
|
; IN ES:DI
|
||
|
drive_setup:
|
||
|
xor cx, cx
|
||
|
mov [drive_table], di
|
||
|
mov al, drive_struct_len
|
||
|
mov ah, BYTE [drive_table.count]
|
||
|
mul ah
|
||
|
xchg cx, ax
|
||
|
; this increments DI and also fills table with zeros
|
||
|
rep stosb
|
||
|
ret
|
||
|
|
||
|
; Load a drive table entry
|
||
|
; IN DL drive number
|
||
|
; OUT DS:SI ptr to table item
|
||
|
drive_load:
|
||
|
; bail out if number too high
|
||
|
cmp dl, [cs:drive_table.count]
|
||
|
jnc .err
|
||
|
|
||
|
push cs
|
||
|
pop ds
|
||
|
mov si, [drive_table]
|
||
|
|
||
|
push ax
|
||
|
mov al, drive_struct_len
|
||
|
mul dl
|
||
|
add si, ax
|
||
|
pop ax
|
||
|
|
||
|
ret
|
||
|
.err:
|
||
|
stc
|
||
|
ret
|