Home arrow Forums
OSDEV Forums  


bradbobak
User

Fresh Osdever
Posts: 1
graphgraph
Karma: 0  
looking for optimized asm - 2006/04/13 01:23 Hey guys.. I'm looking for optimized asm code that will take eax holding a linear block and convert to track / head / sector info..
basically in C:
Code:

   track linear / (secs_per_track num_heads)  head =  (linear % (secs_per_track num_heads)) / secs_per_track;  sector = ((linear % (secs_per_track num_heads)) % secs_per_track) + 1;



I'm sure this has been done before.. the reason I don't do it myself is that this is going in a 512byte bootsector and I need optimized (read: small) code..
Any help will be appreciated..
  | | The administrator has disabled public write access.
OSDEV
Community
Advertisement
   
gaf
User

Platinum Osdever
Posts: 153
graph
Karma: 10  
Re:looking for optimized asm - 2006/04/13 08:00 Hello,
if this is meant to be a bootsector for a floppy disk, you can assume standard values for the number of sectors/heads/tracks as disk size and geometry is always the same. By inserting these concrete numbers into your equation the code should get much simpler.

For an example you might have a look at John Fine's bootsector. Read32 in Boot12.asm does exactly what you are looking for..

regards,
gaf
  | | The administrator has disabled public write access.

A WebArticles site. Sponsored by Evoleto. Motorola V525 / Business Directory / Delaware Incorporation / Home Made Bazaar