Hello,
The
Bios Parameter Block provided is incomplete. What you should be doing is reserving space for the BPB and referencing it; making sure to install the boot record in a way as to not overwrite the file system structure. For example, this is the way we do it,
Code: Select all
bits 16
org 0
jmp short main
nop
;
; bios paramater block area is from offset 0 to 0x5a
; actual code starts at offset 0x5a. Formatting software
; installs the BPB in this area
;
times 0x5a db 0
main:
cli
push 0x7c0
push .fix_cs
retf ; jump to 0x7c0:fix_cs
.fix_cs:
mov ax, 0x7c0 ; set segments
mov es, ax
mov ds, ax
mov fs, ax
mov gs, ax
mov ax, 0
mov ss, ax
mov sp, 0x2000 ; ss:sp = stack top at 0x2000
mov bp, 0x7c00 ; ss:bp = bios param block
The Bios Parameter Block can then be referenced through bp. We reference through bp as the base in order to decrease instruction size and conserve space. It looks like this,
Code: Select all
struc biosParamBlock
.jump resb 3 ; jump instruction
.ident resb 8 ; oem identifier
.bps resw 1 ; bytes per sector
.spc resb 1 ; sectors per cluster
.resSectors resw 1 ; reserved sector count
.fatCount resb 1 ; number of FATs
.dirEntryCount resw 1 ; number of directory enteries
.sectorCount resw 1 ; number of sectors in logical volume
.mediaDescr resb 1 ; media descriptor byte
.fatSectorCount resw 1 ; sectors per FAT (fat12/16 only)
.trackSectorCount resw 1 ; sectors per track
.headCount resw 1 ; number of heads
.hiddenSectCount resd 1 ; number of hidden sectors
.sectorCountBig resd 1 ; only set if sectorCount field is 0 (more then 65535 sectors)
;
; extended boot record for fat32
;
.fatSize32 resd 1 ; Sectors per FAT. The size of the FAT in sectors
.flags resw 1 ; flags
.fatVersion resw 1 ; FAT version number
.rootCluster resd 1 ; cluster number of root directory. Often 2
.fsInfoCluster resw 1 ; cluster number of FSinfo structure
.bootCluster resw 1 ; cluster number of backed up boot sector
.reserved resb 12
.driveNum resb 1 ; drive number, identical to the values returned by the BIOS
.winNTflags resb 1 ; flags in Windows NT
.signiture resb 1 ; must be 0x28 or 0x29
.volumeId resd 1 ; serial number
.label resb 11 ; volume label string padded with spaces
.systemId resb 8 ; system idenitifier string always "FAT32 "
endstruc
Installing the boot record using PartCopy is also a little different from FAT12 due to the size of the new structure,
Code: Select all
partcopy bootsect.bin 0 3 C.IMG 0
partcopy bootsect.bin 5a 1a6 C.IMG 5a
This should provide enough startup code on the proper structure of FAT32 formatted disks and how to install them properly. Note that
PartCopy is called twice here as to not overwrite the on disk BPB that the formatting utility installed.