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?
Posted on 2000-12-26 19:02:00 by Ernie
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
Posted on 2000-12-27 20:13:00 by 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.
Posted on 2000-12-27 23:36:00 by Ernie
MACRO_uses_edx MACRO varList:VARARG LOCAL x IRP x, IF ((OPATTR(&x)) AND 10h) IFIDN <&x>, .err ELSE echo accepting CPU register &x... ENDIF ELSE echo accepting not-register-type VAR &x... ENDIF ENDM ENDM in source: .CODE MACRO_uses_edx eax,edx,ecx,YourVar1 Cya
Posted on 2000-12-28 14:06:00 by AndyCar
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 IFIDNI <&arg>, .ERR ENDIF ENDM istatement CATSTR , <_>,<&Function, pInterface> IFNB ;; add the list of parameter arguments if any istatement CATSTR istatement, <, >, <&args> ENDIF mov edx, pInterface mov edx, istatement ENDM 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.
Posted on 2000-12-29 14:27:00 by Ernie