user106300
user106300

Reputation: 43

Macros in x86 assembly coding

Can somebody please explain how to use macros in x86 assembly coding

Upvotes: 4

Views: 10841

Answers (2)

Foredecker
Foredecker

Reputation: 7491

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.

Upvotes: 0

Dead account
Dead account

Reputation: 19960

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

Upvotes: 6

Related Questions