News:

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

Declaring a variable of my_struc?

Started by Fortean Jo, September 13, 2005, 07:30:13 PM

Previous topic - Next topic

Fortean Jo

I'm writing a piece of code in Masm that uses a struc similar to this:

     my_struc     struc
          Field1      db 128 dup (?)
          FieldLen   dd ?
          Field2      db 128 dup (?)
          FieldLen   dd ?
     my_struc     ends


I then want to declare an unitiliased array with several thousand elements, each of type my_struc, so I'm using something like this:

     my_struc_array     my_struc     8192 dup (<>)

However, masm takes ages to actually assemble the file that declares this.  Without my_struc_array, the project is assembled in about 15 ms.  If I declare it, it can take about 20 mins.

The question is, then: Am I going about this the wrong way - I need the array but how should I declare it?

Phoenix

Fortean Jo,

if I'm not completly wrong you are trying to reserve 2,228,224 bytes = 2,176 KBytes = 2.125 MByte of memory......
Perhaps you should use LocalAlloc or similar for the required size of memory and work with ASSUME and pointers to access the data you need?

Just an idea, regards
Phoenix

tenkey

This is a known PERFORMANCE BUG in MASM when generating COFF object files.
You can either create the alternate OMF object file, or use dynamic memory allocation functions, such as HeapAlloc.
A programming language is low level when its programs require attention to the irrelevant.
Alan Perlis, Epigram #8

hutch--

Fortean Jo,

Its not a good tchnique for a couple of reasons, MASM is known to be very slow on large static arrays and similar data allocaions but with the resulting file with the array of structures in the uninitialised data section, the static memory demand is set at the size of the amount of static data you have set up. Any of the dynamic allocation APIS will do what you need.

It will depend on how you wish to access each structure but there is an array allocation procedure in the MASM32 library that will do what you are after if you need each sructure referenced by a pointer.

create_array proc acnt:DWORD,asize:DWORD

It returns the raw array address and the address of an array of pointers to each array element so you would just nominate the count you wanted and the size of each element. I think your structure is 264 bytes in length but make sure if you use it that each element in the allocated array is 4 byte aligned.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php