asm.pl
x86-64 assembly as terms, and their printer as GNU as (AT&T) text. The backends build a list of lines; this module is the only place that knows AT&T syntax.
Lines
| Line | Prints as |
|---|---|
labelS | S: |
insOp, Suffix, Operands | Op, then Suffix unless it is none, then the operands in AT&T order (sources first) |
| a directive | the directive, below |
| Directive | Prints as |
|---|---|
sectionS | the section S: text, data, rodata, bss, tbss (thread-local, zeroed), data_rel_ro, note_gnu_stack, or initctor | dtor, Priority for .init_array or .fini_array, with .Priority unless it is none |
p2alignN balignN | .p2align N, .balign N |
globlS weakS hiddenS | .globl S, .weak S, .hidden S |
typeS, T | .type S, @T, T function or object |
sizeS | .size S, .-S |
sizeS, N | .size S, N |
setS, E | .set S, E |
quadE | .quad E |
longN intN shortN | .long N, .int N, .short N |
byteNs | .byte and the non-empty list Ns |
zeroN | .zero N |
asciiChars | .ascii and the characters, escaped |
ascizAtom | .asciz and the atom, as it is |
Operands
Operands name concrete registers, so mixed widths such as movzbl %al, %eax need no width bookkeeping.
| Operand | Prints as |
|---|---|
immE | $E |
regR | %R, for example regeax, regcl, regr9d |
memD, B | D(%B), D omitted when 0 |
memD, B, I | D(%B,%I), D omitted when 0 |
ripE | E(%rip) |
gotpcrelS | S@GOTPCREL(%rip) |
pltS | S@PLT |
gottpoffS | S@GOTTPOFF(%rip), the GOT slot of thread-local S's offset from %fs |
fsO | %fs:O, memory operand O in the thread segment |
symE | E, a jump or call target |
indO | *O |
An expression E is an integer, a symbol atom or E1+E2; a left operand that is itself a sum is parenthesized.
Print Lines, a list of asm.pl lines, to the current output as GNU as text. Throws nanofil_error(bad_asm_line(Line)) for a line it cannot print.
The text is a list of atomic parts (atoms, numbers and characters), joined once per chunk: building it character by character was most of emission's time.
the text of Line. directive//1 has no clause for label/1 or ins/3, so the cases are disjoint; line//1 commits to the first parse.
A fixed-register asm (docs/asm-fixed.md) from the emitter's own table. cpuid writes rbx, which may hold a register home: it is kept in rsi, and cpuid's b result is brought out in edi.
the bytes Cs, one per character, inside an .ascii string: printable ASCII as itself except quote and backslash, which are escaped, newline and tab as \n and \t, any other byte as three octal digits.
O is the octal digit of N at bit Shift.
Name is the directive text of Section.
The text of an atom or number, as one part.
the characters Cs, as parts.