LOGBOOK

HELP

Quiz Entry - updated: 2026.07.10

What is the GNU Assembler (GAS), and how do you turn an assembly source file into a runnable program with it?

GAS (invoked as as, or via gcc) is the GNU project's assembler — it translates assembly text into object code; its syntax adapts to whichever CPU architecture you target.

A build pipeline: hello.S source is assembled by as (GAS) into hello.o, which the linker ld turns into the runnable executable, with gcc driving both as and ld in one step.

* From source to executable: gcc drives the assembler (as) and the linker (ld) in a single step. *

GAS is the back-end assembler that GCC itself uses, so the easiest way to build assembly is to hand a .S file straight to gcc and let it run the assembler and linker for you:

$ gcc -o hello hello.S      # assemble + link in one step
$ ./hello
Hello, world!

What makes GAS notable is its breadth: one tool supports many architectures (x86, ARM, RISC-V, …), and the exact mnemonics and directives shift to match each platform's conventions. That flexibility comes with quirks worth knowing:

  • Source must end with a trailing newline on the last line, or GAS may reject it.
  • The full directive set is large and architecture-specific — the GAS manual is the reference.

Tip: Use a capital .S extension (not .s) so GCC runs the C preprocessor first, letting you use #include and #define in your assembly.

Go deeper:

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