As part of my operating system I wrote this read sector function.
It takes a sector address to read from a BIOS device id. But when I set to read from sector 19 (Head: 0, Track: 1, Sector 2) the result at 0x1000:0x0000 is likely past that sector (I checked that several times with a hex viewer).
Also, when I read more than one sector, so that sector 19 is included, at the address mentioned above, I can read sector 19 which is copied at 0x1000:(512*19) without a problem.
void __NOINLINE resetDisk(const int device_id) { __asm__ __volatile__("" : : "d"(0x0000|device_id)); //set device id __asm__ __volatile__("mov $0x0000,%ax"); //function 0x02 __asm__ __volatile__("int $0x13");}void __NOINLINE readDiskSector(const int sector, const int device_id) { resetDisk(device_id); int sector_count = 2880; int heads = 2; int tracks = 18; int h = sector/(sector_count/heads); int c = (sector-h*(sector_count/heads))/tracks; int s = sector-c*tracks-h*(sector_count/heads)+1; __asm__ __volatile__("push %es"); __asm__ __volatile__("" : : "a"(c)); __asm__ __volatile__("" : : "b"(s)); __asm__ __volatile__("mov %al,%ch"); __asm__ __volatile__("mov %bl,%cl"); __asm__ __volatile__("" : : "a"(h)); __asm__ __volatile__("" : : "b"(device_id)); __asm__ __volatile__("mov %al,%dh"); __asm__ __volatile__("mov %bl,%dl"); __asm__ __volatile__("mov $0x03,%si"); __asm__ __volatile__("try_again_reading:"); __asm__ __volatile__("cmp $0x00,%si"); __asm__ __volatile__("je stop_trying"); __asm__ __volatile__("mov $0x1000,%bx"); __asm__ __volatile__("mov %bx,%es"); __asm__ __volatile__("mov $0x0000,%bx"); __asm__ __volatile__("mov $0x02,%ah"); __asm__ __volatile__("mov $0x01,%al"); __asm__ __volatile__("int $0x13"); __asm__ __volatile__("dec %si"); __asm__ __volatile__("jc try_again_reading"); __asm__ __volatile__("stop_trying:"); __asm__ __volatile__("pop %es");}