Dieser Code wirft eine Exeption.
int ReadFloppy(int iSector,void *pvBuffer) {
int head,track,sector;
// Compute chs address
sector=(iSector%18)+1;
track=(iSector/18)/2;
head=(iSector/18)%2;
// Enable dma channel
asm("cli");
out(12,0x46);
out(11,0x46);
out(4,(DWORD)pvBuffer & 0xFF); //OFFSET LSB
out(4,((DWORD)pvBuffer >> 8) & 0xFF); //OFFSET MSB
out(0x81,(DWORD)pvBuffer >> 16); //PAGE
out(5,511 & 0xFF); //SIZE-1 LSB
out(5,511 >> 8); //SIZE-1 MSB
out(10,2);
asm("sti");
FloppySeek(track);
FloppyMotorOn();
// Send read command
fd_sendbyte(0x66);
fd_sendbyte(head << 2);
fd_sendbyte(track);
fd_sendbyte(head);
fd_sendbyte(sector);
fd_sendbyte(2); // bytes per sector
fd_sendbyte(18); // Sectors per track
fd_sendbyte(0x1B);
fd_sendbyte(0xFF);
WaitFloppy(0);
int i;
for(i=0;i<10000;i++);
FloppyMotorOff();
return 1;
}
so rufe ich die funktion auf.
char* fatbuff = malloc(512);
ReadFloppy(18,fatbuff);