FAT VBR
Posted: Mon Nov 16, 2015 10:47 am
Hello again,
I have been working on a FAT VBR, that is an AIO VBR for FAT12/16/32.
All size optimization I can see, while keeping everything as a "module", got me down to 50 bytes overweight - at-least I got it down from the 104 bytes lol.
I have currently worked on this for about 5 full hours, my next step will be to remove the "modular" functionality from the VBR code, though I still do not see this fitting in 420 bytes...
Before I get too much farther into this, I just want to ask if this is even possible (Has anyone here done so)?
I know I can do a FAT12/16 and a separate FAT32 VBR, but then I have to keep track of multiple FAT VBRs - and I so rather one VBR for all FATs.
Best regards,
B!
EDIT: without worrying about modular FS I have got it down to 36 Bytes over...
Here is the section I would like help optimizing (for size not speed) some...I know there has to be a more efficient way to find the next cluster...
I have been working on a FAT VBR, that is an AIO VBR for FAT12/16/32.
All size optimization I can see, while keeping everything as a "module", got me down to 50 bytes overweight - at-least I got it down from the 104 bytes lol.
I have currently worked on this for about 5 full hours, my next step will be to remove the "modular" functionality from the VBR code, though I still do not see this fitting in 420 bytes...
Before I get too much farther into this, I just want to ask if this is even possible (Has anyone here done so)?
I know I can do a FAT12/16 and a separate FAT32 VBR, but then I have to keep track of multiple FAT VBRs - and I so rather one VBR for all FATs.
Best regards,
B!
EDIT: without worrying about modular FS I have got it down to 36 Bytes over...
Here is the section I would like help optimizing (for size not speed) some...
Code: Select all
.NextCluster:
mov ebx, DWORD [FAT_Start]
mov edx, DWORD [CurrentCluster]
mov edi, DWORD 0x1000
mov cx, 2
movzx eax, WORD [BPB_TOTALSECTS16]
test ax, ax
jz .FAT32
movzx edx, BYTE [BPB_SECTSPERCLUST]
div dx
cmp ax, 0x0FF6
ja .FAT16
.FAT12:
mov ax, dx
shr ax, 1
add ax, dx
mov dx, ax
shr dx, 8
add ebx, edx
call ReadSectors
movzx bx, al
mov ax, WORD [di + bx]
test bl, 1
jnz .FAT12ODD
and ax, 0x0FFF
cmp ax, 0x0FF0
jae .EOF
jmp .continue
.FAT12ODD:
shr ax, 4
cmp ax, 0x0FF0
jae .EOF
jmp .continue
.FAT16:
movzx ax, dl
shr dx, 8
add ebx, edx
call ReadSectors
shl ax, 1
xchg bx, ax
mov ax, WORD [di + bx]
cmp ax, 0xFFF0
jae .EOF
jmp .continue
.FAT32:
mov al, dl
and ax, 0xF
shr edx, 4
add ebx, edx
call ReadSectors
shl ax, 2
xchg bx, ax
mov eax, DWORD [di + bx]
cmp eax, 0x0FFFFFF0
jb .continue
.EOF:
xor eax, eax
.continue:
mov DWORD [CurrentCluster], eax
popa
ret