I write a macro and want to determine whether the parameter is integer type. Could anyone help me how to do the checking code? My first thought is to use OPATTR but i don't quite familiar with this macro and some terms in masm help. For example: "immediate expression", "direct memory addressing", "SS-relative memory expression" etc.

Thanks
Posted on 2003-01-07 03:27:45 by yoursguideline
I think you need bit 2 to be set in the OPATTR flag, which indicates the argument is an immediate value.

Thomas
Posted on 2003-01-08 13:25:38 by Thomas
i write a sample macro with bit 2 set in OPATTR:


abcabc MACRO a:REQ
IF (OPATTR(a)) AND 00100000y
echo i
ENDIF
ENDM


Both
abcabc eax
abcabc 2
will print out a i character. Obviously the eax is not an integer type. Any ideas?
Posted on 2003-01-08 22:29:20 by yoursguideline
You can use the "TYPE" operator. Ths should work for any arg.



mymac macro arg
if (TYPE arg) eq (TYPE dword)
...
endif
endm
Posted on 2003-01-09 01:29:17 by gfalen
Thanks gfalen . It works great.
Posted on 2003-01-09 02:24:25 by yoursguideline
Originally posted by yoursguideline
00100000y

That isn't bit 2 :)

This is bit 2:
00000100b


Thomas
Posted on 2003-01-09 02:24:45 by Thomas
What's the difference between "y" and "b" after a sequence of bits?

Regards.
Posted on 2003-01-09 02:30:33 by yoursguideline
To determine whether param is immediate or not i use this macro.
$IsImm MACRO Operand:REQ

IF (OPATTR (Operand)) AND 00000100y
;; Is an immediate value
EXITM <-1>
ELSE
EXITM <0>
ENDIF
ENDM
But there is no way to determine whether the parameter is integer type or not.

What's the difference between "y" and "b" after a sequence of bits?

"Binary: y. e.g. 1010y, or b if the radix is not hexadecimal. e.g. .radix 10 1010b.
The default Radix is decimal."
Posted on 2003-01-09 05:28:05 by Four-F