Re: Structures in Assembly Language

From: f0dder (f0dder_spicedham_at_flork.dk)
Date: 08/19/04


Date: Thu, 19 Aug 2004 03:14:40 +0200

Betov wrote:
*snip*
>
> Notice that all of the Initializations of the Structure
> are done, on the Stack, AT RUN-TIME. Such Methods, and,
> most of all, their _generalizations_ (in some cases, this
> is accurate to do something similar to this...), would
> completely defeate any reason for programming Assembly:
> Such a Structure should, evidently, be declared in Data,
> as simple Data, and it should be initialized, for all the
> known Members, AT WRITE-TIME.
>
*snip*
Nothing stops you from using a pre-initalized structure in
masm, whether in data, code, const or elsewhere. The runtime-
filling is just an example of typical bad code... don't judge
a tool by the people that (mis)use it :). The annoying thing,
though, is that you need the line-continuation character ('\'),
otherwise masm will bitch.

wcMain WNDCLASSEX < \
 sizeof WNDCLASSEX, \ ; cbSize
 0, \ ; style
 ofs wndProc, \ ; lpfnWndProc
 0, \ ; cbClsExtra
 0, \ ; cbWndExtra
 0, \ ; hInstance - fixed up later
 NULL, \ ; hIcon
 NULL, \ ; hCursor
 NULL, \ ; hbrBackground - not needed
 NULL, \ ; lpszMenuName
 ofs szClassName,\ ; lpszClassName
 NULL \ ; hIconSm
>