help with some math

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
earlz
Member
Member
Posts: 1546
Joined: Thu Jul 07, 2005 11:00 pm
Contact:

help with some math

Post by earlz »

I need some help with a bit of math, i just really dont know where to start in the eqaution
i want to convert lba to chs
here is the only formula i could find but it is for chs to lba

Code: Select all

DOS_sector_num = BIOS_sector_num - 1 + Head_num*Sectors_per_track
		+ Track_num*Sectors_per_track*Total_heads
if anyone could help me it would greatly be appreciated
Osbios
Member
Member
Posts: 116
Joined: Fri Jun 10, 2005 11:00 pm

Re: help with some math

Post by Osbios »

This is my code for 1440KB floppys:

Code: Select all

;LBA2CHS
;C=LBA/36
;H=(LBA mod 36)/18
;S=((LBA mod 36)mod 18)+1
 mov eax,[LBA] ;eax=LBA(0..2879)
 xor edx,edx
 mov ecx,36
 div ecx
 mov [floppy_c],al
 mov eax,edx
 mov ecx,18
 div cl
 mov [floppy_h],al
 inc ah
 mov [floppy_s],ah
But this is only for 1440KB floppys!!!
dw 0xAA55
earlz
Member
Member
Posts: 1546
Joined: Thu Jul 07, 2005 11:00 pm
Contact:

Re: help with some math

Post by earlz »

thanks a lot, couldnt it be made for anyting if u change some values to the spt and tph and heads per drive

too bad i cant use this right now though(decided to switch to pmode so im not even close to fdd stuff yet)

edit:
(i mean i just decided to switch to pmode last night, about 3 hours after posting this)
Last edited by earlz on Fri Sep 09, 2005 11:00 pm, edited 1 time in total.
Osbios
Member
Member
Posts: 116
Joined: Fri Jun 10, 2005 11:00 pm

Re: help with some math

Post by Osbios »

dw 0xAA55
earlz
Member
Member
Posts: 1546
Joined: Thu Jul 07, 2005 11:00 pm
Contact:

Re: help with some math

Post by earlz »

thanks, looks promising
Post Reply