Macro replacing a constant number in GAS

What happened to this macro on the GNU X86 assembly? He says that the character S is undefined during binding.

.macro S size=40 \size .endm 

I use it as

 mov %eax, S 
+7
source share
1 answer

Macros are used to create patterns for code that you often use, and not to enter a constant number. Thus, I do not believe that assembler performs macro decomposition inside an expression. Since you just want a number, you can use .set to define a constant.

 .set S, 40 mov %eax, S 

Also, if you usually use intel syntax, make sure you understand what this code does: it currently stores the eax value in memory at 0x28. If you want to put the number 40 in eax, you need to cancel the operands and use the dollar sign in front of S.

 mov $S, %eax 
+16
source

All Articles