This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Problems with inline asm


Hi,

I'm not sure if I'm doing something stupid or not, but the following code does odd things to g++-3.3.1. If I compile it with -O(or higher), it compiles and runs, no problem. But if I try to compile without optimization, I get "error: inconsistent operand constraints in an `asm'". If I change the two "ra's" in the asm operands to "a's", the program compiles error free at any -O level. I really think this is a bug in g++, but It's also possible I am misunderstanding the rather poor inline asm documentation. In any case, I'd really appreciate someone looking at this before I go insane.

#include <iostream>
using namespace std;

int main(void)
{
   int a=1;
   int b=2;
   int &ra=a;
   int &rb=b;

   asm(" movl  %0, %%eax\n\
         add   %2, %%eax\n\
         movl  %%eax, %0\n\
      "
      :"=m"(ra)
      :"0"(ra), "m"(rb)
      :"%eax"
      );
   cout << a << endl;
   return 0;
}

Thanks,

Kyle Centers
-- 
__________________________________________________________
Sign-up for your own personalized E-mail at Mail.com
http://www.mail.com/?sr=signup

CareerBuilder.com has over 400,000 jobs. Be smarter about your job search
http://corp.mail.com/careers


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]