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?
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
That makes sense about the WORD value thing. I should have known that, but that leaves a mystery as to how:
produces no error. Unless LOWORD zero fills it and passes back a DWORD. I know nothing about macros.
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.
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
Sorry about that. Here are the macros:
LOWORD macro l
exitm <( ( l ) ) >
endm
HIWORD macro l
exitm <( ( ( ( l ) shr 16 ) and 0FFFFh ) ) >
endm
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.
you can safely replace them with the macros i posted in my previous post. it should work then.
Your macros worked great. Thanks drizz.
Sweet Macro - Thanks drizz.