G
Gordon Burditt
The code:
ANSI C says it's ok. It probably does that because lots of compilers,
I suspect from the PDP-11 on, did just that. Personally, I agree
with you; out-of-range counts should cause core dumps. But the
speed freaks don't like it.
I don't agree that the cast is illogical. And dealing with this
doesn't have to generate inefficient code in the cases where it's
NOT needed, unlike the shift case, which slows down all variable shifts.
I have heard of some peculiar cases where shift used rotate instead
(there were no shift instructions on that machine) and some masking
was used which went a bit haywire when the count was out of range.
I don't remember what machine it was, though.
Gordon L. Burditt
That all is correct, no doubt, however, my personal opinion is that that's
wrong to take the shift count and blindly feed it to the asm instruction
with such a limitation.
ANSI C says it's ok. It probably does that because lots of compilers,
I suspect from the PDP-11 on, did just that. Personally, I agree
with you; out-of-range counts should cause core dumps. But the
speed freaks don't like it.
It's as illogical as the need to cast one of two
integer multipliers to long integer in order to get the correct long integer
product.
I don't agree that the cast is illogical. And dealing with this
doesn't have to generate inefficient code in the cases where it's
NOT needed, unlike the shift case, which slows down all variable shifts.
That strikes the math guys in the back. Anyway, I was talking about
a slightly different problem of the shift -- whether or not it's SAR-like or
something else, especially something very odd, probably not any kind of
shift at all.
I have heard of some peculiar cases where shift used rotate instead
(there were no shift instructions on that machine) and some masking
was used which went a bit haywire when the count was out of range.
I don't remember what machine it was, though.
Gordon L. Burditt