Page 1 of 1
Read FAT16 table problem
Posted: Mon Mar 07, 2011 4:51 pm
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 :
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
Re: Read FAT16 table problem
Posted: Mon Mar 07, 2011 6:41 pm
by thepowersgang
What interrupt are you calling, what arguments are being passed?
What is the purpose of each instruction in your assembly dump?
Re: Read FAT16 table problem
Posted: Mon Mar 07, 2011 11:20 pm
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?
Re: Read FAT16 table problem
Posted: Tue Mar 08, 2011 12:24 am
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 :
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.
Re: Read FAT16 table problem
Posted: Tue Mar 08, 2011 3:08 pm
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.
Re: Read FAT16 table problem
Posted: Wed Mar 09, 2011 4:33 am
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?
Re: Read FAT16 table problem
Posted: Wed Mar 09, 2011 5:50 am
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.
Re: Read FAT16 table problem
Posted: Wed Mar 09, 2011 8:17 am
by Raddel
I see, thank you about the information
.