From: Agner Fog <agner@agner.org>
To: linux-assembly@vger.kernel.org
Subject: New C++ compiler with inline assembly support
Date: Mon, 20 Jun 2005 09:02:50 +0200 [thread overview]
Message-ID: <42B66A1A.50004@agner.org> (raw)
Intel have just released version 9.0 of their C++ compiler with better
support for inline assembly.
It can compile for the following platforms
- Linux x86 32 bit
- Linux x86 64 bit
- Linux ia64 (Itanium)
- Windows x86 32 bit
- Windows x86 64 bit
- Windows ia64 (Itanium)
I haven't tested it on FreeBSD yet, but I assume that it works on 32 and
64 bit FreeBSD as well.
In Linux, you now have the choice between MASM syntax and AT&T syntax
for inline assembly. MASM syntax is almost the same as NASM. If you
choose MASM syntax, you can use the same C++ file with inline assembly
in both Linux and Windows. It can even translate MASM syntax assembly to
AT&T syntax, and this more reliably than any other translation tools I
have seen yet.
To use MASM syntax under Linux, simply use the command line option
-use-msasm
Example:
int addnumbers (int a, int b) {
return a+b;}
Same with inline assembly in MASM syntax:
int addnumbers (int a, int b) {
__asm {
mov eax, a
add eax, b
}
}
This will work in both Linux and Windows, 32 and 64 bit. So you can use
the same C++/asm file on all platforms. It takes care of the differences
in calling conventions between the different platforms, and it
automatically pushes and pops any non-volatile registers that you use in
your code. This makes Linux assembly much easier! You can make the most
of your program in C++ and make the critical innermost loop with inline
assembly.
In 64-bit Linux, function parameters are transferred in registers rdi,
rsi, rdx, rcx, r8, r9, xmm0-xmm7. If you know this, you can optimize the
above example:
int addnumbers (int a, int b) {
__asm {
lea eax, [rdi+rsi]
}
}
But then your code is no longer platform independent, of course.
The C++ compiler for Linux is available for free for noncommercial
users. Download it from http://www.intel.com/software/products/noncom/
The C++ compiler for Windows is available with a time limited free
evaluation license from
https://registrationcenter.intel.com/EvalCenter/EvalForm.aspx?ProductID=411
Agner Fog
www.agner.org/assem
next reply other threads:[~2005-06-20 7:02 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-06-20 7:02 Agner Fog [this message]
2005-06-22 12:27 ` New C++ compiler with inline assembly support Herbert Poetzl
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=42B66A1A.50004@agner.org \
--to=agner@agner.org \
--cc=linux-assembly@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).