You copied the Doc URL to your clipboard.

Syntax of assembly files for integrated assembler

Assembly statements can include labels, instructions, directives, or macros.

Syntax

    label:
    instruction[;]
    directive[;]
    macro_invocation[;]

Description

label

For label statements, the statement ends after the : character. For the other forms of assembler statements, the statement ends at the first newline or ; character. This means that any number of labels can be defined on the same source line, and multiple of any other types of statements can be present in one source line if separated by ;.

Label names without double quotes:

  • Must start with a period (.), _, a-z or A-Z.
  • Can also contain numbers, _, $.
  • Must not contain white spaces.

You can have white spaces in label names by surrounding them with double quotes. Escape sequences are not interpreted within label names. It is also not possible to have double quotes as part of the label name.

instruction

The optional ; can be used to end the statement and start a new statement on the same line.

directive

The optional ; can be used to end the statement and start a new statement on the same line.

macro_invocation

The optional ; can be used to end the statement and start a new statement on the same line.

Comments

Comments are treated as equivalent to whitespace, their contents are ignored by the assembler.

There are two ways to include comments in an assembly file:

  // single-line comment
  @ single-line comment in AArch32 state only
  /* multi-line
     comment */

In single-line comments, the // marker starts a comment that runs to the end of the source line. Unlike when compiling C and C++ source, the end of the line cannot be escaped with \ to continue the comment.

@ starts a single-line comment in AArch32 state. @ is not a comment character in AArch64 state.

In multi-line comments, the /* marker starts a comment that runs to the first occurrence of */, even if that is on a later line. Like in C and C++ source, the comment always ends at the first */, so comments cannot be nested. This style of comments can be used anywhere within an assembly statement where whitespace is valid.

Examples

    // Instruction on it's own line:
    add r0, r1, r2

    // Label and directive:
  lab: .word 42

    // Multiple labels on one line:
  lab1: lab2:
    
    /* Multiple instructions, directives or macro-invocations 
       must be separated by ';' */
    add r0, r1, r2; bx lr

    // Multi-line comments can be used anywhere whitespace can:
    add /*dst*/r0, /*lhs*/r1, /*rhs*/r2

Was this page helpful? Yes No