I have a problem:
I can't do this
;===========================================
LOCAL a:DWORD
.if a="mystring"
invoke MessageBox,hWin,ADDR TextMsg,ADDR TextMsg,MB_OK
.endif
;===========================================
But, I can do this:
;===========================================
LOCAL a:DWORD
switch$ ADDR a
case$ "mystring"
invoke MessageBox,hWin,ADDR TextMsg,ADDR TextMsg,MB_OK
endsw$
;===========================================
can we modify if statement like case statement?
How to do it?
Thank you
Fritz
Hi
Your "a" is a dword and is 4 bytes
and you sting is more as 4 bytes
lea eax ,a
;the first 4 bytes
.if DWORD PTR [eax]=="tsym" ;the 4 bytes of a dword and backward "myst"
.if DWORD PTR [eax+4]=="gnir";the next 4 bytes of a dword backward "ring"
;mystring if correct
.endif
.endif
Byte == 1 byte
Word == 2 byte
Dword== 4 bytes long
...
.
see in the masm32 package for mor help
Or your compare with lstrcmp api
Greets
Fritz,
The .IF notation in MASM is for comparing integers, not string characters. The macros in "switch$" actually call a string comparison algorithm that compares the two strings.
If you wanted to use .IF notation you would need to run a string compare algo then feed its result through an .IF block.
Hi Hutch
This compare a string or not only backward or not?
.if DWORD PTR [eax]=="tsym" ;myst
ragdog,
You are actually doing an integer compare in your example as you can fit 4 ascii/ansi characters in a DWORD. MASM reads the characters backwards like their real memory order.