Question

I'm studying x86 assembly, and I've come across this declaration:

array1 DB 5 DUP(2 DUP('*'))

What does this declaration do?

  1. Allocates space for an array called array1, with size DB * 5 * 2 = 10, and 10 * elements.

  2. Allocates space for an array called ærray1, with size DB * 5 and 5 ** elements. This would mean that 5 * elements get discarded.

  3. 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] = {{'*', '*'}, {'*', '*'}, {'*', '*'}, {'*', '*'}, {'*', '*'}}

?

Was it helpful?

Solution

According to the comments, the declaration allocates an array with 10 contiguous * character bytes in memory.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top