Page 1 of 1

FAT 12 File System

Posted: Sun Jan 11, 2009 5:30 pm
by Stavros
I'm trying to implement a FAT 12 file system. The disk is formatted as follows:

Boot Sector (1 sector) | Reserved (1 sector) | FAT 1 (9 sectors) | FAT 2 (9 sectors) | Root ....

My Root directory starts at sector 21. Each cylinder has 18 sectors on the disk. So the starting root sector is at the second cylander at sector 3. I used the following code to try to load that sector into memory:

MOV ax, 0x1000
MOV es, ax ;es - extra segment. Pointer to extra data. es = 0x1000
MOV bx, 0 ;bx - Base register. Used as a pointer to data. bx = 0

MOV al, 1 ;Load just 1 disk sector
MOV ch, 1 ;Cylander = 1
MOV cl, 3 ;Sector = 3
MOV dh, 0 ;Head = 0
MOV dl, 0 ;Drive = 0 (A drive)

MOV ah, 2
INT 0x13

The above code causes bochs to enter an endless loop that keeps on printing out the following message:

prefetch: EIP [00010000] > CS.limit [0000ffff]

Any ideas as to what is wrong?

Also, I haven't had any luck reading any sector that was not in the first cylinder.

Thanks!

Re: FAT 12 File System

Posted: Sun Jan 11, 2009 5:32 pm
by VolTeK
are you jumping to the loaded sector to run it? i dont really know about files systems but i know bootprog does this. i looked at it, and somewhere there is a jmp 0x1000? i think thats it

Re: FAT 12 File System

Posted: Sun Jan 11, 2009 5:35 pm
by Stavros
Yes. After the sector is loaded to memory I jump to the code in memory. The jump code is:

Code: Select all

JMP 0x1000:0000

Re: FAT 12 File System

Posted: Sun Jan 11, 2009 6:15 pm
by ru2aqare
Stavros wrote:My Root directory starts at sector 21. Each cylinder has 18 sectors on the disk. So the starting root sector is at the second cylander at sector 3.
I think sector twenty-one is at sector three, head one, cylinder zero actually... Floppies have two sides.

The Bochs error usually indicates that you are running at a bogus memory address (like above 1M in real mode).
Stavros wrote:Also, I haven't had any luck reading any sector that was not in the first cylinder.
This may be related to the head issue.

Re: FAT 12 File System

Posted: Sun Jan 11, 2009 6:23 pm
by Stavros
Yes. That worked. Thanks! So I guess floppies only have 1 cylinder per head?

Re: FAT 12 File System

Posted: Sun Jan 11, 2009 6:54 pm
by Love4Boobies
Stavros wrote:Yes. That worked. Thanks! So I guess floppies only have 1 cylinder per head?
Lol. No, there's 80 of them per head, 2 heads.

Re: FAT 12 File System

Posted: Sun Jan 11, 2009 6:59 pm
by VolTeK
check wikipedia on different floppy disks and then you can set your bootlaoder to use, say you want to make one for a different size, i would check for future references