Program to write data in DMA Mode

void main()
{
clrscr();
union REGS regs;
int ans;
char arr[1000];

outp(0x3f2,0x1c); //Motor On
delay(200);
outp(0x3f5,0x0f); //Command Code
delay(200);
outp(0x3f5,0x00); //Command Code
delay(200);
outp(0x3f5,0); //Cylinder no.
delay(200);
outp(0x3f5,0x08); //Sense Interrupt Command
delay(200);

ans=inp(0x3f5); //Reading ST0 in data register
delay(100);
ans=inp(0x3f5); //pcn

cout<
delay(200);
outportb(0x12,0); /*initialization of DMA Mode*/
delay(200);
outportb(0x11,10); /*supplying Mode Byte*/

int ar=FP_OFF(arr);
int ar1=FP_SEG(arr);
outportb(0x10,2); /*supplying channel no. on port 10*/

regs.h.ch = (ar1)&(0x0f00);
regs.x.ax = regs.h.ah+ar;
(regs.h.ch)++;

outportb(0x04,regs.h.al);
delay(200);

outportb(0x04,regs.h.ah);
delay(200);
outportb(0x81,regs.h.ch);
delay(200);
outportb(0x05,1);
// DMA End

//READ command
delay(200);
outportb(0x3f5,46); //Command Code
delay(200);
outportb(0x3f5,0); //Command Code
delay(200);

outportb(0x3f5,0); //Cylinder no.
delay(200);

outportb(0x3f5,0); //Head Addr
delay(200);
outportb(0x3f5,3); //Record
delay(200);
outportb(0x3f5,2); //Sector size
delay(200);
outportb(0x3f5,5); //EOT
delay(200);
outportb(0x3f5,21); //GPL
delay(200);
outportb(0x3f5,10); //DTL

//result
delay(200);


// st0

int st0 = inportb(0x3f5);
printf("
st0 = %x",st0);
if(inportb(0x3f5) & (192)!=0)
{
printf("
st0= %d",st0);
cout<<"
Abnormal termination st0";
delay(200);
outp(0x3f2,0x0c); //Motor off
exit(0);
}

delay(200);

int st1 = inportb(0x3f5);
printf("
st1 = %x",st1);
if((st1=inportb(0x3f5)) !=0)
{
printf("
st1=%d ",st1);
cout<<"
Abnormal termination st1";
delay(200);
outp(0x3f2,0x0c); //Motor off
exit(0);
}

delay(200);

int st2 = inportb(0x3f5);
printf("
st2 = %x",st2);
if((st2=inportb(0x3f5)) != 0)
{
cout<<"st2= "<
cout<<"
Abnormal termination st2";
delay(200);
outp(0x3f2,0x0c); //Motor off
exit(0);
}

cout<<"
Successful Termination";
delay(200);

cout<<"
c= "<
delay(200);

cout<<"
h= "<
delay(200);

cout<<"
r= "<
delay(200);

cout<<"
n= "<
delay(200);

outp(0x3f2,0x0c); //Motor off

getch();

}

Related Links :

No comments:

Post a Comment


If you face any Problem in viewing code such as Incomplete "For Loops" or "Incorrect greater than or smaller" than equal to signs then please collect from My Web Site CLICK HERE


More Useful Topics...

 

History Of C..

In the beginning was Charles Babbage and his Analytical Engine, a machine
he built in 1822 that could be programmed to carry out different computations.
Move forward more than 100 years, where the U.S. government in
1942 used concepts from Babbage’s engine to create the ENIAC, the first
modern computer.
Meanwhile, over at the AT&T Bell Labs, in 1972 Dennis Ritchie was working
with two languages: B (for Bell) and BCPL (Basic Combined Programming
Language). Inspired by Pascal, Mr. Ritchie developed the C programming
language.

My 1st Program...


#include
#include
void main ()
{
clrscr ();
printf ("\n\n\n\n");
printf ("\t\t\t*******Pankaj *******\n");
printf ("\t\t\t********************************\n");
printf ("\t\t\t\"Life is Good...\"\n");
printf ("\t\t\t********************************");
getch ();
}

Next Step...


#include
#include

void main ()
{
clrscr ();
printf ("\n\n\n\n\n\n\n\n");
printf ("\t\t\t --------------------------- \n\n");

printf ("\t\t\t | IGCT, Info Computers, INDIA | \n\n");
printf ("\t\t\t --------------------------- ");

getch ();

}

Hits!!!