| |||
| Home > Writing ARM Assembly Language > Assembly language changes | |||
Table 2.10 shows the main differences between the current ARM/Thumb assembler language and the earlier separate ARM and Thumb assembler languages. The old ARM syntax is accepted by the assembler.
Table 2.10. Changes from earlier ARM assembly language
| Change | Old ARM syntax | Preferred syntax |
|---|---|---|
The default addressing mode for LDM and STM is IA |
| LDM, STM |
You can use the PUSH and POP mnemonics
for full, descending stack operations in ARM as well as Thumb. |
STMFD sp!, { |
PUSH { |
You can use the LSL, LSR, ASR, ROR,
and RRX instruction mnemonics for instructions with
rotations and no other operation, in ARM as well as Thumb. | MOV | LSL |
Use the form
for PC-relative addressing. Do not use the form
in new code. | LDR | LDR |
| Specify both registers for doubleword memory accesses. You must still obey rules about the register combinations you can use. | LDRD | LDRD |
{,
if used, is always the last element of all instructions. |
ADD{ |
ADDS{ |
You can use both ARM { conditional
forms and Thumb-2 IT instructions, in both ARM and
Thumb-2 code. The assembler checks for consistency between the two,
and assembles the appropriate code depending on the current instruction
set. | ADDEQ r1, r2, r3 LDRNE r1, [r2, r3] | ITEQ E ADDEQ r1, r2, r3 LDRNE r1, [r2, r3] |
In addition, some flexibility is permitted that was not permitted in previous assemblers (see Table 2.11).
Table 2.11. Relaxation of requirements
| Relaxation | Preferred syntax | Permitted syntax |
|---|---|---|
| If the destination register is the same as the first operand, you can use a two register form of the instruction. |
|
|
You can write source code for Thumb processors using the ARM/Thumb assembler language.
If you are writing Thumb code for a pre-Thumb-2 processor, you must restrict yourself to instructions that are available on the processor. The assembler generates error messages if you attempt to use an instruction that is not available.
If you are writing Thumb code for a Thumb-2 processor, you can minimize your code size by using 16-bit instructions wherever possible.
Table 2.12 shows
the main differences between Thumb assembly language and ARM assembly
language. The assembler accepts the old Thumb syntax only if it
is preceded by a CODE16 directive, or if the source
file is assembled with the --16 command-line option.
Table 2.12. Differences between old Thumb syntax and current syntax
| Change | Old Thumb syntax | New syntax |
|---|---|---|
The default addressing mode for LDM and STM is IA | LDMIA, STMIA | LDM, STM |
You must use the S postfix
on instructions that update the flags. This change is essential
to avoid conflict with 32-bit Thumb-2 instructions. | ADD r1, r2, r3 SUB r4, r5, #6 MOV r0, #1 LSR r1, r2, #1 | ADDS r1, r2, r3 SUBS r4, r5, #6 MOVS r0, #1 LSRS r1, r2, #1 |
| The preferred form for ALU instructions specifies three registers, even if the destination register is the same as the first operand. | ADD r7, r8 SUB r1, #80 | ADD r7, r7, r8 SUBS r1, r1, #80 |
If and are
both Lo registers, MOV is disassembled
as ADDS . | MOV | ADDS |
NEG is
disassembled as RSBS . | NEG | RSBS |
NOP instructions replace MOV
r8, r8 when available. | - NOP | NOP MOV r8, r8 |