How get hard drive info from BIOS?
Posted: Sun Mar 06, 2016 9:26 am
To write a partition table and format a hard drive I need to find the number of sectors info - hopefully BIOS has this info. Ralf Brown Int List says int 13h ah=15h returns # of sectors in cx:dx. I wrote code to access the info and it doesn't return a reasonable number (see code below). For a 320 GB internal hd on a laptop the value of cx:dx is 00000080h. RBIL is apparently wrong. How can I find the # of sectors? Also I need to determine how many hard drives and flash drives are attached at start up time. Also the number of sectors on a flash drive.
Thanks. Bill S.
Thanks. Bill S.
Code: Select all
;dsecs.asm nasm -f bin dsecs.asm -o dsecs.bin
bits 16
org 0x7C00 ; add 0x7C00 to label addresses
mov ax, 0 ; set up segments
mov ds, ax
mov es, ax
mov ss, ax ; setup stack
mov sp, 0x7C00 ; stack grows downwards from 0x7C00
mov ah,0x15
mov dl,0x80 ;bit 7 = hd
int 0x13 ;returns #sectors in cx:dx
push dx
mov dx,cx ;operate on cx as dx
xor cx,cx ;cx counts to 1
mov bx,i2xt ;point to table
getcxdx:
rol dx,4 ;put hi hex digit on r. side
and dl,0x0f ;get digit, put it in al
mov al,dl ;index into table
xlat ;table result in al
mov ah,0xe
int 0x10 ;write
rol dx,4 ;put next hex digit on r. side
and dl,0x0f
mov al,dl ;index into table
xlat ;table result in al
mov ah,0xe
int 0x10 ;write
rol dx,4 ;put next hex digit on r. side
and dl,0x0f ;get digit
mov al,dl ;index into table
xlat ;table result in al
mov ah,0xe
int 0x10 ;write
rol dl,4 ;put next hex digit on r. side
and dl,0x0f
mov al,dl ;index into table
xlat ;table result in al
mov ah,0xe
int 0x10 ;write
cmp cx,0
jne crlf
inc cx
pop dx
jmp getcxdx
crlf:
mov al,0xd ;go to left end
mov ah,0xe ;
int 0x10 ;write
mov al,0xa ;go to next line
mov ah,0xe ;
int 0x10 ;write
i2xt db '0123456789ABCDEF'