MS/CW-style inline assembly for GCC

James Morrison ja2morri@csclub.uwaterloo.ca
Tue May 4 18:49:00 GMT 2004


Andrew Haley <aph@redhat.com> writes:
> Maintaining two totally different assembler syntaxes doesn't seem to
> me like a sensible plan.  Perhaps, with a little thought, we could
> improve what we have at the moment.  "less ugly" might, for example,
> involve replacing operands like "%1" with real names in a slightly
> less evil way than we do at the moment.
> 
> Andrew.

 You mean nicer like [name]?

e.g.
 __asm__ __volatile__("1: ldstub [%[ptr] + 3], %[lock]\n"
                      "\torcc %[lock], 0, %[ignore]\n"
                      "\tbne 1b\n" /* go back until we have the lock */
                      "\tld [%[ptr]], %[inc]\n"
                      "\tsra %[inc], 8, %[inc]\n"
                      "\tadd %[inc], %[val], %[inc]\n"
                      "\tsll %[inc], 8, %[lock]\n"
                      "\tst %[lock],[%[ptr]]\n" /* Release the lock */
                      : [inc] "=&r" (increment), [lock] "=r" (lock),
                        [ignore] "=&r" (ignore)
                      : "0" (increment), [ptr] "r" (ptr), [val] "r" (val)
                      );

Jim



More information about the Gcc mailing list