Arm Community
Arm Community
  • Site
  • User
  • Site
  • Search
  • User
  • Groups
    • Arm Research
    • DesignStart
    • Education Hub
    • Innovation
    • Open Source Software and Platforms
  • Forums
    • AI and ML forum
    • Architectures and Processors forum
    • Arm Development Platforms forum
    • Arm Development Studio forum
    • Arm Virtual Hardware forum
    • Automotive forum
    • Compilers and Libraries forum
    • Graphics, Gaming, and VR forum
    • High Performance Computing (HPC) forum
    • Infrastructure Solutions forum
    • Internet of Things (IoT) forum
    • Keil forum
    • Morello Forum
    • Operating Systems forum
    • SoC Design and Simulation forum
    • 中文社区论区
  • Blogs
    • AI and ML blog
    • Announcements
    • Architectures and Processors blog
    • Automotive blog
    • Graphics, Gaming, and VR blog
    • High Performance Computing (HPC) blog
    • Infrastructure Solutions blog
    • Innovation blog
    • Internet of Things (IoT) blog
    • Mobile blog
    • Operating Systems blog
    • Research Articles
    • SoC Design and Simulation blog
    • Smart Homes
    • Tools, Software and IDEs blog
    • Works on Arm blog
    • 中文社区博客
  • Support
    • Open a support case
    • Documentation
    • Downloads
    • Training
    • Arm Approved program
    • Arm Design Reviews
  • Community Help
  • More
  • Cancel
Arm Community blogs
Arm Community blogs
Tools, Software and IDEs blog Migration of assembly code to Arm Compiler 6
  • Blogs
  • Mentions
  • Sub-Groups
  • Tags
  • Jump...
  • Cancel
More blogs in Arm Community blogs
  • AI and ML blog

  • Announcements

  • Architectures and Processors blog

  • Automotive blog

  • Embedded blog

  • Graphics, Gaming, and VR blog

  • High Performance Computing (HPC) blog

  • Infrastructure Solutions blog

  • Internet of Things (IoT) blog

  • Operating Systems blog

  • SoC Design and Simulation blog

  • Tools, Software and IDEs blog

Tags
  • Architecture
  • Arm Compiler 6
  • DS-5 Development Studio
  • C++
  • LLVM
  • Armv8
Actions
  • RSS
  • More
  • Cancel
Related blog posts
Related forum threads

Migration of assembly code to Arm Compiler 6

Ronan Synnott
Ronan Synnott
October 12, 2017

With Arm Compiler 6, Arm has moved to an advanced, modern compiler based on LLVM and Clang technology. There are many reasons to migrate your C code to this compiler (see my colleague Paul's excellent discussion 'Link Time Optimization in Arm Compiler 6'). But what of the assembler? We have provided a stand-alone assembler, armasm, as part of our tool suites (RVDS, MDK, and DS-5) for many years. Arm Compiler 6, or armclang, as the executable is named, contains a built-in integrated assembler that can be used to build your low level source files. In this blog I will discuss how to make use of this feature, and how to migrate legacy source to this tool.

Perhaps surprisingly, I will start by saying that you may not need to migrate source files to this tool! The existing Arm assembler (armasm) has been maintained to support the latest Armv8 architecture and conforming processors (up to Armv8.3). Even if you have migrated the C source to the new compiler, you can still build the assembler source with armasm as before. The linker will happily consume objects built with either assembler (or either compiler). That being said, we do encourage you to start the migration process.

Mixing armclang and armasm in Eclipse

If you use the Eclipse IDE within DS-5 to manage your project, you will know that there is a default project template for Arm Compiler 6. This selects armclang as the default assembler, as visible in the Properties → C/C++ Build → Settings view.

C/C++ Build Settings

You can change this, by navigating to the Tool Chain Editor pane in the same view, and click on Select Tools...

Tool Chain Editor view

Within this view, you can replace Arm Assembler for Arm Assembler 5 (i.e. armasm):

Select tools replace to Arm Assembler 5

Click OK to save, then, when you go back to Settings, you will see armasm listed instead.

Settings view

Migration of legacy source to armclang

Of course, as assembly level source code is typically written for initialization of device specific features, it is usually re-written for new platforms, perhaps based on existing code, and so when you are at this point, it is a good time to start to consider migration to armclang. Armasm consumes source code written in a proprietary format, whereas armclang consumes source in GNU assembler (gas) format. Unfortunately these are quite different formats, even for the most basic of examples, as illustrated below:

; Example armasm syntax source file

; This is a comment

	AREA	ARMex, CODE		; Name this block of code ARMex
	ENTRY					; Image (potential) entry point
	CODE32					; A32 code from here
	EXPORT	foo				; Make symbol foo global
	IMPORT	bar				; Reference external global symbol
foo					    	; symbol declaration
	LDR	r0, [pc]
	B	bar
	DCD	0x12345678			; This is data

	END					    ; End of file. Ignore everything after

// Example GNU syntax source file
// This is a comment

	.section ARMex, "x“		// Name this block of code ARMex
				            // specify entry point by linker
	.code 32			    // A32 code from here
	.global	foo     		// Make symbol foo global
			            	// undef symbols assumed global
foo:        				// symbol declaration
	LDR	r0, [pc]
	B	bar
	.word	0x12345678  	// This is data

	.end	        		// End of file. Ignore everything after

Command-line options are also significantly different, a table is provided in documentation to compare equivalent options.

Inline assembly within C code

It is possible to insert assembler code within C source to implement functionality for which there is no direct equivalent C construct, by using the __asm keyword.

As above, the legacy Arm Compiler, armcc, used armasm syntax, whereas armclang uses GNU inline assembly syntax, and so these sources would need to be rewritten to be re-compiled with armclang. However our recommendation for such cases is to reconsider if assembler notation is truly appropriate any more. Better to make use of the intrinsic functions as defined within arm_acle.h (and arm_compat.h) which are portable implementations of such operations, defned within the Arm C Language Extensions specification.

I hope this was a useful introduction on this topic. For more information on migrating both C and assembly code to Arm Compiler 6, click the button below: 

Arm Compiler Migration and Compatibility Guide

Anonymous
Tools, Software and IDEs blog
  • Arm Compiler for Linux: what is new in the 22.0 release?

    Ashok Bhat
    Ashok Bhat
    Arm Compiler for Linux 22.0 is now available with performance improvements and support for new hardware like AWS Graviton 3.
    • May 27, 2022
  • Cloud infrastructure for continuous integration tests

    Christopher Seidl
    Christopher Seidl
    This blog introduces a cloud-based continuous integration (CI) workflow for embedded projects that uses model-based simulation.
    • May 24, 2022
  • New performance features and improvements in GCC 12

    Tamar Christina
    Tamar Christina
    Read about the new architecture and performance feature in GCC 12 for the Arm CPUs. From vectorization to instructions to optimize memory operations.
    • May 10, 2022