is there any word processing software for the pdp11?
Chuck Guzis
cclist at sydex.com
Thu Dec 4 17:15:44 CST 2014
On 12/04/2014 01:50 PM, Peter Corlett wrote:
> On Tue, Dec 02, 2014 at 03:32:38PM -0800, Fred Cisin wrote:
>> . . .
>>>>> long long int A;
>>>>> int B;
>>>>> A = B << 32;
> The C99 (draft) standard says of << and >> that "[t]he behavior is undefined if
> the right operand is negative, or greater than or equal to the length in bits
> of the promoted left operand", with the C++ standard using much the same words
> but in a different order. There are all sorts of edge cases and caveats in the
> standard, but I've not omitted anything relevant.
I think that Fred's also hinting at differences in x86 architecture as
well.
Some members of the family shift modulo (data item bit length);
others shift (shift_count => data_length ? 0 : item << shift_count)
And then there are some compiler implementations that direct the shift
operator to an intrinsic library routine and shift one bit at a time, in
a loop (the old Lattice C compiler would do this).
So, the same code on either system yields a different result--and it's
dangerous for any compiler to make any assumption about how the
instruction operates.
You could, of course, standardize the meaning of << on a particular
platform by AND-ing the shift count with (data item bit length -1) --
which may or may not be what the writer intended.
There, the best solution is to shoot the programmer for even writing
such stuff.
--Chuck
More information about the cctech
mailing list