www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2007/11/16/15:18:45

X-Authentication-Warning: delorie.com: mail set sender to djgpp-bounces using -f
X-Recipient: djgpp AT delorie DOT com
Message-ID: <BAY106-W28A28C4CD5A3E0F7A597B389830@phx.gbl>
X-Originating-IP: [24.203.252.135]
From: sHadoW MaN <captain_fantastik AT hotmail DOT com>
To: <djgpp AT delorie DOT com>
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

<html>
<head>
<style>
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
FONT-SIZE: 10pt;
FONT-FAMILY:Tahoma
}
</style>
</head>
<body class=3D'hmmessage'>
Hi <BR>
&nbsp;<BR>
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)<BR>
here's the code below:<BR>
&nbsp;<BR>
typedef struct Drive_request {<BR>&nbsp;&nbsp; int cmd;<BR>&nbsp;&nbsp; int=
 drive;<BR>&nbsp;&nbsp; int head;<BR>&nbsp;int sec;<BR>&nbsp;&nbsp; int cyl=
;<BR>&nbsp;&nbsp; int nsecs;<BR>&nbsp;&nbsp; unsigned char *buffer;<BR>&nbs=
p;&nbsp; int errors;<BR>} Drive_rq;<BR>
enum Commands { RESET,STATUS,READ,WRITE,FORMAT,VERIFY };<BR>enum Drives { F=
D0,FD1,HD0 =3D 0x80,HD1 };<BR>enum Status { NOERR,BADCMD };<BR>
#define DISK_ISR 0x13<BR>
&nbsp;<BR>
void exec_drive_rq(Drive_rq *rq)<BR>{<BR>&nbsp;union REGS inreg,outreg;<BR>
&nbsp;inreg.h.ah =3D rq-&gt;cmd;<BR>&nbsp;inreg.h.al =3D rq-&gt;nsecs;<BR>
&nbsp;if (rq-&gt;cmd =3D=3D READ) {<BR>&nbsp;&nbsp;rq-&gt;buffer =3D (unsig=
ned char *) malloc(512 * rq-&gt;nsecs * sizeof(unsigned char));<BR>
&nbsp;&nbsp;if (! rq-&gt;buffer) {<BR>&nbsp;&nbsp;&nbsp;fprintf(stderr,"Pro=
gram executiom error...");<BR>&nbsp;&nbsp;&nbsp;getch();<BR>&nbsp;&nbsp;&nb=
sp;exit(EXIT_FAILURE);<BR>&nbsp;&nbsp;}<BR>&nbsp;&nbsp;else<BR>&nbsp;&nbsp;=
&nbsp; inreg.x.bx =3D (unsigned int) rq-&gt;buffer;<BR>&nbsp;}<BR>&nbsp;els=
e<BR>&nbsp;&nbsp; inreg.x.bx =3D (unsigned int) rq-&gt;buffer;<BR>
&nbsp;inreg.h.ch =3D rq-&gt;cyl;<BR>&nbsp;inreg.h.cl =3D rq-&gt;sec;<BR>&nb=
sp;inreg.h.dh =3D rq-&gt;head;<BR>&nbsp;inreg.h.dl =3D (char) rq-&gt;drive;=
<BR>
&nbsp;int86(DISK_ISR,&amp;inreg,&amp;outreg);<BR>
&nbsp;&nbsp; if (outreg.x.cflag)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; rq-&gt;e=
rrors =3D outreg.h.ah;<BR>&nbsp;&nbsp; else<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
p;&nbsp; rq-&gt;errors =3D NOERR;<BR>}<BR>
<BR>Thanks a lot <BR>
&nbsp;<BR><br /><hr />Envoie un sourire, fais rire, amuse-toi! <a href=3D'h=
ttp://www.emoticonesgratuites.ca/?icid=3DEMFRCA120' target=3D'_new'>Employe=
z-le maintenant!</a></body>
</html>=

--_8474c3f6-1e05-4835-a054-91efc89c05a2_--

- Raw text -


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