The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: brixton on June 13, 2005, 07:54:01 AM

Title: Question about declarations
Post by: brixton on June 13, 2005, 07:54:01 AM
When I see these variables being declared in a Proc, I wonder how they would be declared if they weren't in a proc.

For example,

      LOCAL wc   :WNDCLASSEX
      LOCAL msg  :MSG
      LOCAL Wwd  :DWORD


How can you declare a MSG structure in the .data or .data? section, or how do you declare a variable of type WNDCLASSEX?

I don't understand, thanks for any help  :red
Title: Re: Question about declarations
Post by: Jeff on June 13, 2005, 08:25:43 AM
quite simply:
.DATA
wc WNDCLASSEX <>
msg MSG <>


when initializing structures, you need to use angle brackets.  when you leave the brackets alone, the structure will take the default values for that structure.  otherwise, you can pass in the values for each field.  so for instance, if you wanted a COORD structure with X = 2 and Y = 3:
.DATA
pt COORD <2,3>

(remember, order matters)
Title: Re: Question about declarations
Post by: thomas_remkus on June 13, 2005, 09:50:14 PM
Is the ordinal placement of array members between your &gt; and &lt; directly related to the way that it is written in the .inc or declared location?

thomas
Title: Re: Question about declarations
Post by: RuiLoureiro on June 13, 2005, 10:13:59 PM
Hi brixton
             These structures (and many others) are defined in windows.inc ( if not wrong )
WNDCLASSEX
 MSG


So, you can use it to define variables in .data or .data? section like the exmple from Jeff
or in the stack with LOCAL

Does it help ?
Rui
Title: Re: Question about declarations
Post by: MichaelW on June 13, 2005, 10:55:23 PM
Thomas,

If I understand your question correctly, the answer is yes. See Structures and Unions here:

http://webster.cs.ucr.edu/Page_TechDocs/MASMDoc/ProgrammersGuide/Chap_05.htm

Title: Re: Question about declarations
Post by: brixton on June 14, 2005, 09:33:34 AM
Many thanks for the help, yet again  :U

Now I will practise using STRUCTs  :green
Title: Re: Question about declarations
Post by: thomas_remkus on June 14, 2005, 02:20:27 PM
MichaelW,

You did a great job understanding what I was asking. Phew! Thanks, that did answer my question perfectly ... and I have another help reference too! Thanks for that!!

I now understand that MASM like C, the ordinal positions of structured variables plays an important part in initializing them. I also now understand more about C.

thomas