Hi xitrum,
I decided to go down a different route using malloc to allocate it a section of memory of 512 or multiples of depending on how many sectors i wanted to read and then allocating this pointer to the es register (where the memory location for the sector to be read into usually goes) and so far it isn't kicking out an coding error during compilation but when I am trying to simply print this section of memory out using the pointer as reference the results are not what I am expecting. Below is the code that i have so far:
#include <dos.h>
#include <stdio.h>
/* reads a given sector on the cylinder, head and drive (cyl, hd & dr)*/
read_sector(cyl, hd, dr)
char cyl, hd, dr;
{
int status;
int *memsectptr;
int *tempptr;
int sectorsize = 512;
int noofsectors = 1;
int i;
char buff[512];
*memsectptr = malloc(sectorsize); /*open 512 bytes of data in memory to read in sector */
tempptr = memsectptr;
_AH = 0x02; /* read sectors instead of verify command */
_AL = noofsectors; /* read one sector only */
_CH = cyl;
_CL = 1; /* starts at sector 1*/
_DH = hd;
_DL = dr;
//_BX = 0x00; /* no offset for data to be stored */
ES:_BX = *memsectptr; /*Add memory location in to read data to */
geninterrupt(0x13);
for(i=0; i<(sectorsize * noofsectors); i++)
{
printf("%X", memsectptr);
}
free(memsectptr);
status = _AH;
return(status);
}
/* takes the status code returned by verify track and prints message associated with it */
pr_error(error)
int error;
{
switch(error)
{
case 0x01:
printf("Invalid Command\n");
break;
case 0x02:
printf("Address Mark Not Found\n");
break;
case 0x03:
printf("Disk Write Protected\n");
break;
case 0x04:
printf("Sector Not Found\n");
break;
case 0x05:
printf("Reset Failed\n");
break;
case 0x06:
printf("Floppy Disk Removed\n");
break;
case 0x08:
printf("DMA Overrun\n");
break;
case 0x09:
printf("DMA Crossed 64k Boundary\n");
break;
case 0x0C:
printf("Media Type Not Found\n");
break;
case 0x10:
printf("CRC Error\n");
break;
case 0x20:
printf("Controller Failed\n");
break;
case 0x40:
printf("Seek Failed\n");
break;
case 0x80:
printf("\n status %d\n", error);
}
}
/* main calls verify_track for all values of cyl (0-79) and both values for head (0-1). If function succeeds it returns 0
otherwise it returns the relevant error code to printf and terminates program.*/
main()
{
int status = 0;
char head, cylinder;
char drive = 0;
head = 0;
cylinder = 0;
status = read_sector(cylinder, head, drive);
if( status != 0)
{
printf("\nError at head %d, cylinder %02d :", head, cylinder);
pr_error(status);
}
else
{
printf("\nOperation completed successfully. See output\n");
}
}
Thanks, Dinklebaga