FAT32: get next cluster number.
Posted: Thu Jun 10, 2010 10:55 pm
hi
i've been working on FAT32 usb boot program so far. But now i found that my function of getting next cluster num does not work.
i wrote it according to FAT: General Overview of On-Disk Form, Version 1.02, May 5, 1999, Microsoft Corporation
notice it is under real mode not protected mode.
i tested it with formated disk and i wrote a program in C++ and it got the right answer in the same method.
tmpfat in the code is 0x90000
eax=3 should output eax=4 but it 0 here.
i test it on real machine(because i hope to boot with a USB disk) so i can't figure out if it is always 0.
could anyone help me figure out where is the problem?
thx
i've been working on FAT32 usb boot program so far. But now i found that my function of getting next cluster num does not work.
Code: Select all
;================================================
getfat: ;return eax = fat[eax]
pushad
xor ebx,ebx
mov bx,[BPB_BytsPerSec]
shr bx,2 ;bx/4,every entry 4 bytes
div ebx
mov bx,[BPB_RsvdSecCnt]
add eax,ebx ;eax = sector
mov cx,1
mov edi,tmpfat
call readsectors ;read cx sectors start at eax to edi
shl edx,2 ;edx*4 = offset
mov eax,[edx+tmpfat]
xor edx,edx
mov dx,sp
mov [edx+28],eax ;store it in the eax in stack
popad
ret
Code: Select all
ThisFATSecNum = BPB_ResvdSecCnt + (FATOffset / BPB_BytsPerSec);
ThisFATEntOffset = REM(FATOffset / BPB_BytsPerSec);
i tested it with formated disk and i wrote a program in C++ and it got the right answer in the same method.
tmpfat in the code is 0x90000
eax=3 should output eax=4 but it 0 here.
i test it on real machine(because i hope to boot with a USB disk) so i can't figure out if it is always 0.
could anyone help me figure out where is the problem?
thx