News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Dynamic array? or how to create array at runtime

Started by cobold, May 23, 2008, 08:39:25 PM

Previous topic - Next topic

cobold

Hello,

is there a way to create an array dynamically or at runtime in Assembler? The only way I know so far creates static arrays only:
f.ex.

.data
SomeArray DWORD NbrOfElements dup(?)


This is the only method I know and it was fine so far. But NbrOfElements must be a constant value, so you end up with fixed sized, static arrays. Now it would be fine to have a bit more flexibility. (I know there's a function to allocate memory at runtime, but how do you tell the assembler: "use this memory for SomeArray"?)
What I want to do is either:
-  predefine SomeArray with let's say 1000 Elements, and then depending on user-input I want to resize the Array (make it smaller or larger)
or
- don't define the array in advance, but after user-input I want to calculate the size I need at runtime, allocate the required memory and assign this memory to SomeArray.

Any hints how to do this?
Thanks in advance!

cobold

jj2007

Hutch has started at least dedicated two dedicated threads, try this and that.

hutch--

I have got the new system finished, it needed to be faster in a few places than the prototypes I had tried out but the problem is I now have it as part of the masm32 library for version 10 and have the help file more or less done for it but the new version is not ready yet for posting.

The prototype system worked OK but the original array allocation was slower than it needed to be through allocating an empty array member where the new version uses a single fixed null length string for empty strings that made it both faster and used less memory.

If you used the old system with its macro interface the new system is compatible but the new system has both a macro and procedure interface and is structured a bit differently so you could not use the old system as procedures and then use the new system on top of it.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php