According to the comments, the declaration allocates an array with 10 contiguous *
character bytes in memory.
x86 array declaration with multiple 'DUP' - what does it do?
-
10-10-2022 - |
题
I'm studying x86 assembly, and I've come across this declaration:
array1 DB 5 DUP(2 DUP('*'))
What does this declaration do?
Allocates space for an array called
array1
, with sizeDB * 5 * 2 = 10
, and 10*
elements.Allocates space for an array called
ærray1
, with sizeDB * 5
and 5**
elements. This would mean that 5*
elements get discarded.Allocates a multi-dimensional array called
array1
, with size[5][2]
and 5{'*', '*'}
elements.
So, is this declaration equivalent to
char array1[10] = {'*', '*', '*', '*', '*', '*', '*', '*', '*', '*'}
or is it equivalent to
char array1[5] = {'*', '*', '*', '*', '*', '*', '*', '*', '*', '*'}
?
Or maybe:
char array1[5][2] = {{'*', '*'}, {'*', '*'}, {'*', '*'}, {'*', '*'}, {'*', '*'}}
?
解决方案
不隶属于 StackOverflow