Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.std.c > #6306

Re: Why is shifting too far undefined behvaior?

From Philipp Klaus Krause <pkk@spth.de>
Newsgroups comp.std.c
Subject Re: Why is shifting too far undefined behvaior?
Date 2021-09-21 20:12 +0200
Message-ID <sid79l$d35$1@solani.org> (permalink)
References <siceh0$1lm$1@solani.org> <87tuidolj1.fsf@nosuchdomain.example.com>

Show all headers | View raw


Am 21.09.21 um 20:01 schrieb Keith Thompson:

>     
>     I looked at my Interdata 8/32 manual (1975), which describes
>     a 32-bit machine, and was amused to find, under the
>     "Shift Left Logical" instruction,
>     
>       "... the shift count is specified by the least significant
>       five bits of the second operand."

The modern Z80N (a Z80 variant used in the ZX Spectrum Next) has a
"shift left arithmetic" that shifts 16-bit register de left by the
number specified in the lower 5 bits of 8-bit register b.

So in SDCC when targeting the Z80N, left-shifting a 16-bit value could,
depending on which register the shifted value gets allocated to, shift
either by the lower 5 bits of the right operand (is the Z80N instruction
is used) or the lower 8 bits of the right operand (if normal code for
Z80 left shift is generated) or by the actual right operand (if the
value of the right operand can be determined at compile time).

Back to comp.std.c | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Why is shifting too far undefined behvaior? Philipp Klaus Krause <pkk@spth.de> - 2021-09-21 13:09 +0200
  Re: Why is shifting too far undefined behvaior? Ike Naar <ike@faeroes.freeshell.org> - 2021-09-21 11:33 +0000
    Re: Why is shifting too far undefined behvaior? Richard Kettlewell <invalid@invalid.invalid> - 2021-09-21 12:47 +0100
  Re: Why is shifting too far undefined behvaior? Richard Damon <Richard@Damon-Family.org> - 2021-09-21 08:29 -0400
    Re: Why is shifting too far undefined behvaior? Vincent Lefevre <vincent-news@vinc17.net> - 2021-09-22 01:17 +0000
      Re: Why is shifting too far undefined behvaior? Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2021-09-21 19:05 -0700
        Re: Why is shifting too far undefined behvaior? James Kuyper <jameskuyper@alumni.caltech.edu> - 2021-09-22 00:02 -0400
          Re: Why is shifting too far undefined behvaior? Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2021-09-21 21:12 -0700
            Re: Why is shifting too far undefined behvaior? James Kuyper <jameskuyper@alumni.caltech.edu> - 2021-09-22 09:42 -0400
          Re: Why is shifting too far undefined behvaior? Richard Damon <Richard@Damon-Family.org> - 2021-09-22 07:08 -0400
            Re: Why is shifting too far undefined behvaior? James Kuyper <jameskuyper@alumni.caltech.edu> - 2021-09-22 09:42 -0400
              Re: Why is shifting too far undefined behvaior? James Kuyper <jameskuyper@alumni.caltech.edu> - 2021-09-23 12:18 -0400
          Re: Why is shifting too far undefined behvaior? Vincent Lefevre <vincent-news@vinc17.net> - 2021-09-23 11:10 +0000
            Re: Why is shifting too far undefined behvaior? James Kuyper <jameskuyper@alumni.caltech.edu> - 2021-09-23 12:22 -0400
        Re: Why is shifting too far undefined behvaior? Vincent Lefevre <vincent-news@vinc17.net> - 2021-09-23 11:08 +0000
  Re: Why is shifting too far undefined behvaior? Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2021-09-21 11:01 -0700
    Re: Why is shifting too far undefined behvaior? Philipp Klaus Krause <pkk@spth.de> - 2021-09-21 20:12 +0200
  Re: Why is shifting too far undefined behvaior? Vincent Lefevre <vincent-news@vinc17.net> - 2021-09-22 01:13 +0000
  Re: Why is shifting too far undefined behvaior? David Brown <david.brown@hesbynett.no> - 2021-09-22 14:25 +0200
    Re: Why is shifting too far undefined behvaior? Vincent Lefevre <vincent-news@vinc17.net> - 2021-09-23 11:17 +0000
  Re: Why is shifting too far undefined behvaior? Tim Rentsch <txr@shamko.com> - 2021-10-09 04:27 -0700

csiph-web