Quiz Entry - updated: 2026.07.14
What are the common GAS directives for laying out data, and how do they map to C types?
Directives both switch sections and emit data of a chosen size — .byte/.word/.long/.quad correspond to 1/2/4/8-byte values, mirroring C's char/short/int/long.
A "variable" in assembly is just a label followed by directives that emit the right number of bytes. The size directive you pick is the type:
| Directive | Purpose / C analogue |
|---|---|
.text / .data |
Switch to the code / initialized-data section |
.align N |
Align the next item to an N-byte boundary |
.globl / .extern |
Export a symbol / declare one defined elsewhere |
.byte |
1-byte value (char) |
.short / .word |
2-byte value (short) |
.int / .long |
4-byte value (int) |
.quad |
8-byte value (long, pointer) |
.ascii |
String, no null terminator |
.asciz / .string |
Null-terminated string (adds the trailing \0) |
.skip N / .zero N |
Reserve N bytes (zero-filled) |
Gotcha: .ascii "hi" emits only h,i — two bytes. If C code will treat it as a string and call strlen/printf on it, you want .asciz/.string so the terminating \0 is actually present.
Go deeper:
Using as — the GNU Assembler manual — the complete directive list — .byte/.word/.long/.quad/.ascii/.asciz and more.
GNU Assembler (Wikipedia) — GAS overview.