I have a macro that takes an arbitrary number of parameters (VARARG). I need to test if any of these parameters happens to be register edx, I need it to hard fail the assembly. Anyone have any ideas?
Why do you need to know if one of the arguments of the macro is edx ? If it's solely beacuse you need the value contained in the register, why not just pushing it before macro code then pop it at the end ? Maybe your needs are different and deeper... Why not to store edx value (or register values) in memory before macro and than compare edx value (or register values) during macro with the saved one(s) in order to understand if they are changed ? I think I am far away from the solution... Bye, Saiwa
The macro uses edx itself. It moves a value into edx, pushes all the other params, then it pushes edx last onto the stack. Curently, should the macro be given edx as a parameter, it will be overwitten by the macro, producing incorrect results. To make the a bit more bullit proof, it would be far easier to track down a compile error ("STOP using edx YOU FOOL") then a runtime bad data ("ummm, gee, I wonder why it did that?") error. Storing the value BEFORE the macro defeats the purpose of the macro: to encapulate some tricky inline code.
MACRO_uses_edx MACRO varList:VARARG LOCAL x IRP x,
IF ((OPATTR(&x)) AND 10h)
echo accepting CPU register &x...
echo accepting not-register-type VAR &x...
Thanks Andy, gave me a nudge in the correct direction. Here's the final version: coinvoke MACRO pInterface:REQ, Interface:REQ, Function:REQ, args:VARARG LOCAL istatement, arg FOR arg,
;; run thru args to see
;; if edx is lurking in there
istatement CATSTR ,
IFNB ;; add the list of parameter arguments if any
istatement CATSTR istatement, <, >, <&args>
mov edx, pInterface
This macro will take a COM interface definition structure and perform calls on it. Interface methods are 'decorated' with the interface name and an underscore in the defining struct to allow for method polymorphism ( two interfaces with identicle method names).
Allowing edx to be used as a parameter would occasionally lead to obecure runtime errors, these are best caught at compile time.
Thanks to Andy and all.