>Robert Cloud wrote:
>Is it possible to include assembly language routines in
C ...
how would I denote that the following
code is assembly and thus shouldn't be checked for syntax errors?
In article <g5**********@a ioe.orgjacob navia <ja***@nospam.o rg>
wrote (in part, and in reply to the second part):
>Use the asm() pseudo instruction in the C code. But beware... it is
not very easy because you will want to avoid destroying the assembler
code that the compiler generates, so you can't just add instructions
like that withing a function, unless you save all the registers
and restore them later before leaving.
If you use asm() at all, you will depend heavily on the
specific compiler.
If you choose to depend on GCC, what Jacob says here is not quite
correct, because gcc's asm() construct includes communication
between the programmer and the compiler as to what machine registers
and other features are modified by the inline assembly.
For instance, if you are inserting inline assembly on the Glorko
GX-47, you might write:
asm volatile("frob %1,%2,%0" : "=B"(result ) :
"g"(arg1), "I"(arg2) : "L");
to tell gcc:
- the instruction must not be moved or combined;
- the output must be in one of the "B" registers;
- arg1 can be in any register or memory ("g"eneral);
- arg2 must fit in an "I"ntermedi ate instruction field; and
- the "L"aziness register is clobbered by a "frob".
The B and L codes are specific to the Glorko machines, of course.
The letter B means something else on similar machines, and L is
not even valid. So be sure you do not attempt to use this on a
Frobozz series, which also has a frob instruction, but does not
have a laziness register.
(The above is meant as an illustrative example of just what you
are getting into when you start inserting inline assembly. Be
*very* sure this is a good idea before you attempt it.)
--
In-Real-Life: Chris Torek, Wind River Systems
Salt Lake City, UT, USA (40°39.22'N, 111°50.29'W) +1 801 277 2603
email: gmail (figure it out)
http://web.torek.net/torek/index.html