flat assembler
Message board for the users of flat assembler.

Index > Windows > variables?

Author
Thread Post new topic Reply to topic
calpol2004



Joined: 16 Dec 2004
Posts: 110
calpol2004 03 Jan 2006, 15:12
if i create a C program i can declare hundreds of variables some of which could contain a large bitmap (i just declare them i dontt actually put data into them) and the size of the executable would not be affected. however if i declare a "label" as it is so called in asm and i dont even put data into it the size of the excutable is affected. e.g. if i have a empty program that just declares label which is say 2000 bytes in size, the size of the executable is increased. shouldn't the amount of RAM the applications uses be affected instead of the amount of space the executable takes up? there must be a way to stop this from happening and ill probably sound stupid if there is Razz .
Post 03 Jan 2006, 15:12
View user's profile Send private message MSN Messenger Reply with quote
r22



Joined: 27 Dec 2004
Posts: 805
r22 03 Jan 2006, 19:53
There are different ways of declaring data.
In your data section if you use dd 0 then that is taking up space whether you use it or not. If you use rd 1 it reserves the space for 1 dword.

What your thinking about in C, when you declare a variable it's being created on the stack of the function you dclared it in OR your using memory allocation api's (ie HeapAlloc) to create space in virtual memory for the large variables.

Look into the VirtualAllocate api if you want to store data but not in your data section.
Post 03 Jan 2006, 19:53
View user's profile Send private message AIM Address Yahoo Messenger Reply with quote
Reverend



Joined: 24 Aug 2004
Posts: 408
Location: Poland
Reverend 04 Jan 2006, 00:59
Variables in C are defined exactly the same way as locals in fasm. Try compiling the same code in C but give 'static' before data definition ie. instead of 'int a;' write 'static int a;' and you'll see the file also got bigger
Post 04 Jan 2006, 00:59
View user's profile Send private message Visit poster's website Reply with quote
calpol2004



Joined: 16 Dec 2004
Posts: 110
calpol2004 04 Jan 2006, 14:09
thanks for the info.... nothing is ever simple Shocked
Post 04 Jan 2006, 14:09
View user's profile Send private message MSN Messenger Reply with quote
Borsuc



Joined: 29 Dec 2005
Posts: 2465
Location: Bucharest, Romania
Borsuc 04 Jan 2006, 14:17
If you want small executable, but need a .data buffer, use rb 2000, to reserve bytes, like r22 said.
Post 04 Jan 2006, 14:17
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-2025, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.