int main(void){
for (int i = 0; i < 20; i++){
read_ide_sector(20000 + i, 0x100000 + i * 512);
goto 0x10000; // NOTE: Not proper C language!
}
}
void read_ide_sector(int s, int a){
while((inb(0x1F7) & 0xc0) != 0x40) // inb = inbyte
continue;
outb(0x1F2,1); // Outbyte # of sectors
outb(0x1F3, s & 0xff);
outb(0x1F4, (s >> 8) & 0xff);
outb(0x1F5, (s >> 16) & 0xff);
outb(0x1F6, (s >> 24) & 0xff);
outb(0x1F7, 0x20); // Read sector
while((inb(0x1F7) & 0xc0) != 0x40)
continue;
insl(0x1F0,a,128); // Where, data, copy # of 4-bytes units
}
|
int main(void){
char buffer[512];
int nwords = 0;
bool in_word = false;
for (int s = 500000;; s++){
read_ide_sector(s, (int)buf); // Typecasting buf
for (int j=0; j < 512; j++){
if(!buf[j]){
write_out[nwords];
return;
}
bool this_alpha = isalpha((unsigned char) buf[j]) != 0;
nwords += this_alpha & ~in_word; // ~ means invert bits; has the same effect as !, but is generally faster, increment word count
in_word = this_alpha; // Now in a word
}
}
}
|