As being a dynamic data structure, it should be allowed to create a empty array
Semi-dynamic, maybe. Example from hlhelp.chm:
LOCAL hArray :DWORD
......
mov hArray, arralloc$(2048)
......
mov hArray, arrealloc$(hArray,4096)Slightly more dynamic:
include \masm32\MasmBasic\MasmBasic.inc ; download
Init ; ## create a dynamic string array ##
Dim My$()
xor ecx, ecx
.Repeat
Let My$(ecx)=Str$("String %i", ecx)
inc ecx
.Until ecx>=20000
Inkey "ok"
Exit
end startBut in both cases, a "true" empty array makes little sense. You wouldn't create it if you didn't want to use it, right?
P.S.: Your version is better than mine. I had not thought of accessing memory from bottom to top. I wonder, however, if the direction really matters. Testbed? ;)
Here it is:
Intel(R) Celeron(R) M CPU 420 @ 1.60GHz (SSE3)
9947 kCycles for 5 * down
10274 kCycles for 5 * up
10205 kCycles for 5 * down
10284 kCycles for 5 * up
10155 kCycles for 5 * down
10212 kCycles for 5 * up
35 bytes for down
38 bytes for up