X-Authentication-Warning: delorie.com: mailnull set sender to djgpp-bounces using -f Message-ID: <3C61E6BB.7F9AD526@yahoo.com> From: CBFalconer Organization: Ched Research X-Mailer: Mozilla 4.75 [en] (Win98; U) X-Accept-Language: en MIME-Version: 1.0 Newsgroups: comp.os.msdos.djgpp,comp.lang.c Subject: gcc 2.953 output - is this a bug? Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Lines: 49 Date: Thu, 07 Feb 2002 02:31:00 GMT NNTP-Posting-Host: 12.90.175.128 X-Complaints-To: abuse AT worldnet DOT att DOT net X-Trace: bgtnsc05-news.ops.worldnet.att.net 1013049060 12.90.175.128 (Thu, 07 Feb 2002 02:31:00 GMT) NNTP-Posting-Date: Thu, 07 Feb 2002 02:31:00 GMT To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com Please look at the following disassembly: 00000578 <_hshstrehash>: /* 1------------------1 */ /* ReHash a string quantity */ unsigned long hshstrehash(const char * string) { 578: 55 push %ebp 579: 89 e5 mov %esp,%ebp 57b: 8b 4d 08 mov 0x8(%ebp),%ecx unsigned long h; h = 0; 57e: 31 d2 xor %edx,%edx while (*string) { 580: 80 39 00 cmpb $0x0,(%ecx) 583: 74 12 je 597 <_hshstrehash+0x1f> h = h * 37UL + (unsigned char) *string++; 585: 8d 04 d2 lea (%edx,%edx,8),%eax <<*** 588: 8d 04 82 lea (%edx,%eax,4),%eax <<*** 58b: 31 d2 xor %edx,%edx 58d: 8a 11 mov (%ecx),%dl 58f: 41 inc %ecx 590: 01 c2 add %eax,%edx } 592: 80 39 00 cmpb $0x0,(%ecx) 595: 75 ee jne 585 <_hshstrehash+0xd> return h; 597: 89 d0 mov %edx,%eax 599: 89 ec mov %ebp,%esp 59b: 5d pop %ebp 59c: c3 ret } /* hshstrehash */ look at the lines marked "<<***". I fail to see how this implements h * 37UL. This is compiled with -O2 and disassembled by objdump -dS. c.l.c justification - purely standard source code :-) I AM impressed by gcc's code generation. -- Chuck F (cbfalconer AT yahoo DOT com) (cbfalconer AT XXXXworldnet DOT att DOT net) Available for consulting/temporary embedded and systems. (Remove "XXXX" from reply address. yahoo works unmodified) mailto:uce AT ftc DOT gov (for spambots to harvest)