SHR and SAR Commands

前端 未结 1 768
梦谈多话
梦谈多话 2021-01-24 12:39

I would like to make sure I am understanding this concept 100% and if not get some clarification.

In an asm program, if you perform SHR 00110000b you would

1条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-01-24 13:12

    if you perform SHR 00110000b you would end up with 00011000b

    If you shifted one bit to the right, yes. You can specify the shift amount, so it's not fixed at 1.

    However, if you were to perform SHR on 11111111b you would end up with an incorrect answer

    If you did a logical shift of 11111111b one bit to the right you'd get 01111111b. Whether you consider that to be incorrect or not depends entirely on what you're trying to achieve. If you wanted to preserve the sign you should've used SAR.

    0 讨论(0)
提交回复
热议问题