News:

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

Memory

Started by Empirelord, August 30, 2010, 08:22:57 PM

Previous topic - Next topic

Empirelord

I am writing a program, that should use around 50MB of Memory to store Byte Vars. At first, coming from C++, I tried to make use of an uninitialised array of that size in the .data? section. It worked just fine, but took hours to compile. So I tried virtualalloc. And that is the point, were I am now. I have this mass of uninitialised memory and dont know how I can get data in it. (Yes, probably an nooby question, but I am also doing assembler just since a few weeks)

redskull

The slow assembly with a large unitialized data section is most likely due to a bug in masm itself; I belive there are workarounds using ORG directive.  Otherwise, put brackets around value returned from VirtualAlloc().
-r
Strange women, lying in ponds, distributing swords, is no basis for a system of government

Rockoon

Use the COMM directive to avoid the terrible performance problem.

example:

.data?

COMM foo:byte:50000000
When C++ compilers can be coerced to emit rcl and rcr, I *might* consider using one.

cobold

or

invoke GlobalAlloc,GPTR,50000000 ; allocates 50MB - zero-initialzed
mov pArray,eax  ; points to array

;use ebx as index
;write to Array:
mov [pArray+ebx],yourbyte

;read from Array
movzx eax,[pArray+ebx]

;read next element from Byte-Array
inc ebx
movzx eax,[pArray+ebx]

Farabi

Using a buffer of big data on .data is not good, sometime it will bloat your software.
Better use the method posted above.
Those who had universe knowledges can control the world by a micro processor.
http://www.wix.com/farabio/firstpage

"Etos siperi elegi"

hutch--

Empirelord,

If you need 50 meg or more, allocate it in dynamic memory, the Windows API have a number of strategies depending on what you need. If you need global scope with the memory, put a DWORD variable as its pointer in the .DATA or .DATA? section so it has global scope.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

bomz

COMM foo:byte:50000000  - very interesting. thanks
Quote
.comm name, size,alignment

    The .comm directive allocates storage in the data section. The storage is referenced by the identifier name. Size is measured in bytes and must be a positive integer. Name cannot be predefined. Alignment is optional. If alignment is specified, the address of name is aligned to a multiple of alignment.

.It worked just fine, but took hours to compile.  - how long? and how GHz you processor?

Empirelord

Ok, I will try these solutions am I am sure it will work.
Thnaks to all of you for the fast and good help.

@bomz: I haven't exactly took the time, but it took longer to compile than me watching 1time trough Avatar. The CPU is a Q8200@3,2Ghz

bomz

1 mb about 20 minutes pentium 2.3 Ghz

mineiro

I don't have tested how to solve this, but in "AoA book" says that you can do a downgrade of masm to MASM v6.11, but this version, the autor says that cannot understand mmx.
50*1024*1024
regards and good luck Sr EmpireLord.

jj2007

You can use JWasm, it doesn't have that bug and is fully compatible.