delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2002/06/11/18:45:11

From: Nick <jp_prongs AT yahoo DOT com>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: bit and bytes ... help [ biosdisk ]
Date: Tue, 11 Jun 2002 18:29:53 -0400
Organization: MindSpring Enterprises
Lines: 21
Message-ID: <3D0679E1.E9F97F93@yahoo.com>
References: <eGkN8.90451$6v2 DOT 3674113 AT twister DOT southeast DOT rr DOT com>
NNTP-Posting-Host: a5.f7.88.b7
Mime-Version: 1.0
X-Server-Date: 11 Jun 2002 22:30:12 GMT
X-Mailer: Mozilla 4.75 [en] (Win98; U)
X-Accept-Language: en
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com


"Frank Troy Cook Jr." wrote:
> 
> i need to extract drive information returned from a biosdisk call. for
> example:
-snip-
> i understandfrom the djgpp site that the first 4 bytes return:
> byte 0 = sectors per track (bits 0..5) and top two bits of cylinder (in bits
> 6..7)
> byte 1 = cyliders (bits 0..7)
> byte 2 = number of drives
> byte 3 = number of heads
> how do i convert this to integer numbers correctly?

int sectors_per_track = buffer[0] & 0x1f;
int cylinders = buffer[1] + ((buffer[0] & 0xc0) << 2);
int number_of_drives = buffer[2];
int number_of_heads = buffer[3];

Some of the parentheses on "cylinders" may be unnecessary, but I think it's clearer that way.

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019