Reputation: 5691
I have started to learn assembly. I came across these lines.
;*************************************************;
; OEM Parameter block / BIOS Parameter Block
;*************************************************;
TIMES 0Bh-$+start DB 0
bpbBytesPerSector: DW 512
bpbSectorsPerCluster: DB 1
bpbReservedSectors: DW 1
I am confused on the first line of declaration "bpbBytesPerSector: DW 512" . Here I think DW is define word. So DW 512 means defining 512 words means 1024 bytes. Now the label is "bpbBytesPerSector". Bytes per sector should be 512(this is what I think). Similarly I can't understand next two lines. I am totally confused on this. Can anybody explain me.Thanks in advance.
Upvotes: 3
Views: 466
Reputation: 490623
As @paxdiablo already pointed out, the number is just the value for the word. When/if you want to define an array of 512 words like you described, you'd use something like:
myarray dw 512 dup(?)
Here the 512
is the number of repetitions, and the ?
is the value to be put in each ("?" means "leave it uninitialized", but you can specify a value if you prefer).
Upvotes: 0
Reputation: 882426
No, dw
means define the single word 512. That means allocate space for one word here and set the value to 512.
This is creating a BIOS parameter block (BPB) and breaking it down:
0000 TIMES 0Bh-$+start DB 0 ; allocate 11 zero bytes.
000B bpbBytesPerSector: DW 512 ; define one word 512
000D bpbSectorsPerCluster: DB 1 ; define one byte 1
000E bpbReservedSectors: DW 1 ; define one word 1
0010
Upvotes: 6