Technical Note 86655

Migrating some GCC inline assembler constructions to EWARM

EW targets: ARM
EW component: C/C++ compiler
Keywords: inline assembler, Migration
Last update: January 21, 2011

Acknowledgment:
These examples have been written by Mr. Ivan Paulik, Pasat, Bratislava, Slovakia, Europe. We are most grateful that he shares his findings with the EWARM users.

This tech note applies to:
This tech note applies to ARM7/9 devices, not to Cortex devices.

Background:
Now and then there are users requesting that IAR makes a "GCC to EWARM Migration Guide". This might seem to be trivial task (as IAR have written other Migration Guides), but it is not trivial, as there is not "one GCC compiler" so we are not able to cover all GCC variants.

Suggestion:
The most different area between GCC and EWARM is Inline Assembler and such constructions (and some other issues) will be commented in this Tech Note (and in the attachment). The goal is that the 9 examples + comments should cover the issues that are most different between GCC and EWARM, and that other issues can be sorted out by the developer that performs the migration.

General comment:
The GCC seems to give the user more responsibility to the user, where the EWARM instead uses keywords, intrinsic functions and/or options for covering the same construction in the application.

The examples

EXAMPLE 1 -- Code referencing to one of the MCU registers.
Please rewrite such constructions without reading/using the general registers. As noted in the example, there is great risk that the ICCARM compiler will re-use register R0 and thus create a run-time error.

EXAMPLE 2 -- Using SWI instruction.
Replace the GCC construction with the EWARM keyword __SWI.

EXAMPLE 3 -- Calling a function with parameters from inline assembler.
This should not be used in EWARM as the use of inline assembly should be minimized in order to make the compile more efficient.
The IAR suggestion is to rewrite the inline assembly as a real assembly function in an assembly file.

EXAMPLE 4 -- Using a function without a "prolog" and "epilog".
There are great risks in keeping the GCC construction. The IAR suggestion is to rewrite the inline assembly as a real assembly function in an assembly file.

EXAMPLE 5 -- Using packed data structures.
This is describes a change of syntax from GCC to EWARM.

EXAMPLE 6 -- Reference to segment start, end, etc.
Rewrite with the use of the EWARM section operators.

EXAMPLE 7 -- Creating own "prolog" and "epilog" to a function without implicit entry and return parameter handling.
Remove the GCC constructions and use the Interwork option instead.

EXAMPLE 8 -- Using interrupt functions.
This is describes a change of syntax from GCC to EWARM.

EXAMPLE 9 -- Aligning data structures.
This is describes a change of syntax from GCC to EWARM.

Note:
This Tech Note does not cover all GCC-to-EWARM conversion issues, but is it at least a starting point for the migration.

Example 1
(PDF, 10 KB)

Example 2
(PDF, 9 KB)

Example 3
(PDF, 9 KB)

Example 4
(PDF, 9 KB)

Example 5
(PDF, 7 KB)

Example 6
(PDF, 8 KB)

Example 7
(PDF, 9 KB)

Example 8
(PDF, 14 KB)

Example 9
(PDF, 6 KB)