Copyright (C) 2000-2012 |
GNU Info (nasm.info)Section 4.1.24.1.2. Enhancing %define: `%xdefine' ------------------------------------ To have a reference to an embedded single-line macro resolved at the time that it is embedded, as opposed to when the calling macro is expanded, you need a different mechanism to the one offered by `%define'. The solution is to use `%xdefine', or it's case-insensitive counterpart `%xidefine'. Suppose you have the following code: %define isTrue 1 %define isFalse isTrue %define isTrue 0 val1: db isFalse %define isTrue 1 val2: db isFalse In this case, `val1' is equal to 0, and `val2' is equal to 1. This is because, when a single-line macro is defined using `%define', it is expanded only when it is called. As `isFalse' expands to `isTrue', the expansion will be the current value of `isTrue'. The first time it is called that is 0, and the second time it is 1. If you wanted `isFalse' to expand to the value assigned to the embedded macro `isTrue' at the time that `isFalse' was defined, you need to change the above code to use `%xdefine'. %xdefine isTrue 1 %xdefine isFalse isTrue %xdefine isTrue 0 val1: db isFalse %xdefine isTrue 1 val2: db isFalse Now, each time that `isFalse' is called, it expands to 1, as that is what the embedded macro `isTrue' expanded to at the time that `isFalse' was defined. automatically generated by info2www version 1.2.2.9 |