Search code examples
assemblygnu-assembler

Is there a difference between equals sign assignment "x = 1" and ".equ x, 1" or ".set x, 1" in GNU Gas assembly?


E.g.:

a = 1

and:

.equ a, 1

and:

.set a, 1

all produce the same output byte-by-byte upon:

as --32 main.S

according to cmp.

I know that .equ and .set do the same thing according to the documentation of .equ: https://sourceware.org/binutils/docs-2.25/as/Equ.html :

It is synonymous with `.set'.

and I know what .equ does from Difference between .equ and .word in ARM Assembly?

So what about =? Is it the same as the other two?


Solution

  • It is the same.

    After grepping the documentation source, I've found the section that confirms it https://sourceware.org/binutils/docs-2.25/as/Setting-Symbols.html

    A symbol can be given an arbitrary value by writing a symbol, followed by an equals sign `=', followed by an expression (see Expressions). This is equivalent to using the .set directive.