From: Paul Shirley Newsgroups: comp.os.msdos.djgpp Subject: Re: Infinite loop??? Date: Fri, 10 Jul 1998 19:17:28 +0100 Organization: wot? me? Message-ID: References: <35A3D8C3 DOT 208E6D23 AT cyberdude DOT com> <35A5FC72 DOT C235F6D9 AT eik DOT bme DOT hu> NNTP-Posting-Host: chocolat.foobar.co.uk Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Lines: 24 To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk In article <35A5FC72 DOT C235F6D9 AT eik DOT bme DOT hu>, Dr. András Sólyom writes >For the left shift operator BCC uses an > SHL (shift left) >instruction, while GCC uses > SAL (arithmetic shift left) >I think these differ in how they uses the CARRY bit > >why is it so? > AFAIK the implementation of the left shift operator is left to the >compiler >maker by the ANSI C specification. The >> operator is clearly defined. For signed operands it does an arithmetic shift, unsigned ops get a zero extending shift. If you see anything different its a compiler bug. You should check the type of the value being shifted to explain the difference you see. In particular shifting a char type may cause differences between compilers because a char may be signed or unsigned by default in older compilers. --- Paul Shirley: my email address is 'obvious'ly anti-spammed