GCC can't count operands.
Tony Mantler
eek@escape.ca
Thu Mar 23 20:16:00 GMT 2000
The attached ASM macro is giving me grief. GCC complains about there being
more than 10 operands, and refuses to compile. In reality, there are only 6
operands, since the input and output operands are overlayed.
Anyways, it's perfectly valid code, and deserves to be compiled without
protest, especially since the only reason there's that many operands in the
first place (x1,x2,x3,x4) is because GCC was optimizing away too many
registers and broke the code. :P
For the record, this code is used to very quickly paint a certain range of
memory with a constant value. (ie: 0 or -1)
ubb:~$ m68k-linux-gcc test.c
test.c: In function `main':
test.c:23: more than 10 operands in `asm'
ubb:~$ m68k-linux-gcc -v
Reading specs from /usr/local/lib/gcc-lib/m68k-linux/egcs-2.91.66/specs
gcc version egcs-2.91.66 19990314 (egcs-1.1.2 release)
int main(void) {
long t;
void *s = &t;
long count = sizeof(long);
int x1,x2,x3,x4;
if (!count)
return(0);
__asm__ __volatile__(
"lsrl #1,%1 ; jcc 1f ; moveb %2,%0@-\n\t"
"1: lsrl #1,%1 ; jcc 1f ; movew %2,%0@-\n\t"
"1: lsrl #1,%1 ; jcc 1f ; movel %2,%0@-\n\t"
"1: lsrl #1,%1 ; jcc 1f ; movel %2,%0@- ; movel %2,%0@-\n\t"
"1: subql #1,%1 ; jcs 3f\n\t"
"2: moveml %2/%3/%4/%5,%0@-\n\t"
"dbra %1,2b\n\t"
"3:"
: "=a" (s), "=d" (count), "=d" (x1), "=d" (x2), "=d" (x3), "=d" (x4)
: "2" (0), "3" (0), "4" (0), "5" (0),
"0" ((char *)s+count), "1" (count)
);
return(0);
}
Cheers - Tony :)
--
Tony Mantler Renaissance Nerd Extraordinaire eek@escape.ca
Winnipeg, Manitoba, Canada http://www.escape.ca/~eek
More information about the Gcc-bugs
mailing list