My assembly program has following structure:
BPB_FAT16 STRUCT ; Base BPB_FAT16. Size=0x19=25.
BytesPerSector DW 0x0200 ; Size of HW sector, usualy 512.
SectorsPerCluster DB 0x01 ; Valid values 1,2,4,8,16,32,64,128.
ReservedSectors DW 0x0001 ; NrOfSectors preceding FAT.
NumberOfFats DB 0x02 ;
RootEntries DW 0x00E0 ; Max number of YWORD entries in the
;root dir.
SmallSectors DW 0x0B40 ; See also .LargeSectors.
MediaDescriptor DB 0xF0 ; 0xF0 floppy disk, 0xF8 hard disk.
SectorsPerFat DW 0x0009 ;
SectorsPerTrack DW 0x0012 ;
NumberOfHeads DW 0x0002 ;
HiddenSectors DW 0x00000000
LargeSectors DW 0x00000000
; Extended BPB_FAT16. Size=0x1A=26.
PhysicalDriveNumber DB 0x00 ; 0x00 floppy disk, 0x80 hard disk.
Reserved DB 0x00 ;
ExtBootSignature DB 0x29 ; Or 0x28.
VolumeSerialNumber DW 1212121 ; Randomly generated number.
VolumeLabel DB "NO NAME " ; Space-padded to size=11.
FileSystemType DB "FAT12 " ; Space-padded to size=8.
BPB_FAT16 ENDS ; Total BPB_FAT16. Size=0x33=51.
My program is showing two errors for only one line of code given below:
Bpb BPB_FAT16{}
and those two errors are:
error1: missing operator in expression error2: initializer magnitude too large for specified size
What should I do? Please guide me.
The error message missing operator in expression
is likely occurring on every line where you use 0x
prefix for hexadecimal values. MASM doesn't support that and it use the h
suffix to denote hexadecimal values.
The error initializer magnitude too large for specified size
is because the value 1212121
can't fit in the DW (16-bit WORD) you specified for VolumeSerialNumber
. VolumeSerialNumber
in a BPB needs to be a DD (32-bit DWORD).
Although it didn't generate an error, the fields HiddenSectors
and LargeSectors
in a BPB are a 32-bit DWORD so they should be using the type DD
instead of DW
.
Your structure could have been defined as:
BPB_FAT16 STRUCT ; Base BPB_FAT16. Size=0x19=25.
BytesPerSector DW 200h ; Size of HW sector, usualy 512.
SectorsPerCluster DB 1h ; Valid values 1,2,4,8,16,32,64,128.
ReservedSectors DW 1h ; NrOfSectors preceding FAT.
NumberOfFats DB 2h ;
RootEntries DW 0E0h ; Max number of YWORD entries in the
; root dir.
SmallSectors DW 0B40h ; See also .LargeSectors.
MediaDescriptor DB 0F0h ; 0xF0 floppy disk, 0xF8 hard disk.
SectorsPerFat DW 9h ;
SectorsPerTrack DW 12h ;
NumberOfHeads DW 2h ;
HiddenSectors DD 0h
LargeSectors DD 0h
; Extended BPB_FAT16. Size=0x1A=26.
PhysicalDriveNumber DB 0h ; 0x00 floppy disk, 0x80 hard disk.
Reserved DB 0h ;
ExtBootSignature DB 29h ; Or 0x28.
VolumeSerialNumber DD 1212121 ; Randomly generated number.
VolumeLabel DB "NO NAME " ; Space-padded to size=11.
FileSystemType DB "FAT12 " ; Space-padded to size=8.
BPB_FAT16 ENDS ; Total BPB_FAT16. Size=0x33=51.
With these changes your structure is now exactly 51 bytes which is what you'd expect for a FAT16 DOS 4.0 EBPB.
User contributions licensed under CC BY-SA 3.0