Reputation: 387
a:.int 0
movl $0,a(%rip)
Is there a way to do something like #define b a(%rip)
such that every instance of b
will be replaced by a(%rip)
, so that movl $0,a(%rip)
could be abbreviated as movl $0,b
? I've tried both b=a(%rip)
and .macro b;a(%rip);.endm
but neither worked. Any help will be appreciated.
Upvotes: 1
Views: 262
Reputation: 92994
You can preprocess your file with the C preprocessor and then indeed use #define b a(%rip)
. To have the file preprocessed with the C preprocessor, use the file suffix .S
instead of .s
and assemble like this:
cc -c file.S
Note that a definition like this is very unusual and confusing to readers. Instead of trying to change assembler syntax that is confusing to you by the mean of macros, I recommend you to get familiar with the syntax and the reasons why you use a %rip
-relative addressing mode instead.
Upvotes: 2