xor  eax, eax
mov  eax, GET_WM_COMMAND_CMD(wParam, lParam)


This generates an error at assembly time:


error A2026: constant expected


The macro is:


GET_WM_COMMAND_CMD macro wp,lp
exitm <HIWORD ( wp ) >
endm


I don't see the problem.  Does anybody else?
Posted on 2007-06-26 12:46:35 by rdaneel
I don't see the problem.  Does anybody else?

the HIWORD macro is to primitive and only accepts constants. (can you post it?)
you cant encode instruction with
mov eax,WORD PTR wParam;; not possible
but you can use movzx or movsx

movzx eax,word ptr wParam[0]
movzx edx,word ptr wParam[2]


;; more advanced hiword macro
HIWORD macro l:req
if ( ( (.TYPE (l)) SHR 1 ) AND 1);; Mem
movzx edx,WORD PTR (l) +2
exitm <edx>
elseif ( ( (.TYPE (l)) SHR 4 ) AND 1);; Reg
mov edx,(l)
shr edx,16
exitm <edx>
else;; Imm
exitm <((l) SHR 16)>
endif
endm
Posted on 2007-06-26 15:06:27 by drizz
That makes sense about the WORD value thing.  I should have known that, but that leaves a mystery as to how:


xor  ecx, ecx
mov  ecx, GET_WM_COMMAND_ID(wParam, lParam)


produces no error.  Unless LOWORD zero fills it and passes back a DWORD.  I know nothing about macros.
Posted on 2007-06-26 15:36:03 by rdaneel

That makes sense about the WORD value thing.  I should have known that, but that leaves a mystery as to how:


xor   ecx, ecx
mov   ecx, GET_WM_COMMAND_ID(wParam, lParam)


produces no error.  Unless LOWORD zero fills it and passes back a DWORD.  I know nothing about macros.

again, can you post the macros > HIWORD, LOWORD < ?

here are mine - final version.

HIWORD macro l:req,usereg
LOCAL treg
treg textequ <eax>
ifnb <usereg>
treg textequ <usereg>
endif
if ( ( (.TYPE (l)) SHR 1 ) AND 1)
movzx treg,WORD PTR (l) +2
exitm <treg>
elseif ( ( (.TYPE (l)) SHR 4 ) AND 1)
mov treg,(l)
shr treg,16
exitm <treg>
else
exitm <((l) SHR 16)>
endif
endm

LOWORD macro l:req,usereg
LOCAL treg
treg textequ <eax>
ifnb <usereg>
treg textequ <usereg>
endif
if ( ( (.TYPE (l)) SHR 1 ) AND 1)
movzx treg,WORD PTR (l)
exitm <treg>
elseif ( ( (.TYPE (l)) SHR 4 ) AND 1)
mov treg,(l)
and treg,0FFFFh
exitm <treg>
else
exitm <((l) AND 0FFFFh)>
endif
endm

;; so you can do something like this
.if HIWORD(wParam,edx) == BN_CLICKED && LOWORD(wParam,eax) == IDC_BTN1
mov ecx,HIWORD( 0BADC0DEh )
mov ecx,LOWORD( 0BADC0DEh )
mov ecx,LOWORD( lParam )
mov ecx,LOWORD( esp )
mov ecx,HIWORD( esp )
.endif


Posted on 2007-06-26 15:52:58 by drizz
Sorry about that.  Here are the macros:


LOWORD macro l
exitm <( ( l ) ) >
endm
HIWORD macro l
exitm <( ( ( ( l )  shr  16 )  and  0FFFFh ) ) >
endm
Posted on 2007-06-26 16:30:18 by rdaneel
ah yes, the direct translation of c++ defines/macros most of the time does not work.
you can safely replace them with the macros i posted in my previous post. it should work then.
Posted on 2007-06-27 05:17:41 by drizz
Your macros worked great.  Thanks drizz.
Posted on 2007-06-27 09:56:19 by rdaneel
Sweet Macro - Thanks drizz.
Posted on 2007-06-27 10:18:41 by JimmyClif