Is there a way to have GNU as only expand .macro directives in a .S file, producing another .S file without them? Similiar to what gcc -E does with C code.
Note this is about the assembler .macro directive like in the following code, not about C-style #define macros which can be expanded via cpp.
.macro my_macro src, so, dest
movl \so+10(\src), %r8d
The assembler directives are used to tell the assembler to do something. For instance: Defining a symbol, change sections, repeat code, change the location counter, etc. The . macro directive defines the start of a new macro, the name of the macro and the macro arguments.
This directive terminates expansion of a macro body and passes control to the nearest . ENDM. Write this directive in the body of a macro definition. This directive declares that the label specified as an operand is a macro local label.
Directives are instructions used by the assembler to help automate the assembly process and to improve program readability. Examples of common assembler directives are ORG (origin), EQU (equate), and DS. B (define space for a byte).
The -E option causes gcc to run the preprocessor, display the expanded output, and then exit without compiling the resulting source code. The value of the macro TEST is substituted directly into the output, producing the sequence of characters const char str[] = "Hello, World!" ; .
GNU as's preprocessor doesn't handle .include
and .macro
, as everything starting with a dot is in fact an assembler directive; thus, macro expansion is performed along program assembly, and cannot be done separately, at least by as.
You have these options:
C-style macro processing is performed by default when you use the .S
(capital s) extension for assembly files you use to feed gas, and the C preprocessor can be also invoked standalone with command cpp
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With