Can somebody please explain how to use macros in x86 assembly coding
+4
A:
It depends on what complier you are using.
Typically an assembler macro will take the following form;
begin MyMacro %1, %2
mov eax, %1
add eax, %2
end
This would exist in the header section of your source code and does not output any code unless it is referenced. You would inline this with the other assembler.
mov ecx, 88
MyMacro ecx, 12
asr ecx, 3
The "parameters" %1 and %2 in this case would be replaced with ecx and 12 generating the following output
mov ecx, 88
mov eax, ecx
add eax, 12
asr ecx, 3
Dead account
2009-05-13 13:35:54
thank u for the solution :)
2009-05-14 06:51:31
no problem, please mark as answer
Dead account
2009-05-14 07:50:52
Great Ian. Even a bad asked question deserves a good answer :)
jyzuz
2010-10-06 19:09:12
A:
That's a really broad question. There are a zillion ways to use Macros. Some assembly language developers use them tons, some hate them.
One of the most common ways is to use macros for function prologues and epilogues. Another is to use them for fetching saving parameters on the stack.
Foredecker
2009-05-13 13:37:25