Success!  Thanks to everyone who helped me out.  This was a great
little project to learn about inline assembly in GCC.  For those of
you who are interested, here's the final product:

inline double DiffAngle(double theta1, double theta2)
{
  double TWO_PI __attribute__ ((aligned (16)))(2 * M_PI),
    NEG_TWO_PI __attribute__ ((aligned (16)))(-TWO_PI);
  double delta(theta1 - theta2);

  asm("cmpnlesd %0, %1\n\t"
      "cmpltsd %0, %2\n\t"
      "andpd %3, %1\n\t"
      "andpd %4, %2\n\t"
      "addsd %1, %0\n\t"
      "addsd %2, %0\n\t"
      : "+x" (delta)
      : "x" (M_PI),
        "x" (-M_PI),
        "m" (TWO_PI),
        "m" (NEG_TWO_PI)
      :
      );

  return delta;
}

One final question - is it possible to declare TWO_PI and NEG_TWO_PI
as const?  And, if so, what constraint would I use?  Right now, if I
declare them const, I get the error "memory input 3 is not directly
addressable".

Thanks,
Bill
_______________________________________________
help-gplusplus mailing list
help-gplusplus@gnu.org
https://lists.gnu.org/mailman/listinfo/help-gplusplus

Reply via email to