Read FAT16 table problem

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
Raddel
Posts: 8
Joined: Sat Feb 26, 2011 7:50 am

Read FAT16 table problem

Post by Raddel »

Hello,

I'have a problem during read FAT16 table... this is a piece of my bootsector code

Code: Select all

.....................
READ_FAT:
        mov             ax,4                            ;-- First Sector
        call              LBACHS
   [b] mov             al,250  [/b]                   ;-- Read 1 FAT (Flashdisk 256Mb)
        mov             bx,ds
        mov             es,bx
        mov             di,buffer
        mov             bx,di
        call            READSECTOR
............
                                         
My problem is at bold instruction, i try to read first FAT on disk and i want to read whole one FAT in memory, that is point to ES:BX. But when i check at ES:BX there a invalid value, not a FAT Table. But when I change the value :

Code: Select all

mov al,1
ES:BX have a valid value. I need help who have experience of this thing... Is there limitation at INT 13h to read disk?
Sorry if my english bad.

Best Regards,
Raddel
User avatar
thepowersgang
Member
Member
Posts: 734
Joined: Tue Dec 25, 2007 6:03 am
Libera.chat IRC: thePowersGang
Location: Perth, Western Australia
Contact:

Re: Read FAT16 table problem

Post by thepowersgang »

What interrupt are you calling, what arguments are being passed?
What is the purpose of each instruction in your assembly dump?
Kernel Development, It's the brain surgery of programming.
Acess2 OS (c) | Tifflin OS (rust) | mrustc - Rust compiler
Currently Working on: mrustc
Raddel
Posts: 8
Joined: Sat Feb 26, 2011 7:50 am

Re: Read FAT16 table problem

Post by Raddel »

Here is my code READSECTOR and LBA2CHS

Code: Select all

;-- proc LBACHS must be call to calculation C-H-S
;-- then C-H-S will auto input in register before call int 13h
;-- IN          : AL (Number of Sector to read) 
;-- OUT         : Buffer (ES:BX)
READSECTOR:
        pusha   ;-- push all register
        mov             ah,2h
        
        mov             ch,[absTrack]
        mov             cl,[absSector]
        mov             dh,[absHead]
        mov             dl,[bootdev]
        
        stc
        int             13h
        popa    ;-- pop all register
        ret
                
;-- IN              : AX (LBA)
;   OUT             : Absolute Track (Cylinder), Head, Sector
LBACHS:
        pusha   ;-- push all register
        xor             dx,dx
        
        ;-- Calculation Absolute Sector
        div             word[SectorPerTrack]
        inc             dl
        mov             byte[absSector],dl
        
        ;-- Calculation Absolute Head and Track
        xor             dx,dx
        div             word[Heads]
        mov             byte[absHead],dl
        mov             byte[absTrack],al
        
        popa    ;-- pop all register
        ret
        
        absTrack        db 0
        absHead         db 0
        absSector       db 0              
I have problem when read sector if al = 250, the data is not a valid data, i have check to dump buffer at memory.. But if i read sector set al=1 then buffer have a valid data. How it can be? I need to read FAT table buffered at memory, but it seems gonna wrong when i set al=250. Why 250? because SectorPerFAT=250. Anyone have idea about this?
egos
Member
Member
Posts: 612
Joined: Fri Nov 16, 2007 1:59 pm

Re: Read FAT16 table problem

Post by egos »

Raddel wrote:My problem is at bold instruction, i try to read first FAT on disk and i want to read whole one FAT in memory, that is point to ES:BX. But when i check at ES:BX there a invalid value, not a FAT Table. But when I change the value :

Code: Select all

mov al,1
ES:BX have a valid value. I need help who have experience of this thing... Is there limitation at INT 13h to read disk?
Sorry if my english bad.
Function 2 is able to read the sectors on "one track". You can try to use function 42h before using function 2. I think to cache only actual fragments of FAT is better way. I'm loading whole FAT for floppies only.
If you have seen bad English in my words, tell me what's wrong, please.
azblue
Member
Member
Posts: 147
Joined: Sat Feb 27, 2010 8:55 pm

Re: Read FAT16 table problem

Post by azblue »

Raddel wrote:Here is my code READSECTOR and LBA2CHS

I have problem when read sector if al = 250, the data is not a valid data, i have check to dump buffer at memory.. But if i read sector set al=1 then buffer have a valid data. How it can be? I need to read FAT table buffered at memory, but it seems gonna wrong when i set al=250. Why 250? because SectorPerFAT=250. Anyone have idea about this?
250 Sectors per FAT does not mean the FAT starts at sector 250; if I remember correctly it starts after the reserved sectors.
Raddel
Posts: 8
Joined: Sat Feb 26, 2011 7:50 am

Re: Read FAT16 table problem

Post by Raddel »

@azblues : I have calculate start of LBA before call READSECTOR. al=250 is a number of sector, that's not mean the start of sector, the start of sector read from sector 4.

@Egos: May be you right, i need to extended read. Could you have some example code for that?

If just a disk 1.44Mb it has a little size of FAT, And how i can read FAT Table that have size of partition above 1GB?
Does anyone now the trick about read FAT table in memory?
egos
Member
Member
Posts: 612
Joined: Fri Nov 16, 2007 1:59 pm

Re: Read FAT16 table problem

Post by egos »

Raddel wrote:Could you have some example code for that?
Function 42h is easy to use, but don't forget to check support for it by calling function 41h.
If just a disk 1.44Mb it has a little size of FAT, And how i can read FAT Table that have size of partition above 1GB?
Does anyone now the trick about read FAT table in memory?
As I said above you can cache only actual fragments of FAT е.g. only one sector of FAT and use it until you need to load other one.
If you have seen bad English in my words, tell me what's wrong, please.
Raddel
Posts: 8
Joined: Sat Feb 26, 2011 7:50 am

Re: Read FAT16 table problem

Post by Raddel »

I see, thank you about the information :D.
Post Reply