flat assembler
Message board for the users of flat assembler.

Index > Windows > Alternative to rd?

Author
Thread Post new topic Reply to topic
bot



Joined: 06 Dec 2008
Posts: 3
bot
Newbie here, I want to allocate a very large amount of data at the beginning for a hash map, about 4 megabytes, however with:

Code:
HashSpace rd 1048576    


The exe file rises by 4 megabytes as well, this isn't desirable. What is the more reasonable way of doing this?
Post 06 Dec 2008, 06:39
View user's profile Send private message Reply with quote
DOS386



Joined: 08 Dec 2006
Posts: 1901
DOS386
bot wrote:
Code:
HashSpace rd 1048576    
The exe file rises by 4 megabytes as well, this isn't desirable. What is the more reasonable way of doing this?


Depends from EXE type and OS. Put it into EXE's reserved area (AKA "B.S.S." Laughing ) or hog the memory with appropriate allocation features of the OS.
Post 06 Dec 2008, 07:25
View user's profile Send private message Reply with quote
ManOfSteel



Joined: 02 Feb 2005
Posts: 1154
ManOfSteel
If this is for Windows, use one of the following APIs: GlobalAlloc, HeapAlloc, LocalAlloc, VirtualAlloc.
And the thread should be moved to the Windows forum.
Post 06 Dec 2008, 11:29
View user's profile Send private message Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4633
Location: Argentina
LocoDelAssembly
If it is really Windows (in which case I'll move this to the Windows forum), then what you did is correct already, BUT you must make sure that "HashSpace rd 1048576" is the last thing in the source or PE section, if it is not then depending on whether the next lines of code define initialized data (or CPU instructions) or uninitialized data on the section the "rd 1048576" will act as "dd 1048576 dup (0)" or "rd 1048576" respectively.
Post 06 Dec 2008, 14:19
View user's profile Send private message Reply with quote
bot



Joined: 06 Dec 2008
Posts: 3
bot
I had moved it around and found that the big file size problem was magically solved but not understood why, thanks for your explanation Loco.
Post 06 Dec 2008, 19:19
View user's profile Send private message Reply with quote
baldr



Joined: 19 Mar 2008
Posts: 1651
baldr
bot,

No magic here, addition of uninitialized bytes in the PE section does increase VirtualSize but not necessarily increase SizeOfRawData for that section, hence file size (increase can occur when the section has initialized bytes somewhere after the aforementioned uninitialized bytes, as LocoDelAssembly mentioned).
Post 07 Dec 2008, 13:12
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar.

Powered by rwasa.