Mail Archives: djgpp/2007/11/16/15:18:45
--_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>
<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>
<BR>
typedef struct Drive_request {<BR> int cmd;<BR> int=
drive;<BR> int head;<BR> int sec;<BR> int cyl=
;<BR> int nsecs;<BR> unsigned char *buffer;<BR>&nbs=
p; 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>
<BR>
void exec_drive_rq(Drive_rq *rq)<BR>{<BR> union REGS inreg,outreg;<BR>
inreg.h.ah =3D rq->cmd;<BR> inreg.h.al =3D rq->nsecs;<BR>
if (rq->cmd =3D=3D READ) {<BR> rq->buffer =3D (unsig=
ned char *) malloc(512 * rq->nsecs * sizeof(unsigned char));<BR>
if (! rq->buffer) {<BR> fprintf(stderr,"Pro=
gram executiom error...");<BR> getch();<BR> &nb=
sp;exit(EXIT_FAILURE);<BR> }<BR> else<BR> =
inreg.x.bx =3D (unsigned int) rq->buffer;<BR> }<BR> els=
e<BR> inreg.x.bx =3D (unsigned int) rq->buffer;<BR>
inreg.h.ch =3D rq->cyl;<BR> inreg.h.cl =3D rq->sec;<BR>&nb=
sp;inreg.h.dh =3D rq->head;<BR> inreg.h.dl =3D (char) rq->drive;=
<BR>
int86(DISK_ISR,&inreg,&outreg);<BR>
if (outreg.x.cflag)<BR> rq->e=
rrors =3D outreg.h.ah;<BR> else<BR> &nbs=
p; rq->errors =3D NOERR;<BR>}<BR>
<BR>Thanks a lot <BR>
<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 -