flat assembler
Message board for the users of flat assembler.

Index > Windows > To ? or not to ?....

Author
Thread Post new topic Reply to topic
StakFallT



Joined: 19 Jan 2006
Posts: 50
StakFallT 19 Jan 2006, 03:07
Ok this may have been asked before, so I appologize if it's been answered already.. I been working with FASM and MASM32 for about 3 months now, which is why I'm surprised the question for me is now just coming up, but it dawned on me... what in the world is the difference in declaring a variable of some type with ? or not using it? For example:

hwnd dd ? ; is pretty typical... but what about...
ps PAINTSTRUCT

Now I seem to remember certain things about the use of call (I think it was) that variables initialized on declaration get loaded into memory differently, and a call can jump backwards in memory but not forwards, and unintialized variables get loaded after the code and certain functions can't access them so you have to use another set of functions, but I think that might have been more of an MASM thing more so than anything... So is that really the only difference? If so is there any real main advantage or reason why I should choose one over the other?

-- StakFallT
Post 19 Jan 2006, 03:07
View user's profile Send private message Reply with quote
RedGhost



Joined: 18 May 2005
Posts: 443
Location: BC, Canada
RedGhost 19 Jan 2006, 05:23
? data should not be assigned to any value and should run the risk of being filled with garbage data(i believe)

but out of curiosity i went and tested, declaring data with ? just sets it to 0 from the tests i did, but it may run that garbage risk

_________________
redghost.ca
Post 19 Jan 2006, 05:23
View user's profile Send private message AIM Address MSN Messenger Reply with quote
Madis731



Joined: 25 Sep 2003
Posts: 2139
Location: Estonia
Madis731 19 Jan 2006, 09:54
That is true - ? usually gets defined as 0 but you can't count on it. Just to be sure always fill it yourself or if you NEED it to be ZERO, then:
Code:
times 512 db 0
    


ps PAINTSTRUCT is a structure that you must fill in yourself and you can't expect it to be 0 (although it might be Very Happy)

Offtopic: I've always wondered how to tell which is best:
1) rd 1
2) dd ?
Post 19 Jan 2006, 09:54
View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8351
Location: Kraków, Poland
Tomasz Grysztar 19 Jan 2006, 10:57
3) dd 1 dup ?
4) dd 1 dup (?)
Wink

When it happens that uninitialized data has to be anyway written into the file, it is filled with zeros - but you shouldn't rely even on this. If I changed it to put 90h or 0CCh bytes there, it still would be consistent with the presumptions.
Post 19 Jan 2006, 10:57
View user's profile Send private message Visit poster's website Reply with quote
StakFallT



Joined: 19 Jan 2006
Posts: 50
StakFallT 19 Jan 2006, 13:41
aaah ok that makes sense, thanks for replying guys Smile
Post 19 Jan 2006, 13:41
View user's profile Send private message Reply with quote
RedGhost



Joined: 18 May 2005
Posts: 443
Location: BC, Canada
RedGhost 20 Jan 2006, 02:14
Madis731 wrote:

1) rd 1
2) dd ?


Tomasz Grysztar wrote:

3) dd 1 dup ?
4) dd 1 dup (?)
Wink


im gonna have to go with madis here, i prefer the fasm syntax to the masm syntax (or tasm or whatever >_>)

_________________
redghost.ca
Post 20 Jan 2006, 02:14
View user's profile Send private message AIM Address MSN Messenger 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-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.