SHR和SAR命令 [英] SHR and SAR Commands

查看:146
本文介绍了SHR和SAR命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想确保我100%理解了这个概念,如果没有得到澄清.

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

在asm程序中,如果执行SHR 00110000b,则最终会得到00011000b. 但是,如果要在11111111b上执行SHR,您将得到错误的答案,应改为使用SAR?这是因为数字已签名?

In an asm program, if you perform SHR 00110000b you would end up with 00011000b. However, if you were to perform SHR on 11111111b you would end up with an incorrect answer and should use SAR instead? This is because the number is signed?

推荐答案

如果执行SHR 00110000b,则结果为00011000b

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

如果您向右移动一位,那就可以.您可以指定移动量,因此它不会固定为1.

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

但是,如果您要在11111111b上执行SHR,则会得到错误的答案

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

如果您对11111111b进行了逻辑右移一位,则会得到01111111b.您是否认为这是不正确的,完全取决于您要实现的目标.如果您想保留标志,应该使用SAR.

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.

这篇关于SHR和SAR命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆