Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Win32Asm question

Status
Not open for further replies.

AmkG

Programmer
May 12, 2001
366
0
0
PH
I'm currently trying to make head and tail of Win32Asm programming. Anyway one thing I noticed is that the Window Class Registration structure is almost always created and loaded from the .code section. Couldn't most of that data be initialized and placed in the .data section? Some data (such as hInstance) will still be loaded from the code space but most of the data is constant in each instance anyway...

Just wondering.
"Information has a tendency to be free. Which means someone will always tell you something you don't want to know."
 
Aparrently no one else here is doing Win32Asm... <sob> &quot;Information has a tendency to be free. Which means someone will always tell you something you don't want to know.&quot;
 
Yes it can & I do this all the time. If you're looking at the Iczelion tutes they're great but only take them as a starting point... your commonsense should guide thru the rest of the learning process. There is an old saw that goes &quot;Don't have code do the work of data & vice versa.&quot; It applies to assembler too. Having said all this tho, most of the window setup is execute once & then you're waiting for window$ to get done picking it's nose so this isn't the place to be looking for speed gains.
 
The reason that a compiler might put that structure in the code section is to make it read-only. Most win32 linkers make the code (.text) section read-only.

Some compilers put C strings in the code section for that reason.

Also, in a DLL, the code section is shared by all processes (with some exceptions), and a separate data section is created for each seperate instance of the DLL. Putting that structure in the code section would reduce the size of your data section, potentially saving a few KB per instance.

Doug Gale
 
It's being created DYNAMICALLY using a LOCAL directive. Which doesn't make sense because it still ends up in the stack, a portion of the data section. Might as well have placed it there in the first place.

Also, you need to load the instance variable into the structure, which means it can't be placed in a read-only section. Each instance is different for each instance, too... hmm, that seems kind of vague... &quot;Information has a tendency to be free. Which means someone will always tell you something you don't want to know.&quot;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top