X-Authentication-Warning: delorie.com: mail set sender to djgpp-bounces using -f X-Recipient: djgpp AT delorie DOT com Message-ID: Content-Type: multipart/alternative; boundary="_8474c3f6-1e05-4835-a054-91efc89c05a2_" X-Originating-IP: [24.203.252.135] From: sHadoW MaN To: Subject: using DOS ISR calls Date: Fri, 16 Nov 2007 15:17:47 -0500 Importance: Normal MIME-Version: 1.0 X-OriginalArrivalTime: 16 Nov 2007 20:17:47.0721 (UTC) FILETIME=[C137AB90:01C8288D] Reply-To: djgpp AT delorie DOT com --_8474c3f6-1e05-4835-a054-91efc89c05a2_ Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Hi=20 =20 I wanted to use the int86 with the disk interrupt 13h, I wanted to read the= boot block (MBR), 1st I had programmed this using Borland's Turbo C++ comp= iler and it worked fine, but when compile it usingg DJGPP, it doesn't. I us= ed to print to screen all the block bytes, and with both compiler it's not = he same, with TC compiler I got the right block data (due to the last 2 byt= es signature AA55) here's the code below: =20 typedef struct Drive_request { int cmd; int drive; int head; int sec;= int cyl; int nsecs; unsigned char *buffer; int errors;} Drive_rq; enum Commands { RESET,STATUS,READ,WRITE,FORMAT,VERIFY };enum Drives { FD0,F= D1,HD0 =3D 0x80,HD1 };enum Status { NOERR,BADCMD }; #define DISK_ISR 0x13 =20 void exec_drive_rq(Drive_rq *rq){ union REGS inreg,outreg; inreg.h.ah =3D rq->cmd; inreg.h.al =3D rq->nsecs; if (rq->cmd =3D=3D READ) { rq->buffer =3D (unsigned char *) malloc(512 * = rq->nsecs * sizeof(unsigned char)); if (! rq->buffer) { fprintf(stderr,"Program executiom error..."); get= ch(); exit(EXIT_FAILURE); } else inreg.x.bx =3D (unsigned int) rq->b= uffer; } else inreg.x.bx =3D (unsigned int) rq->buffer; inreg.h.ch =3D rq->cyl; inreg.h.cl =3D rq->sec; inreg.h.dh =3D rq->head; i= nreg.h.dl =3D (char) rq->drive; int86(DISK_ISR,&inreg,&outreg); if (outreg.x.cflag) rq->errors =3D outreg.h.ah; else rq->er= rors =3D NOERR;} Thanks a lot=20 =20 _________________________________________________________________ Envoie un sourire, fais rire, amuse-toi! Employez-le maintenant! http://www.emoticonesgratuites.ca/?icid=3DEMFRCA120= --_8474c3f6-1e05-4835-a054-91efc89c05a2_ Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Hi
 
I wanted to use the int86 with the disk interrupt 13h, I wanted to read the= boot block (MBR), 1st I had programmed this using Borland's Turbo C++ comp= iler and it worked fine, but when compile it usingg DJGPP, it doesn't. I us= ed to print to screen all the block bytes, and with both compiler it's not = he same, with TC compiler I got the right block data (due to the last 2 byt= es signature AA55)
here's the code below:
 
typedef struct Drive_request {
   int cmd;
   int= drive;
   int head;
 int sec;
   int cyl= ;
   int nsecs;
   unsigned char *buffer;
&nbs= p;  int errors;
} Drive_rq;
enum Commands { RESET,STATUS,READ,WRITE,FORMAT,VERIFY };
enum Drives { F= D0,FD1,HD0 =3D 0x80,HD1 };
enum Status { NOERR,BADCMD };
#define DISK_ISR 0x13
 
void exec_drive_rq(Drive_rq *rq)
{
 union REGS inreg,outreg;
 inreg.h.ah =3D rq->cmd;
 inreg.h.al =3D rq->nsecs;
 if (rq->cmd =3D=3D READ) {
  rq->buffer =3D (unsig= ned char *) malloc(512 * rq->nsecs * sizeof(unsigned char));
  if (! rq->buffer) {
   fprintf(stderr,"Pro= gram executiom error...");
   getch();
  &nb= sp;exit(EXIT_FAILURE);
  }
  else
  =   inreg.x.bx =3D (unsigned int) rq->buffer;
 }
 els= e
   inreg.x.bx =3D (unsigned int) rq->buffer;
 inreg.h.ch =3D rq->cyl;
 inreg.h.cl =3D rq->sec;
&nb= sp;inreg.h.dh =3D rq->head;
 inreg.h.dl =3D (char) rq->drive;=
 int86(DISK_ISR,&inreg,&outreg);
   if (outreg.x.cflag)
      rq->e= rrors =3D outreg.h.ah;
   else
    &nbs= p;  rq->errors =3D NOERR;
}

Thanks a lot
 


Envoie un sourire, fais rire, amuse-toi! Employe= z-le maintenant! = --_8474c3f6-1e05-4835-a054-91efc89c05a2_--