News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Problems w/DragDetect

Started by NoCforMe, October 04, 2011, 06:08:43 AM

Previous topic - Next topic

NoCforMe

Yes; here's what happens 'behind the scenes" (I find it very useful to actually look all the assembler-generated stuff, using the /Fl /Sg options). I created a dummy function "xxx" that takes a POINT as its argument:


xxx proto :POINT

invoke xxx, pt
000002D3  FF 75 FC    *     push   dword  ptr ss:[ebp]+0FFFFFFFCh
000002D6  FF 75 F8    *     push   dword  ptr ss:[ebp]+0FFFFFFF8h
000002D9  E8 00000000 E   *     call   xxx


which does exactly what you described.

If you thnk about it, this is just the kind of thing about assembly language that would drive any language purist (like C programmers!) nuts. This seems like the classic ill-defined behavior. Is this even documented anywhere? I haven't seen anything covering this in the MASM manual, f'rinstance.

Anyhow, we know it works, so I guess that's what counts, eh?

jj2007

Quote from: NoCforMe on October 04, 2011, 08:20:39 PM...the classic ill-defined behavior. Is this even documented anywhere?

Yes, somewhere here in the Forum :bg
Passing a structure is possible but rarely used. As your listing and Olly show, it takes a whopping 12 bytes to pass a global POINT (from my example above):
<ModuleEnt  .  FF35 04104000            push dword ptr [401004]
0040100E    .  FF35 00104000            push dword ptr [401000]


Most of the time you have the x & y points in registers anyway - and two push exx takes only two bytes.