Mail Archives: djgpp/1995/12/20/01:16:18
Andy Molyneux (molyneua AT cs DOT man DOT ac DOT uk) wrote:
: Trouble is, this doesn't let you refer to local variables or parameters
: passed to the current function (which I believe BCC's asm{} does) and the
: assembler syntax requires operands "backwards" amongst other bizarre
: features.
Sorry, but it DOES let you do it, and moreover, you can put not only
variables but ANY VALID C-EXPRESSION inside the `()'. Please DO take a
further look at the info file I mentioned earlier. Here is a (silly)
example I can think of ; sorry I didn't compile it, but I'm at work at
the moment :
int trigger;
int isTriggerPlus2(int i) {
register int result asm("eax");
asm( "
movl %1, %%edx
cmpl %2, %%edx
setnel %0
" : "=r" (result) : "g" (i), "g" (trigger+2) : "edx");
}
I know it is REALLY silly, but it's an example of what can be put
between the `:'.
I know the syntax is not the same as Intel's assembly, but it
DOES allow you to do ASM constructs in a C-source file.
.... hope this helps...
Igx, The dreaming drummer...
-----------------------------------------------------------------------------
Igx, The dreaming drummer... in real(???) life : Jean-Marc CHALLIER
email : challier AT irit DOT fr | J-M CHALLIER,
pmail : IR1-17, UPS, 18 rte de Narbonne | 18, Bd Griffoul Dorval
31000 Toulouse - FRANCE | 31400 Toulouse - FRANCE
phone : (33) 61-55-63-57 | Tel : (33) 62-16-35-92
- Raw text -