News:

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

Iczelion tut 7 help !!!

Started by EnFeR RoI, February 12, 2010, 04:43:29 PM

Previous topic - Next topic

EnFeR RoI

Hello everyone!!

mov eax,lParam
        and eax,0FFFFh
        mov hitpoint.x,eax
        mov eax,lParam
        shr eax,16
        mov hitpoint.y,eax


Can you explain clearly this frustrating code :red???
This make me a lot of confusion??? :(


Hope you help me!!!
EnFeR RoI.

Slugsnack

mov eax,lParam        ; moves lParam into eax
and eax,0FFFFh        ; zeroes the top half of eax. that constant is essentially 0x0000FFFF and and'ing with 0 results in 0
mov hitpoint.x,eax    ; move eax into the x member of the hitpoint structure
mov eax,lParam        ; moves lParam into eax
shr eax,16               ; shift right by 16 bits will move the upper word of eax into the lower word, ie. ax. the bits that are shifted in are 0
mov hitpoint.y,eax    ; this value is then moved into the y member of the hitpoint structure

it appears the top half of lParam contains the y value and bottom half contains x value

EnFeR RoI

but when we shift then what happens???

EnFeR RoI

where is dedndave and MichaelW :bg

Waiting for your reply!!
EnFeR RoI.

jj2007

Quote from: EnFeR RoI on February 12, 2010, 04:58:20 PM
but when we shift then what happens???


\masm32\help\opcodes.chm is a good start. Or reading what Slugsnack typed for you.

This code is equivalent:
movzx eax, word ptr lParam        ; moves the loword of lParam into eax
mov hitpoint.x,eax    ; move eax into the x member of the hitpoint structure
movzx eax, word ptr lParam+2        ; moves the hiword of lParam into eax
mov hitpoint.y,eax    ; move eax into the x member of the hitpoint structure

EnFeR RoI


MichaelW


For the WM_LBUTTONDOWN message the low-order WORD of lParam specifies the x-coordinate of the cursor and the high-order WORD the y-coordinate of the cursor. For the POINT structure:

POINT STRUCT
  x  DWORD ?
  y  DWORD ?
POINT ENDS

The coordinates are DWORDs. The code is extracting the coordinate values from lParam and copying them to the POINT structure.
eschew obfuscation