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

让人想犯罪 __ 提交于 2020-01-30 06:08:28

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/33175248/is-there-a-difference-between-equals-sign-assignment-x-1-and-equ-x-1-or

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!