From: Christoph Spiel <Christoph.Spiel@pa...> - 2006-04-24 06:45:46
> How to compile GCC inline assembly into ANSI
> C/C++ assembly?
"C/C++ assembly" in general simply does not
exist. This is, the C and C++ ISO standards do
_not_ define inline assembly. Inline assembly
always has been very compiler specific.
With respect to CASE 1:
I do not speak MSVC, thus I cannot tell
whether the output that CIL produces is
correct ("correct" in terms of what?).
Nathan, any comments from Your side on this?
With respect to CASE 2:
This looks perfectly kosher to me; CIL
correctly translates the __asm__ statement.
It is conceivable that Your MSVC-compiler
chokes because the syntax is GNU-C specific.
That does not come as a surprise however.
> How to translate the following function to
> ANSI C/C++ assembly by using CIL and compile
> it by MS VC++?
> inline int neg_ssr32(int a, unsigned char s)
> asm ("sarl %1, %0\n\t"
> : "+r" (a)
> : "ic" ((unsigned char)(-s)));
> return a;
(i) As stated above "ANSI C/C++ assembly" does
(ii) To my knowledge CIL does not translate
inline assembly code. Your CASE 1 tells me
that e.g. that there is no translation from
AT&T-style to Intel-style memnonics, which
is something I would have expected.
Until CIL actually can do this (Patches are
always welcome!), You could revert to the
technique I showed You in my previous mail.
Dr. Christoph L. Spiel
BMW Forschungs- und Innovationszentrum, EA-41
Lauchstaedter Strasse 5, 80995 Muenchen