LOGBOOK

HELP

Quiz Entry - updated: 2026.07.10

How do you write comments in GAS (GNU Assembler) syntax, and what are the rules for how lines and whitespace work?

Single-line comments start with # and run to end of line; multi-line comments use /* ... */.

GAS treats the layout of an assembly file very loosely, which trips up people used to C's syntax:

.text
.globl main
/*
 * main function
 */
main:
    movl $1, %eax    # set %eax to 1
    ret              # return to caller

Key rules:

  • A newline ends an instruction. There's no ; statement terminator — one instruction per line.
  • Whitespace is ignored. Indentation is purely cosmetic; the assembler doesn't care if you indent or not.
  • No blocks. Assembly has no { } scoping — structure comes only from labels and jumps.
  • /* */ outranks #, and you cannot nest same-style comments (a /* inside a /* */ won't behave as you'd expect).

Tip: Because a .S file is run through the C preprocessor, a stray # can also look like a preprocessor directive — keep # comments clearly separated from #define lines.

Go deeper:

From Quiz: REVE1 / Translation of C to Assembly | Updated: Jul 10, 2026