reasons for carry flag to be set?

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
Mr_Spam

reasons for carry flag to be set?

Post 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?
Curufir

Re:reasons for carry flag to be set?

Post 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?
Post Reply