Is there a way to define parametrized variables with DUP in x86 assembly?-Collection of common programming errors
Using x86 assembly, I need to define an array filled with incrementing values. Currently, I define it as an empty array and fill it at runtime by looping through it and setting a value I increment on each step. This looks something like this;
myArray DB 10 DUP (0)
...
xor ax, ax
xor bx, bx
mov cx, 10
initArray:
mov myArray[bx], ax
inc bx
add ax, 43
loop initArray
The increment value and the size of the array are both known before runtime, so I could do it by defining the values directly in the code, like this…
myArray DB 0, 43, 86, 129, ...
…but that would take a while, especially with long arrays.
Now for the question; I was wondering if there’s a way to create such an array in assembly, like parametrized macros in C? An equivalent to “#define myArray(x) (x*43)” if you will.