HELP ON INT13

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
Comet

HELP ON INT13

Post by Comet »

Hallo...

To avoid FAT and other fs understanting (for the moment) I projected a very simple fs, but I have this strange - for me - problem:

Ofcorse when I wanto to read first, second and.... on track 0, no problem seems to come:

mov ah,2
mov al,1
mov ch,0
mov cl,1
mov dx,0
mov bx,somevalue
int 0x13

ok...
When I change the tack number and it's not 0 I had this problem:

Example: Track 2, sector 1: insteado of starting at 18432th byte (2*18*512), it starts at 36864th byte (seems 2*18*1024).

int13 reads/writes only 512 byte (a sector).

the code is the same as above with the difference:

mov ch,2
mov cl,1

What do you think I'am missing? Where I'am wrong?

PS: I'm using an image of floppy and vmware. At the beginning the floppy is formatted with all 0s, the boot-sector and some data that I know where it is for test only.

Thanks
Comet (bye from Italy)
B.E

Re:HELP ON INT13

Post by B.E »

Try running it on a real machine.
Red Shaya

Re:HELP ON INT13

Post by Red Shaya »

Your diskette has two sides (heads)
Your calculation sould be (cyl*2*18+head*18+(track-1))*512

in your case if ch=2,cl=1,dl=0,al=1
(2*2*18+0*18+0)*512 = 36K (2*18*1024)
Comet

Re:HELP ON INT13

Post by Comet »

Mmmm.... Are you sure your calculation is correct?

Isn't cyl = track? Is it?

and....

Does each heads have 80 tacks???

Where I'am wrong?????

For example.... how can set cx for the sector 101?? or sector... say it SEC?? :)

(I think that memory and disk are the most hard part of OS.... sigh...)

Thanks
Comet (bye from italy)
Red Shaya

Re:HELP ON INT13

Post by Red Shaya »

a few points.

Yes a cylinder = track. A cylinder is more commonly used in hard drives where you have a few plates (and a few heads) so each group of tracks with the same radios is called a cylinder.

here is a physical explanation:
Look at your diskette. it has a plastic disk coated with a magnetic surface. there are two surfaces, the top surface and the bottom surface. your diskette drive has two heads. one that travel over the top surface and one that travel over the bottom surface. those heads move together in (twards the center of the diskette) and out (twards the radius).

Look at this link for a graphic illustration.
see also this slide

about adressing sector number 101 (with 1 being track 0 head 0 sect 1) it will be track (Cylinder) = 101/(18*2) = 2; head = (101-72)/18 = 1; sect = 101-72-18 = 11

if I remember correctly bits 6-7 of CL are the high bits of the cylinder number (but they are used only for HD's).
See also http://www.ctyme.com/intr/rb-0607.htm
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Re:HELP ON INT13

Post by Pype.Clicker »

you might like to know that the 'natural' order on a PC disk is to switch to the next head when at the end of a track before going to the next track.

E.g. if you fill a floppy (using cat >/dev/fd0, for instance) with 512 'a', then 512 'b', then 512 'c', ... you'll find the sector with 'r' at track 0, head 0, sector 18 and the sector with 's' at track 0, head 1, sector 1 (rather than track 1, head 0, sector 1).

You *can* change that natural order to whatever order you prefer, but in that case, issuing a read/write command that spans over 2 tracks will get wrong (note that you cannot issue a single command that would require the head to be moved, anyway).
Post Reply