rtdsc, asm. Compiler meckert: "can't find a register in class 'AREG'
Hallo Freunde! Aus diesem Programm kompilierte das folgende Stück mit gcc 2.81 gut und funktionierte gut, aber gcc 3.2 sagt: "can't find a register in class 'AREG' while reloading 'asm' " zu der Zeile, wo das erste mal 'mull' vorkommt! (markiert mit --->) Wenn ich diese Zeile auskommentierte, kompilierte es, funktionierte aber natürlich nicht. Was kann ich da tweaken, oder wo mich belesen? /*****************************************************************************/ * * refclock.c -- Accurate reference clock for half duplex soundcards. * static unsigned int scale_tvusec; static unsigned int last_tvusec; static unsigned long long time_cnt; if (rdtsc_ok) { unsigned int tmp0, tmp1; unsigned int tmp2, tmp3; __asm__("rdtsc;\n\t" "subl %2,%%eax\n\t" "sbbl %3,%%edx\n\t" : "=&a" (tmp0), "=&d" (tmp1) : "m" (starttime_lo), "m" (starttime_hi)); ---> __asm__("mull %1" : "=d" (tmp2) : "m" (scale_rdtsc), "a" (tmp0) : "ax"); __asm__("mull %1" : "=a" (tmp3) : "m" (scale_rdtsc), "a" (tmp1) : "dx"); curtime = tmp2 + tmp3; goto time_known; Danke! Günther Safari.Doktor@addcom.de
Hi, On Fri, 28 Nov 2003, [iso-8859-15] Günther Montag wrote:
zu der Zeile, wo das erste mal 'mull' vorkommt! (markiert mit --->)
Clobbers werden schon vor den Inputs geclobbert. Du hast eax als Input und als Clobber, GCC sieht das dieser Input nicht verwendet werden kann, und gibt eben den Fehler aus (zugegeben, nicht sehr erhellend die Meldung). Du willst sowas: unsigned int ignore; __asm__("mull %2" : "=d" (tmp2), "=a" (ignore) : "m" (scale_rdtsc), "1" (tmp0)); __asm__("mull %2" : "=d" (ignore), "=a" (tmp3) : "m" (scale_rdtsc), "1" (tmp1)); I.e. keine Clobber, sondern Input/output. Ciao, Micha.
Am Freitag 28 November 2003 14:37 schrieb Michael Matz:
unsigned int ignore; __asm__("mull %2"
: "=d" (tmp2), "=a" (ignore) : "m" (scale_rdtsc), "1" (tmp0));
__asm__("mull %2"
: "=d" (ignore), "=a" (tmp3) : "m" (scale_rdtsc), "1" (tmp1));
I.e. keine Clobber, sondern Input/output.
Ciao, Micha. Danke! Ist kompiliert! Wird probiert!
Ich hab da noch ein Problem... Noch ein asm. Ist dann das letzte. /*****************************************************************************/ /* * filtbench.c -- "benchmark" several filter implementations. * * Copyright (C) 1997 Thomas Sailer (sailer@ife.ee.ethz.ch) * Swiss Federal Institute of Technology (ETH), Electronics Lab #ifdef __i386__ static int filt3(short *in, int *coeff) { int res = FILTLEN; __asm__ __volatile__ ("xorl %%ebx,%%ebx\n\t" "xorl %%ecx,%%ecx\n\t" "\n1:\n\t" "movswl (%%esi),%%eax\n\t" "imull (%%edi)\n\t" "addl $2,%%esi\n\t" "addl $4,%%edi\n\t" "addl %%eax,%%ebx\n\t" "adcl %%edx,%%ecx\n\t" "decl %1\n\t" "jnz 1b\n\t" "shrdl $15,%%ecx,%%ebx\n\t" "# sarl $15,%%ecx ! high part unneccessary\n\t" "movl %2,%%eax\n\t" "imull %%ebx\n\t" "movl %%edx,%%eax\n\t" : "=&a" (res) : "o" (res), "i" (0x200000000ULL / FILTLEN), "S" (in), "D" (coeff) : "ax", "bx", "cx", "dx", "si", "di"); return res; } #else static int filt3(short *in, int *coeff) { return 0; } #endif /* --------------------------------------------------------------------- */ Fast wie gehabt, nur komplizierter. Der Compiler (gcc 3.2) sagt: warning: asm operand 1 probably doesn't match constraints und das gewohnte can't find a register in class 'AREG' while reloading asm Und ... wo kann ich mich als Anfänger "einlesen" ? Danke! Günther
participants (2)
-
Günther Montag
-
Michael Matz