Most developers write most of their code using a high-level language such as C and C++. This high-level source code is then compiled to machine code which runs on a target device.

Sometimes, however, writing low-level assembly code has advantages. Perhaps you want to hand-optimize a critical algorithm to make it as fast as possible. Or perhaps you need to maintain legacy code that is already written in assembly. Or maybe you just want to learn more about the low-level operation of your code to understand more about how it works.

In all these situations, you will need to understand how to read and write Arm assembly code.

Learning about the instruction set

Assembly instructions are the fundamental building blocks of any program. If you are going to write assembly code, you will need to understand what instructions are available to you.

The precise set of available instructions for a particular device is called the instruction set. The Arm architecture supports three Instruction Set Architectures (ISAs): A64, A32 and T32. Use these resources for more information:

Learning about assembly language

Although the instruction set reference materials described in the Overview are comprehensive, they do not provide the best starting point for beginners.

The following resources introduce the basic concepts of programming in Arm assembly language:

The Arm Compiler 5 toolchain (executable name armasm) uses a different syntax for assembly code to Arm Compiler 6 (executable name armclang) and GNU (executable name as). Although the instructions are mostly the same regardless of toolchain, the syntax around the instructions varies.

Mixing C, C++, and assembly code

Even though you can now write Arm assembly code, you probably do not want to use it to hand-code your entire application.

You will probably want to write a small number of key functions in assembly, and call those functions from your main application code. You might want to do this to make use of existing assembly code, but the rest of your project is in C or C++.

Writing your first assembly program

Here are some examples that you can follow to get started with Arm assembly language.

Writing inline assembly code

Inline assembly lets you write assembly code directly in your C or C++ source code. This can simplify the task of writing assembly code. For example, you can leave register allocation to the compiler, instead of explicitly referring to specific registers in your code.