Page 1 of 1

reasons for carry flag to be set?

Posted: Mon Feb 10, 2003 6:27 pm
by Mr_Spam
in my boot secotor i am trying to implement fat12. in my read disk function, the cary flag is always set after trying to read from the disk. when i set the function arguments to constants, it works, but when there set to varriables it dosn't.

I have tried 2 different ways of converting logical sector to track, head, ect..but either way is dosn't work. any help possable?

Re:reasons for carry flag to be set?

Posted: Mon Feb 10, 2003 8:12 pm
by Curufir
There is one, and only one, correct way to convert LBA to CHS.

In pseudo-code:

Sector = ((LBA Sector) mod (Sectors per track)) + 1
Head = floor((LBA Sector) / (Sectors per track)) mod (Heads per cylinder)
Cylinder = floor(floor((LBA Sector) / (Sectors per track)) / (Heads per cylinder))

Make sure you are getting the results you should be getting.

Also remember that LBA starts at 0, so a floppy has an LBA range of 0-2779, CHS starts at sector 1, this has caused much confusion throughout the ages :).

As to why the carry flag is set. Have you reset the drive before starting your read operations?