Xref: news-dnh.mv.net comp.os.msdos.djgpp:1377 Path: news-dnh.mv.net!mv!news.sprintlink.net!newsfeed.internetmci.com!EU.net!i2unix!news From: mc5686 AT mclink DOT it (Mauro Condarelli) Newsgroups: comp.os.msdos.djgpp Subject: int 25/26 Date: Sat, 05 Aug 1995 11:37:18 GMT Lines: 85 Nntp-Posting-Host: 192.106.166.228 To: djgpp AT sun DOT soe DOT clarkson DOT edu Dj-Gateway: from newsgroup comp.os.msdos.djgpp Hi, i' trying to port to djgpp some code which uses dos int 25h/26h (absolute disk read/write). Here follows a code fragment: /*----- Absolute disk Read-------------------------------------------*/ typedef struct { quad sector __attribute__ ((packed)); word nsects __attribute__ ((packed)); word buff_o __attribute__ ((packed)); word buff_s __attribute__ ((packed)); } DiskReadPacket; int ReadSectors(void *buf, quad sect, int n) { DiskReadPacket drp; __dpmi_regs r; drp.sector = sect; drp.nsects = n; drp.buff_o = (__tb & 15) +sizeof(drp); drp.buff_s = __tb / 16; dosmemput(&drp, sizeof(drp), __tb); r.h.al = DriveNumber; r.x.cx = 0xffff; r.x.bx = __tb & 15; r.x.ds = __tb / 16; __dpmi_int(0x25, &r); if (r.x.flags & 1) { /* error! */ return 0; } dosmemget(__tb+sizeof(drp), n * BootSector.eBPB.SectSiz, buf); return n; } /*----- FAT Handling ------------------------------------------------*/ This fails with ax=701fh and flags=3003h while the original Borland C++ /*----- Absolute disk Read-------------------------------------------*/ typedef struct { quad sector; word nsects; byte far *buff; } DiskReadPacket; int ReadSectors(void *buf, quad sect, int n) { DiskReadPacket drp; union REGS r; struct SREGS s; drp.sector = sect; drp.nsects = n; drp.buff = buf; r.h.al = DriveNumber; r.x.cx = 0xffff; r.x.bx = FP_OFF(&drp); s.ds = FP_SEG(&drp); int86x(0x25, &r, &r, &s); if (r.x.flags & 1) { // error! return 0; } return n; } /*----- FAT Handling ------------------------------------------------*/ works flawlessly. I know int 25 leaves a word on the stack, which skould be pop-ed by the user, can it be that this confuses __dpmi_int() ??? or is there some evident error i just can't see (shame on me)? Any reply MOST welcome :) :) Best Regards Mauro Condarelli (mc5686 AT mclink DOT it)