Copyright (C) 2000-2012 |
GNU Info (nasm.info)Section 4.3.84.3.8. Condition Codes as Macro Parameters ------------------------------------------ NASM can give special treatment to a macro parameter which contains a condition code. For a start, you can refer to the macro parameter `%1' by means of the alternative syntax `%+1', which informs NASM that this macro parameter is supposed to contain a condition code, and will cause the preprocessor to report an error message if the macro is called with a parameter which is _not_ a valid condition code. Far more usefully, though, you can refer to the macro parameter by means of `%-1', which NASM will expand as the _inverse_ condition code. So the `retz' macro defined in *Note Section 4.3.2:: can be replaced by a general conditional-return macro like this: %macro retc 1 j%-1 %%skip ret %%skip: %endmacro This macro can now be invoked using calls like `retc ne', which will cause the conditional-jump instruction in the macro expansion to come out as `JE', or `retc po' which will make the jump a `JPE'. The `%+1' macro-parameter reference is quite happy to interpret the arguments `CXZ' and `ECXZ' as valid condition codes; however, `%-1' will report an error if passed either of these, because no inverse condition code exists. automatically generated by info2www version 1.2.2.9 |