5

Assembly IA-32
Does someone know why arithmetic left shift changes the original binary number's sign (1 to 0,vice versa) , but arithmetic right shift keeps the same sign?

Comments
  • 1
    It probably shifts through a caret...
    Instead of

    01010110 - >10101100

    It does

    [0] 11100111 - > [1]11001110

    The [] is just a "inbetween" savetate of your last byte... Hope it helps
  • 1
    @linuxer4fun Yeah a friend of mine explained it to me, it "triggers" the overflow flag, so it does not change sign. Thanks!
  • 0
    @Dreaming no problem ;)
  • 1
    @Dreaming BTW : wittmaxi@outlook.de is my adress, feel free to always ask me questions about asm... Stackoverflow wont do any good
  • 1
    @linuxer4fun thanks for your help :)
  • 2
    There's a difference between arithmetic shifting, and logical shifting. Logical shifting moves the entire bit pattern left or right, while arithmetic shifting preserves the sign bit.

    There's also another kind of shift called a rotate, where the bits going off the end of the word aren't lost but are shifted into the other end.
Add Comment