Path: utzoo!attcan!uunet!igor!dsb@Rational.COM From: dsb@Rational.COM (David S. Bakin) Newsgroups: comp.lang.c Subject: Re: "for" loops in C ... Message-ID: <339@igor.Rational.COM> Date: 8 Nov 88 19:19:04 GMT References: <867@cernvax.UUCP> <645@quintus.UUCP> Sender: news@igor.Rational.COM Reply-To: dsb@Rational.COM (David S. Bakin) Organization: Rational Lines: 33 In-reply-to: ok@quintus.uucp (Richard A. O'Keefe) [What's going on? The article I'm replying to was signed by Chris Torek of uunet!mimsy!chris but the headers say it is from ok@quintus.uucp???] In article <645@quintus.UUCP>, ok@quintus (Richard A. O'Keefe) writes: >In article <192@libove.UUCP> root@libove.UUCP (Jay M. Libove) writes: >>Looking at the above, I read it to be "shift an n-bit integer n bits left" >>... Now, why is there any question as to the result? > >Because different machines implement shift-left differently. > > ... [omitted] > >On the VAX, the result of shifting by the (not known to be constant) >value 32 is the same as the result of shifting by zero, because the VAX >looks only at the 5 lowest order bits of the shift count. It does this >so that right shifts can be done with negative left shifts. >-- >In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7163) >Domain: chris@mimsy.umd.edu Path: uunet!mimsy!chris I don't get it. The operator << is defined in C as a left shift, what does that have to do with a particular VAX instruction, ASHL, that happens to mask its operand to the low-order 5 bits. Doesn't this merely mean that on the VAX when the argument of the left shift is not a known constant that the single instruction ASH sequence must be replaced by a multiple instruction sequence that does the right thing? -- Dave ---------------------------------------------------------- Dave Bakin (408) 496-3600 c/o Rational; 3320 Scott Blvd.; Santa Clara, CA 95054-3197 Internet: dsb@rational.com Uucp: ...!uunet!igor!dsb