The Intel syntax has comments using the semicolon. When I switched to AT&T, it actually tried to interpret the comments.
What is the comment syntax for AT&T assembly?
armasm syntaxThe first semicolon on a line marks the beginning of a comment except where the semicolon appears inside a string literal. The end of the line is the end of the comment. A comment alone is a valid line.
The comment consists of the slash character (/) (ASCII 0x2F) followed by the text of the comment.
You access this command by right-clicking inside an open file in the Quartus II Text Editor, and then clicking Comment Selection.
CommentsEditA single semi-colon is used for comments, and functions the same as double slash in C++: the compiler ignores from the semicolon to the next newline.
The following are handled by as
directly. (Not the C preprocessor.)
#
Comments - Works as a "rest of line" comment.
Important Caveat: #
is also the GCC preprocessor directive symbol. The preprocessor runs first, so this means that if you are running it,
# include comments in your code to get full credit
at the beginning of the line (whitespaces don't count) will give you error: #include expects "FILENAME" or <FILENAME>
with gcc, even with a space after the #
.
However, these are case-sensitive, so capitalizing # Include
actually works:
# Include comments in your code to get full credit
While it is generally good practice to capitalize the first letter of your comments anyway, you can use ##
as a just-in-case measure. (Just don't use it on any lines that are part of a #define
macro because ##
is also the token pasting operator.)
/
comments - Start of line comment
These may only be used at the start of a line (after whitespace removal).
/ This is OK
xor %eax, %eax / This is *not* ok
These work if the C preprocessor is run on the source file.
In most architectures, the following are supported:
// Rest of line comment
works pretty much as you'd expect from C.
In rare cases this causes problems with .
pseudo-ops. To work around this, I just use a block comment or just move the comment to the preceding line.
/* Use this for block comments */
. I currently haven't run into any issues with this.
#
or /
.//
and /**/
to avoid preprocessor issues. However, if you keep in mind the hidden gotchas, you should be ok./
or ##
so you don't have to worry about the preprocessor or lack thereof on any one file. ##
is more versatile, but may lead to messier code.Comments for at&t assembler are:
# this is a comment
/* this is a comment */
According to the fourth result Google gave me
//
and /* */
comments are only supported in .S
files because GCC runs the C preprocessor on them before assembling. For .s
files, the actual assembler itself (as
) only handles #
as a comment character, for x86.
For some other ISAs, GAS uses other comment characters, for example @
for ARM.
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