In the previous episodes, we got to know ARM company and ARM processors, we learned the basic structures by examining the ARM Cortex-M processor family more closely. In order to better understand ARM architecture, I think it will be very useful for us to start from the very basics, that is, to get acquainted with the ARM assembly instruction set architecture. But first of all, let’s see what the concept of assembly is.
What is Assembly?
Assembly, usually abbreviated as asm, is a low-level programming language in which there is a very strong compromise between the commands in the language and the machine code of the architecture. Assembly, also known as symbolic machine code, is not actually a single language. Each assembly language is designed for a specific computer architecture. For this reason, the assembly language of each computer architecture is unique to itself.
Assembly languages were used a lot in the past. Apart from being used in applications where direct hardware manipulation is required, such as device drivers, low-level embedded systems and real-time applications, or when there are abnormal performance issues, today it has been replaced by high-level languages such as C/C++, Python.
Assembly codes are converted into executable machine code with utilities called assemblers. This transformation process is called assembling.
An assembler program creates object code by converting mnemonic and syntax combinations and addressing modes to their numerical equivalents for operations. This representation typically includes an operation code (opcode) and other control bits and data. Assembler also computes constant expressions, decodes symbolic names for memory locations and other elements. Symbolic naming is an important feature of assembler programs. It saves us from tedious calculations and manual address updates after program changes.
General Language Design
The commands in assembly languages are generally quite simple, unlike high-level languages such as C/C++, Python. An assembly command generally consists of an opcode and an operand. Most commands specify a single value or pair of values. An assembly command usually corresponds to a machine language command that can be directly executed.
Why Is Learning Assembly Still Important?
The use of assemblies makes it possible to directly manage the hardware, fix critical performance-related issues, and provide access to specific instructions for the processors. This helps us to better understand the processor architecture. Although assembly is not used directly, it is a crucial factor in developing a strong knowledge.
ARM Assembly Instruction Sets
ARM processors basically support 4 different instruction sets. We can list these command sets as follows:
- Thumb instruction set aims to improve code density. The size of the executable files is small because the Thumb instruction length is 16 bits. Space savings are achieved by reducing the possibilities of operands and limiting the number of registers accessible to a command. Reducing the instruction memory size provides cost and power savings benefits for many embedded systems.
- ARM32 instruction length is 32 bits and provides more coding flexibility than Thumb instruction set. More operand options, more flexible memory addressing schemes, larger instantaneous numbers, and more addressable registers can be encoded in a 32-bit word. Also, ARM32 commands run faster than the Thumb instruction set, as an instruction can perform more operations or contain more operands, but has the disadvantage of code density.
- Thumb-2 provides an extraordinary compatibility between ARM32 and Thumb instruction sets. It optimizes the balance between code density and processor performance. It consists of 16-bit Thumb instructions and a subset of 32 bit ARM32 instructions. The purpose of the Thumb-2 instruction set is to achieve higher speed with lower code density.
- ARM64 is commonly used in desktops and servers using 64-bit ARM processors. As can be understood the instruction length is 64 bits.
- Wikipedia. Assembly language
- Zhu, Y. (2018). Embedded Systems with ARM Cortex-M Microcontrollers in Assembly Language and C