You copied the Doc URL to your clipboard.

Assembling armasm and GNU syntax assembly code

The Arm® Compiler toolchain can assemble both armasm and GNU syntax assembly language source code.

armasm and GNU are two different syntaxes for assembly language source code. They are similar, but have a number of differences. For example, armasm syntax identifies labels by their position at the start of a line, while GNU syntax identifies them by the presence of a colon.

Note

The GNU Binutils - Using as documentation provides complete information about GNU syntax assembly code.

The Migration and Compatibility Guide contains detailed information about the differences between armasm syntax and GNU syntax assembly to help you migrate legacy assembly code.

The following examples show equivalent armasm and GNU syntax assembly code for incrementing a register in a loop.

armasm assembler 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

You might have legacy assembly source files that use the armasm syntax. Use armasm to assemble legacy armasm syntax assembly code. Typically, you invoke the armasm assembler as follows:

armasm --cpu=8-A.64 -o file.o file.s

GNU assembler syntax:

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

        .section .text,"ax"                          
        .balign 4                               

main:                                        
        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
        .end                                    

Use GNU syntax for newly created assembly files. Use the armclang integrated assembler to assemble GNU assembly language source code. Typically, you invoke the armclang assembler as follows:

armclang --target=aarch64-arm-none-eabi -c -o file.o file.S
Was this page helpful? Yes No