Declaring Arrays In x86 Assembly
The AT&T syntax is used by the GNU assembler. The directive you're looking for is .fill <count>\[, <data-size>\[, <value>\]\]
. In the specific case of 400 bytes:
array: .fill 400
data-size
defaults to 1
(byte). I believe the value
that fills the 400 bytes defaults to zero.
If you are actually using the
nasm
assembler (which is Intel format, not AT&T), then the times
directive will work, as avinash indicated, as long as you want to predefine the data in either the .text
or .data
section. However, if you need to reserve bytes in the .bss
section (in nasm
), you can use the resb
(reserve byte) directive:
setion .bss
...
arr1 resb 400 ; Reserve 400 bytes (uninitialized)
arr2 times 400 resb 1 ; Same thing, using times
Did you try TIMES directive
.Use this code for declaring an array of a given size.
array TIMES 8 DB 0
This will create an array of size 8
Refer to this link for more.