Intel® C++ Compiler
Community support and assistance for creating C++ code that runs on platforms based on Intel® processors.
7942 Discussions

Q&A: Is it possible to write assembly language that will work with multiple compilers?

Intel_Software_Netw1
382 Views
Here is a customer issue submitted to Intel Developer Services Support, along with the response provided by our Application Engineers:
Q. Is it possible to write assembly language that will work with multiple compilers? In particular, we would like to support msvc6, msvc7, Intel, and gcc on Linux.
A. It is possible to support multiple compilers, but if one of them is gcc, then it is not easy. Microsoft Visual C++ Compiler* (MSVC) 6.0 and 7.0 and the Intel compilers all use the same assembly language format (called the Intel format). Care must be taken, however, to ensure that the assembly language instructions used are supported by the various compilers. This is possible through processor packs for MSVC 6.0 and 7.0. Gcc, however, uses the AT&T format for their assembly language instructions. The easiest way to support gcc as well is to generate two sections of the assembly code, one in the AT&T format and one in the Intel format. You can then use IFDEFs to include the correct assembly section for the compiler being used. An alternate approach would be to have an include file which converts one format to the other (using #DEFINE statements) and place the include statement for that include file inside an IFDEF. Such an include file would probably be very large to cover the assembly language instructions used. There are a few other, more convoluted ways to do this, but they are not worth mentioning.
==
Lexi S.

IntelSoftware NetworkSupport

http://www.intel.com/software

Contact us

Message Edited by intel.software.network.support on 12-07-2005 04:44 PM

0 Kudos
4 Replies
TimP
Honored Contributor III
382 Views
I find this reply potentially confusing. The asm syntax of icc for linux-ia32 is compatible with gcc, but not with Windows compilers other than gcc, not only because of the AT&T vs Intel semantics. In fact, gcc has a little used switch to change the spellings over to Intel, but that still won't make it compatible with the commercial Windows compilers.
As I understand it, Microsoft is removing asm support entirely from "64-bit" compilers, and de-emphasizing it throughout. For low level coding,Microsoft are supportinga larger set of what originally were Intel SSE intrinsics. A subset of those work on all the compilers mentioned, for all IA targets. Some of us have urged that more of Microsoft's own extension to the Intel SSE intrinsics should come into the Intel compilers.
Hope I haven't confused the issue even further.
0 Kudos
andy2222
Beginner
382 Views
im also intrested into this problem,
my main problem is the inline asm stuff wich in intel_syntax need's to be rewritten to at&t syntax for gcc.
The -masm=intel switch and the .intel_syntax noprefix is not working at all, many stuff cant be parsed or is not working. he first thing is the "... " stuff and the asm {} to asm( :::); converting stuff.
Also the problem that gcc/gas cant access c++ variables without extended asm usage is a problem.
0 Kudos
TimP
Honored Contributor III
382 Views
If you refer to differences in C++ name-mangling ABI's, you should be able to overcome them with extern "C" declarations. If someone has buried some particulary name-mangling convention into asm code, I assume it was done with full intent to make it non-portable.
0 Kudos
John_O_Intel
Employee
382 Views
You can use MASM or "intel" sytled asm syntax with icc -use_msasmoption. The default for icc is to use the gcc format.
regards,
John O'Neill
0 Kudos
Reply