How it works

The logic behind macro instructions is quite simple. The preprocessor parses the code for the definitions of macro instructions and stores them, simply speaking, in the form of a dictionary, where the name of the macro instruction is the key and its content is the value. Of course, in reality, it is more complicated, as macro instructions may have (and most of the time, they do have) parameters, not to mention the fact that they may also be variadic (have an undefined number of parameters).

When the assembler processes the code and encounters unknown instructions, it checks this dictionary for a macro instruction with the corresponding name. Once such an entry is found, the assembler replaces the macro instruction with its value--expands macro. Consider that the assembler sees the following:

load_4 xmm3, dpy

Then, it refers to the collected macro instruction definitions and replaces this line with the actual code:

movd xmm3, [dpy]
movlhps xmm3, xmm3
movsldup xmm3, xmm3

If the assembler finds no relevant macro definition, we are notified of this via the error reporting mechanism.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset