Hi Kevin You write that you are planning to access the drive directly from the PIC=2E Are you going to implement an IDE interface from the PIC? This sounds interesting=2E Anyway, the int25 and int13 calls are as you may know interface calls to PC DOS, the very code that does the trick is hidden in the DOS=2E I have used int calls a lot but not in Turbo C, unfortunately=2E Hope you ge= t the help you need=2E -------------------------------------------- Hans Nielsen NIELSEN Elektronik nielsen=2Eelek@wanadoo=2Efr ------------------------------------------- > -----Ursprungligt meddelande----- > Fr=E5n: pic microcontroller discussion list > [mailto:PICLIST@MITVMA=2EMIT=2EEDU]F=F6r Kevin A=2E Benedict > Skickat: den 25 september 2001 07:34 > Till: PICLIST@MITVMA=2EMIT=2EEDU > =C4mne: [PIC]: C source code for int25 or int13 > > > Hi, > Does anyone have a C program with source code for reading a sector > from a hard drive with int25 or int13 ? > I eventually plan to access the drive with a PIC, but thought I > would start with a simple(?) C program=2E > The program I was trying to use is below, it was written in MS C 5=2E10, > I have TurboC 2=2E0=2E If I include the far pointer it won't compile, > if I don't include it, it doesn't like the FP_ statements=2E > Any help/comments would be appreciated=2E > > Thanks, > Kevin > > > /* Read a Sector from the Harddrive */ > #include > #include > > struct parm_block { > unsigned long start_sector; > unsigned num_of_sectors; > char far *buffer; > } > > main() > { > union REGS inregs, outregs; > struct SREGS segregs; > > /* original code had struct far parm_block p_block; */ > struct parm_block p_block; > > /* construct parameter block */ > > p_block=2Estart_sector =3D 0; > p_block=2Enum_of_sectors =3D 1; > p_block=2Ebuffer =3D (char far *) farmalloc(512) ; /* buffer for 1 secto= r */ > > /* call function */ > inregs=2Eh=2Eal =3D 0x02; /* drive c */ > inregs=2Ex=2Ecx =3D 0xffff; /* extended calling format */ > inregs=2Ex=2Ebx =3D FP_OFF(p_block); /* xfer pblock offset to bx */ > segregs=2Eds =3D FP_SEG(p_block); /* xfer pblock segment to ds */ > int86x(0x25, &inregs, &outregs, &segregs); /* read sector to buffer */ > > > if ((outregs=2Ex=2Ecflag & 0x01) =3D=3D 0x01) { > printf("\nError Code: %x", outregs=2Ex=2Eax); /* check for error */ > exit(1); > } > /* Process sector here*/ > exit(0); > } > Code from The indispensible PC hardware book by Hans-Peter Messmer > > -- > http://www=2Epiclist=2Ecom hint: The list server can filter out subtopics > (like ads or off topics) for you=2E See http://www=2Epiclist=2Ecom/#topics > > -- http://www.piclist.com hint: The list server can filter out subtopics (like ads or off topics) for you. See http://www.piclist.com/#topics