Page 1 of 1

detecting drives in real mode + lidt

Posted: Sat Apr 28, 2007 7:42 pm
by anon19287473
how can i detect drives in real mode? I tried attempting to read from all the drive numbers, w/o actually reading any memory, and reporting whether or not there was an error, but that didnt yield resutls. Any ideas?

How does load an idt in real mode? do you just use lidt and it is immediately active? Do i load it, then enter PM then go back to RM? what do i use as the offest in the table entires (idt)?

Posted: Sun Apr 29, 2007 2:31 am
by inflater
how can i detect drives in real mode? I tried attempting to read from all the drive numbers
Well, you can use INT 13h with AH=08h and AH=15h.

AH=08h:

required to fill:
AH=08h
DL=drive number (00-first FDD,01-second FDD,80h:first HDD,81h:second HDD)
INT 13h
you'll get:
CF=1 on error (maybe...)
CH=the maximal number of cylinders of the drive DECREMENTED by 1
CL=the maximal number of sectors (per track?)
DH=number of heads (surfaces)
DL=the number of devices connected to the controller

Beware that this function may return curious results, if you for example, have one harddisk in your PC and you are getting info for second HDD..

AH=15h:

required to fill:
AH=15h
DL=drive number
INT 13h
you'll get:
AH=status:
00 - drive in DL does not exist
01 - diskette without indication of removability (?)
02 - diskette (or any removable media) with indication of removability (?)
03 - hard disk
CX:DX= if AH is nonzero, then it is the total number of sectors in medium
How does load an idt in real mode? do you just use lidt and it is immediately active?
Should be...

inflater

Posted: Sun Apr 29, 2007 8:56 am
by anon19287473
Thanks a bunch! :) :D

Posted: Mon Apr 30, 2007 4:53 pm
by mathematician
You don't need the LIDT instruction in real mode, because the interrupt vector table always occupies the first 1kb of memory.