Count Leading Zeros counts the number of binary zero bits before the first binary one bit in the value of the source register, and writes the result to the destination register.
该指令用于计算最高符号位与第一个1之间的0的个数。当一些操作数需要规范化(使其最高位为1)时 ,该指令用于计算操作数需要左移的位数,以及确定一个优先级掩码中最高优先级(最高位的优先级)。
CLZ指令用于计算寄存器中操作数的最高位0的个数,如果操作数的bit[31]为1,则返回0,如果操作数全为0 ,则指令返回 64 或 32 .
32-bit variant
Applies when sf == 0.
CLZ <Wd>, <Wn>
64-bit variant
Applies when sf == 1.
CLZ <Xd>, <Xn>
Decode for all variants of this encoding
integer d = UInt(Rd);
integer n = UInt(Rn);
integer datasize = if sf == '1' then 64 else 32;
Operation
integer result;
bits(datasize) operand1 = X[n];
result = CountLeadingZeroBits(operand1);
X[d] = result<datasize-1:0>;
integer CountLeadingZeroBits(bits(N) x)
return N - (HighestSetBit(x) + 1);
integer HighestSetBit(bits(N) x)
for i = N-1 downto 0
if x<i> == '1' then return i;
return -1;
版权声明:
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。
如若内容造成侵权、违法违规、事实不符,请将相关资料发送至xkadmin@xkablog.com进行投诉反馈,一经查实,立即处理!
转载请注明出处,原文链接:https://www.xkablog.com/cjjbc/33620.html