4.1 Overview of differences between ARM and GNU syntax assembly code

armasm (for assembling legacy assembly code) uses ARM® syntax assembly code.

armclang aims to be compatible with GNU syntax assembly code (that is, the assembly code syntax supported by the GNU assembler, as).
If you have legacy assembly code that you want to assemble with armclang, you must convert that assembly code from ARM syntax to GNU syntax.
The specific instructions and order of operands in your UAL syntax assembly code do not change during this migration process.
However, you need to make changes to the syntax of your assembly code. These changes include:
  • The directives in your code.
  • The format of labels, comments, and some types of literals.
  • Some symbol names.
  • The operators in your code.
The following examples show simple, equivalent, assembly code in both ARM and GNU syntax.

ARM syntax

; Simple ARM syntax example
;
; Iterate round a loop 10 times, adding 1 to a register each time.

        AREA ||.text||, CODE, READONLY, ALIGN=2

main PROC
        MOV      w5,#0x64      ; W5 = 100
        MOV      w4,#0         ; W4 = 0
        B        test_loop     ; branch to test_loop
loop
        ADD      w5,w5,#1      ; Add 1 to W5
        ADD      w4,w4,#1      ; Add 1 to W4
test_loop
        CMP      w4,#0xa       ; if W4 < 10, branch back to loop
        BLT      loop
        ENDP

        END

GNU syntax

// Simple GNU syntax example 4.2 Comments
// 
// Iterate round a loop 10 times, adding 1 to a register each time.

        .section .text,"x"     // 4.6 Sections
        .balign 4								

main:                          // 4.3 Labels 
        MOV      w5,#0x64      // W5 = 100  4.8 Numeric literals
        MOV      w4,#0         // W4 = 0
        B        test_loop     // branch to test_loop 
loop:
        ADD      w5,w5,#1      // Add 1 to W5
        ADD      w4,w4,#1      // Add 1 to W4
test_loop:
        CMP      w4,#0xa       // if W4 < 10, branch back to loop
        BLT      loop
        .end                   // 4.15 Miscellaneous directives
Related reference
4.2 Comments
4.3 Labels
4.4 Numeric local labels
4.5 Functions
4.6 Sections
4.7 Symbol naming rules
4.8 Numeric literals
4.9 Operators
4.10 Alignment
4.11 PC-relative addressing
4.12 Conditional directives
4.13 Data definition directives
4.14 Instruction set directives
4.15 Miscellaneous directives
4.16 Symbol definition directives
Related information
About the Unified Assembler Language
Non-ConfidentialPDF file icon PDF versionARM DUI0742F
Copyright © 2014-2016 ARM. All rights reserved.