Keil Logo

Overview of differences between armasm and GNU syntax assembly code

5.2 Overview of differences between armasm and GNU syntax assembly code

armasm (for assembling legacy assembly code) uses armasm 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 armasm 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 armasm and GNU syntax.

armasm syntax

; Simple armasm 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 5.3 Comments
// 
// Iterate round a loop 10 times, adding 1 to a register each time.

        .section .text,"ax"    // 5.7 Sections 
        .balign 4								

main:                          // 5.4 Labels 
        MOV      w5,#0x64      // W5 = 100  5.9 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                   // 5.18 Miscellaneous directives 
Non-ConfidentialPDF file icon PDF version100068_0613_00_en
Copyright © 2014–2019 Arm Limited or its affiliates. All rights reserved. 
  Arm logo
Important information

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.

Change Settings

Privacy Policy Update

Arm’s Privacy Policy has been updated. By continuing to use our site, you consent to Arm’s Privacy Policy. Please review our Privacy Policy to learn more about our collection, use and transfers
of your data.