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] |
On Mon, Aug 27, 2007 at 06:11:04AM +0100, Darryl L. Miles wrote:#define U64_DIVIDE_ASM(quotient, remainder, dividend, divisor, overflow) do { \ __asm__ __volatile__( \ "\n\t" \ "xorl %0,%0\n\t" \ "divq %5\n\t" \ \ "jnc 1f\n\t" \ "incl %0\n" \ "1:\n\t" \ "movq %%rax,%2\n\t" \ "movq %%rdx,%1\n\t" \ : "=&g" (overflow), /* return */ \ "=g" (*remainder), \ "=g" (*quotient) \ : "d" (0), /* argument */ \ "a" ((*dividend)), \ "g" ((*divisor)) \ /*: "rax", "rdx", you'd think you need this to */ \ /* describe these registers as no longer containing */ \ /* the assigned input values after asm block */ \ /* execution, but will not compile witht them set. */ \
I think you want
: "=&r" (overflow), /* return */ "=d" (*remainder), "=a" (*quotient) : "1" (0), /* argument */ "2" (*dividend), "rm" (*divisor)
so the compiler knows that %rax and %rdx are modified.
u64_divide: movq (%rdi), %rdi xorl %r8d, %r8d movq %rdx, %r9 movl %r8d, %edx movq %rdi, %rax #APP
divq (%rsi) jnc 1f inc %r8d 1:
#NO_APP movq %rdx, (%rcx) movq %rax, (%r9) movl %r8d, %eax ret
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |