Migrating to the IAR Assembler for Arm
Assembler source code that was originally written for assemblers from other vendors can also be used with the IAR Assembler for Arm. The assembler option -j allows you to use a number of alternative register names, mnemonics and operators.
The following pages contain information that is useful when migrating from using an existing product to using the IAR Assembler for Arm in 32-bit mode.
Introduction
The IAR Assembler for Arm (IASMARM) was designed using the same look and feel as other IAR assemblers, while still making it easy to translate source code written for the ARMASM assembler from Arm Limited.
When the option -j (Allow alternative register names, mnemonics and operands) is selected, the instruction syntax is the same in IASMARM as in ARMASM. Many features, such as directives and macros, are, however, incompatible and cause syntax errors. There are also differences in Thumb code labels that can cause problems without generating errors or warnings. Be extra careful when you use such labels in situations other than jumps.
For new code, use the IAR Assembler for Arm register names, mnemonics and operators.
Note
The instructions and descriptions in this chapter apply only to using the IAR Assembler for Arm in 32-bit mode.
Thumb code labels
Labels placed in Thumb code, i.e. that appear after a CODE16 directive, always have bit 0 set (i.e. an odd label) in IASMARM. ARMASM, on the other hand, does not set bit 0 on symbols in expressions that are solved at assembly time. In the following example, the symbol T is local and placed in Thumb code. It will have bit 0 set when assembled with IASMARM, but not when assembled with ARMASM—except in DCD, since it is solved at link time for relocatable sections. Thus, the instructions will be assembled differently.
Example
section MYCODE:CODE(2)
armThe two instructions below are interpreted differently by ARMASM and IASMARM. ICCARM interprets a reference to T as an odd address (with the Thumb mode bit set), but in ARMASM it is even (the Thumb mode bit is not set).
adr r0,T+1
mov r1,#T-.To achieve the same interpretation for both ARMASM and ICCARM, use :OR: to set the Thumb mode bit, or :AND: to clear it:
add r0,pc,#(T-.-8) :OR: 1
mov r1,#(T-.) :AND: ~1
thumb
T nop
end