The inline assembly I use in one function generates code which the assembler does not understand (it generates a non existant cpu register).
This is the commandline output: Using built-in specs. Target: i586-elf Configured with: ../gcc-4.3.1/configure --target=i586-elf --prefix=/usr/cross -- disable-nls --enable-languages=c,c++ --without-headers --with-newlib Thread model: single gcc version 4.3.1 (GCC) COLLECT_GCC_OPTIONS='-v' '-save-temps' '-S' '-O2' '-mtune=pentium' /usr/cross/libexec/gcc/i586-elf/4.3.1/cc1.exe -E -quiet -v gzip.c -mtune=pentiu m -O2 -fpch-preprocess -o gzip.i ignoring nonexistent directory "/usr/cross/lib/gcc/i586-elf/4.3.1/../../../../i5 86-elf/sys-include" ignoring nonexistent directory "/usr/cross/lib/gcc/i586-elf/4.3.1/../../../../i5 86-elf/include" #include "..." search starts here: #include <...> search starts here: /usr/cross/lib/gcc/i586-elf/4.3.1/include /usr/cross/lib/gcc/i586-elf/4.3.1/include-fixed End of search list. COLLECT_GCC_OPTIONS='-v' '-save-temps' '-S' '-O2' '-mtune=pentium' /usr/cross/libexec/gcc/i586-elf/4.3.1/cc1.exe -fpreprocessed gzip.i -quiet -dum pbase gzip.c -mtune=pentium -auxbase gzip -O2 -version -o gzip.s GNU C (GCC) version 4.3.1 (i586-elf) compiled by GNU C version 3.4.4 (cygming special, gdc 0.12, using dmd 0. 125), GMP version 4.2.2, MPFR version 2.3.1. GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072 Compiler executable checksum: 51cdd6038f6ef46be90f22b7598c4d3c In file included from gzip.c:4: printf.h:9: warning: conflicting types for built-in function 'printf' printf.h:11: warning: conflicting types for built-in function 'putchar' COMPILER_PATH=/usr/cross/libexec/gcc/i586-elf/4.3.1/:/usr/cross/libexec/gcc/i586 -elf/4.3.1/:/usr/cross/libexec/gcc/i586-elf/:/usr/cross/lib/gcc/i586-elf/4.3.1/: /usr/cross/lib/gcc/i586-elf/:/usr/cross/lib/gcc/i586-elf/4.3.1/../../../../i586- elf/bin/ LIBRARY_PATH=/usr/cross/lib/gcc/i586-elf/4.3.1/:/usr/cross/lib/gcc/i586-elf/4.3. 1/../../../../i586-elf/lib/ COLLECT_GCC_OPTIONS='-v' '-save-temps' '-S' '-O2' '-mtune=pentium' ================================================================================= This is the .i file: # 1 "gzip.c" # 1 "<built-in>" # 1 "<command-line>" # 1 "gzip.c" # 1 "gzip.h" 1 # 1 "typedef.h" 1 typedef unsigned char uint8t; typedef unsigned short uint16t; typedef unsigned int uint32t; typedef unsigned long long int uint64t; # 5 "gzip.h" 2 # 22 "gzip.h" #pragma pack(1) struct gzip_hdr_t { uint8t id1; uint8t id2; uint8t cm; uint8t flg; uint32t mtime; uint8t xfl; uint8t os; }; #pragma pack() uint32t gzipIsGZip(uint8t *file); uint32t gzipUnzip(uint8t *file, void *dest); uint8t getNextBit(uint8t *ptr, uint32t *posByte, uint8t *posBit); # 2 "gzip.c" 2 # 1 "printf.h" 1 # 9 "printf.h" void printf(char *format, ...); void printfTrace(char *format, ...); void putchar(char c); void putcharTrace(char c); void itoa(char *str, int num, uint32t base, uint32t flags); void strreverse(char *begin, char *end); uint32t getxy(); void setxy(uint32t x, uint32t y); void scroll_down(); # 4 "gzip.c" 2 uint32t gzipIsGZip(uint8t *file) { struct gzip_hdr_t *gzip= (struct gzip_hdr_t *)file; if(gzip->id1 != 0x1f) return 0; if(gzip->id2 != 0x8b) return 0; if(gzip->cm != 8) return 0; return 1; } uint32t gzipUnzip(uint8t *file, void *dest) { struct gzip_hdr_t *gzip= (struct gzip_hdr_t *)file; uint8t *ptr, final, type, posBit; uint16t crc16, len, *help; uint32t posByte; if(!gzipIsGZip(file)) return 0; ptr= file + sizeof(struct gzip_hdr_t); if(gzip->flg & 0x4) { ptr+= (uint16t)*ptr; } if(gzip->flg & 0x8) { while(*ptr != '\0') { ptr++; } } if(gzip->flg & 0x10) { while(*ptr != '\0') { ptr++; } } if(gzip->flg & 0x2) { crc16= *ptr; ptr++; } posByte= 0; posBit= 0; do { final= getNextBit(ptr,&posByte,&posBit); type= (getNextBit(ptr,&posByte,&posBit) << 1) | getNextBit(ptr,&posByte,&posBit); if(type == 0x3) return 0; if(type == 0x0) { if(posBit != 0) { posBit= 0; posByte++; } help= (uint16t *)((uint32t)ptr + posByte); len= *help; } else { if(type == 0x2) { } } }while(!final); return 1; } uint8t getNextBit(uint8t *ptr, uint32t *posByte, uint8t *posBit) { uint8t *help= ptr + *posByte, res; asm volatile("testb %2,%1\n\t" "setne %0" :"=r"(res) :"r"(*help),"r"((uint8t)(1 << *posBit))); if(*posBit == 7) { *posBit= 0; (*posByte)++; } else { (*posBit)++; } return res; } -- Summary: inline assembly generates wrong code Product: gcc Version: 4.3.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: inline-asm AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: codemasterhs at yahoo dot de GCC host triplet: cygwin GCC target triplet: i586-elf http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36514