Inline assembly question

Robert Rose rose@cafwap.net
Wed Mar 10 05:26:00 GMT 2004


Hi folks, I don't think there's anything quite as humbling as trying to 
do inline assembly inside a C program.. :)

I'm trying to do a few simple inline assembly instructions in a program 
I'm writing for the Symbian platform.  Symbian uses gcc version 
"2.9-psion-98r2" and compiles for the ARM platform.  I can insert 
"static" assembly statements fine without any issues, but when I try 
and uses extended assembly to refer to local variables I just can't 
figure things out.  For example, I would like to multiply two numbers 
together and store the result in another variable.  From what I've 
managed to scrap together from bits and pieces of online documentation, 
it appears this is done by:

static long mymul(long a, long b) {
   long result;
   __asm("mul %0,%1,%2" : "=r" (result) : "r" (a), "r" (b));
   return result;
}

When this is compiled it gives a warning almost everywhere (but not 
everywhere) I refer to this function.  When I run the code it crashes.  
The warning its giving me is:

"rd and rm should be different in mul".

What does that mean and how do I fix it? :-)  Thanks!

-robert



More information about the Gcc-help mailing list