FAT 12 File System

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
Stavros
Posts: 7
Joined: Wed Dec 31, 2008 11:40 am

FAT 12 File System

Post 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!
User avatar
VolTeK
Member
Member
Posts: 815
Joined: Sat Nov 15, 2008 2:37 pm
Location: The Fire Nation

Re: FAT 12 File System

Post 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
Stavros
Posts: 7
Joined: Wed Dec 31, 2008 11:40 am

Re: FAT 12 File System

Post 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
ru2aqare
Member
Member
Posts: 342
Joined: Fri Jul 11, 2008 5:15 am
Location: Hungary

Re: FAT 12 File System

Post 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.
Stavros
Posts: 7
Joined: Wed Dec 31, 2008 11:40 am

Re: FAT 12 File System

Post by Stavros »

Yes. That worked. Thanks! So I guess floppies only have 1 cylinder per head?
User avatar
Love4Boobies
Member
Member
Posts: 2111
Joined: Fri Mar 07, 2008 5:36 pm
Location: Bucharest, Romania

Re: FAT 12 File System

Post 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.
"Computers in the future may weigh no more than 1.5 tons.", Popular Mechanics (1949)
[ Project UDI ]
User avatar
VolTeK
Member
Member
Posts: 815
Joined: Sat Nov 15, 2008 2:37 pm
Location: The Fire Nation

Re: FAT 12 File System

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