Mike Chambers
Veteran Member
- Joined
- Sep 2, 2006
- Messages
- 2,621
alright, so i'm trying to write a hard drive imager that works over FTP. i tried this before but i was having problems, and lost interest.
right now i'm having problems using the 08h call to interrupt 13h. fdisk clearly shows that the drive in my XT clone has 781 cylinders, but for some reason the code i wrote to get the params returns 557 cyls, 4 heads, and 48 SPT. (totalling 54,755,328 bytes which is way off, the drive's true capacity is half of that.)
here is my code for that part: (cal is the call registers, and of course ret is the return registers.
i know i huge improvements could be made to my math-related code there, but as far as i can see this should still get the numbers properly based on what i've read about the call.
any ideas?
thanks!
right now i'm having problems using the 08h call to interrupt 13h. fdisk clearly shows that the drive in my XT clone has 781 cylinders, but for some reason the code i wrote to get the params returns 557 cyls, 4 heads, and 48 SPT. (totalling 54,755,328 bytes which is way off, the drive's true capacity is half of that.)
here is my code for that part: (cal is the call registers, and of course ret is the return registers.
Code:
drv = &H80
PRINT "Resetting drive on primary master..."
cal.ax = 0
cal.dx = dev
CALL interruptx(&H13, cal, ret)
PRINT "Reading drive parameters of primary master..."
'get drive parameters
cal.ax = &H800
cal.dx = drv
CALL interruptx(&H13, cal, ret)
split$ = RIGHT$("0000" + HEX$(ret.dx), 4)
numhdd = VAL("&H" + RIGHT$(split$, 2))
heads = VAL("&H" + LEFT$(split$, 2))
decby = 16384
DO
IF ret.cx - decby >= 0 THEN
tb$ = "1" + tb$
ret.cx = ret.cx - decby
ELSE
tb$ = "0" + tb$
END IF
decby = decby / 2
LOOP UNTIL decby < 1
cyls = 0
addby = 512
FOR n = 1 TO 10
IF MID$(tb$, n, 1) = "1" THEN cyls = cyls + addby
addby = addby / 2
NEXT n
spt = 0
addby = 32
FOR n = 11 TO 16
IF MID$(tb$, n, 1) = "1" THEN spt = spt + addby
addby = addby / 2
NEXT n
PRINT "Cylinders:" + STR$(cyls + 1)
PRINT "Heads:" + STR$(heads + 1)
PRINT "Sectors per track:" + STR$(spt)
t& = cyls + 1
t& = t& * (heads + 1)
t& = t& * (spt * 512)
PRINT "Disk capacity:" + STR$(t&) + " bytes "
'end get parameters
i know i huge improvements could be made to my math-related code there, but as far as i can see this should still get the numbers properly based on what i've read about the call.
any ideas?
thanks!