From: jasonp AT Glue DOT umd DOT edu (Jason Stratos Papadopoulos) Newsgroups: comp.os.msdos.djgpp Subject: why won't this program compile? Date: 26 Oct 1997 06:51:35 GMT Organization: University of Maryland, College Park Lines: 60 Message-ID: <62up9n$grf$1@hecate.umd.edu> NNTP-Posting-Host: y.glue.umd.edu To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk I guess I should be more specific. With no optimization GAs bails out during assembly (I think it adds extra sets of parentheses to the memory operands in square() and then gets confused by them). However, with -O3 it compiles fine. What gives?! I think the reason is that with full optimization (%0) becomes (%ebp) -or whatever- but with anything else %0 is something like 4(%ebp) and the assembler chokes on (4(%ebp)). Is this on the right track? It's certainly very strange, but for another program I have which uses this function it won't run at all (-O2 will compile but running the executable gives a general protection fault. Thanks in advance, jasonp ----------------CUT HERE INCLUDING THIS LINE----------------------- #include #include void square( unsigned long *a, unsigned long *b ){ /* This function squares a 48-bit number "a" into a 96 bit number "b", stored in binary and in little- endian order. */ __asm__ (" movl (%0), %%eax \n mull %%eax \n movl %%eax, (%1) \n movl 4(%0), %%eax \n mull %%eax \n movl %%eax, 8(%1) \n movl %%edx, 4(%1) \n movl 4(%0), %%eax \n mull (%0) \n addl %%eax, %%eax \n adcl %%edx, %%edx \n addl %%eax, 4(%1) \n adcl %%edx, (%1) \n" : : "g"(a), "g"(b) : "%eax", "%edx", "memory"); } /*---------------------------------------------------------------------*/ int main( int argc, char *argv[] ) { unsigned long b[3], a[2]; a[0]=atol(argv[1]); a[1]=atol(argv[2]); square(a,b); printf("%.8x %.8x %.8x\n\n", b[0], b[1], b[2]); return 0; }