X86 assembly macros

Can someone please explain how to use macros in x86 assembly encoding

+1


a source to share


2 answers


It depends on what you are using.

Typically, an assembler macro takes the following form:

begin MyMacro %1, %2
   mov eax, %1
   add eax, %2
end

      

This will exist in the header section of the source code and will not output any code if not referenced. You would type this with a different assembler.



mov ecx, 88
MyMacro ecx, 12
asr ecx, 3

      

The "parameters"% 1 and% 2 in this case will be replaced with ecx and 12, generating the following output

mov ecx, 88
mov eax, ecx
add eax, 12
asr ecx, 3

      

+7


a source


This is a very broad question. There are several ways to use macros. Some assembly language developers use tons of them, some hate them.



One of the most common ways is to use macros for function prologues and epilogues. Another is to use them to select options for saving to the stack.

0


a source







All Articles