Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Macros in x86 assembly coding

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

like image 387
user106300 Avatar asked Sep 05 '25 03:09

user106300


1 Answers

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
like image 120
Dead account Avatar answered Sep 07 '25 21:09

Dead account