X-Authentication-Warning: delorie.com: mail set sender to djgpp-bounces using -f From: gohyongkwang AT hotmail DOT com (Goh, Yong Kwang) Newsgroups: comp.os.msdos.djgpp Subject: Interpreting return value from _bios_disk Date: 28 Jul 2004 02:36:52 -0700 Organization: http://groups.google.com Lines: 74 Message-ID: <354933d6.0407280136.42e3b0e2@posting.google.com> NNTP-Posting-Host: 165.21.83.230 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Trace: posting.google.com 1091007412 12586 127.0.0.1 (28 Jul 2004 09:36:52 GMT) X-Complaints-To: groups-abuse AT google DOT com NNTP-Posting-Date: Wed, 28 Jul 2004 09:36:52 +0000 (UTC) To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com Hi. I'm writing a simple program to read read a floppy at the sector level, so I'm using _bios_disk. Apparently, there are some bugs in the documentation and example for _bios_disk. After reading some previous postings by other users, it appears to me that the line in the example: di.buffer = &record_buffer; ought to be changed to: di.buffer = record_buffer; since record_buffer is declared as: char record_buffer[512]; Secondly, the way of interpreting the return value is not just comparing it to zero for success and non-zero otherwise. Since AL also contains the number of sectors read (I'm only currently experimenting with _DISK_READ so far), hence some masking or bit shifting ought to be done. I've copied my short program below to double check if I'm interpreting the return value correctly. ---- #include #include int main(void){ char record_buffer[512]; struct diskinfo_t di; unsigned ax_value = 0; di.drive = 0x00; di.head = 0; di.track = 0; di.sector = 1; di.nsectors = 1; di.buffer = record_buffer; ax_value = _bios_disk(_DISK_READ, &di); printf("AH=%X AL=%X\n", (ax_value & 0x0000FF00) >> 8, ax_value & 0x000000FF); return 0; } ---- The confusing thing is that it returns an unsigned (integer) which is 4 bytes huge in DJGPP and AX is only 16 bits and therefore 2 bytes huge. Hence I think the first two bytes are just for padding purpose and unused and the last 2 bytes store the actual value of AH and AL respectively. Therefore some bit masking and shifting may be necessary to parse the AH and AL value. Is my code and interpretation correct? Just need a confirmation from you guys. Initially I was wondering why I kept getting "Disk error" with the _bios_disk example because the return value was non-zero. Lastly, I notice that I'm always given the Disk Time Out error AH=0x80 instead of a Drive not ready error AH=0xAA like DOS does whenever a floppy is not present in the drive and my program tries to access the non-available floppy disk. DOS reports, "Not ready reading drive A." Why is this so? Thanks a lot. Goh, Yong Kwang Singapore