more than 10 operands in `asm', but there aren't.

Jeffrey A Law law@cygnus.com
Wed Mar 31 23:54:00 GMT 1999


  In message < 199903031043.LAA23472@pauillac.inria.fr >you write:
  > I thought the "+" constraint would solve my problem with inline asm
  > complaining about too many operands.  Here's the first example I tried:
  > 
  >   asm ("adds    %0, %0, %4
  >         adcs    %1, %1, %5
  >         adcs    %2, %2, %6
  >         adc     %3, %3, %7"
  >       : "+r" (x0), "+r" (x1), "+r" (x2), "+r" (x3)
  >       : "r" (y0), "r" (y1), "r" (y2), "r" (y3)
  >       : "cc"
  >       );
  > 
  > to add two 128-bit numbers on ARM.  But it gives the:
  > 
  >   more than 10 operands in `asm'
  > 
  > 
  > error even though there are only 8 operands.  =:-(
  > 
  > Presumably the 8 are getting expanded internally into 12 before the
  > check is done.  Sure enough in stmt.c, the expand_asm_operands()
  > function does:
Correct.


  > 
  >   asm volatile (
  >        "adds    %0, %0, %3
  >         adcs    %1, %1, %4
  >         adc     %2, %2, %5"
  >       : "+r" (x0), "+r" (x1), "+r" (x2)
  >       : "r" (y0), "r" (y1), "r" (y2)
  >       : "cc"
  >       );
  > 
  > This goes through fine.  But then if I break it by accessing
  > non-existant operands %6, %7 or %8, say like this:
  > 
  >   asm volatile (
  >        "adds    %0, %0, %3
  >         adcs    %1, %1, %4
  >         adc     %2, %2, %8"
  >       : "+r" (x0), "+r" (x1), "+r" (x2)
  >       : "r" (y0), "r" (y1), "r" (y2)
  >       : "cc"
  >       );
  > 
  > then it goes through as well and produces bogus code instead of the:
  > 
  >   invalid `asm': operand number out of range
No, the error is valid.  You're not supposed to be able to access operands
outside the ones you explicitly declare.


jeff



More information about the Gcc-bugs mailing list