Вопрос

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

?

Это было полезно?

Решение

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

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top