gpt4 book ai didi

c++ - BSF 操作码不工作

转载 作者:太空狗 更新时间:2023-10-29 23:23:33 24 4
gpt4 key购买 nike

我正在使用 Visual Studio 2010 专业版,我刚刚在 Debug模式下检查 BSF 无法正常工作我尝试了很多组合,但没有一个有效!

__asm
{
mov ebx, 0ffffffh;
bsf ecx, ebx;
};

上面的代码至少给了我一些结果,但我在 ecx 寄存器上得到了 0(我使用的是 64 位 win7,应用程序是 32 位)

以下是英特尔对 BSF 的评价:

Searches the source operand (second operand) for the least significant set bit (1 bit). If a least significant 1 bit is found, its bit index is stored in the destination operand (first operand). The source operand can be a register or a memory location; the destination operand is a register. The bit index is an unsigned offset from bit 0 of the source operand. If the content of the source operand is 0, the content of the destination operand is undefined.

有人有什么想法吗?谢谢大家...

最佳答案

您将 ecx 设置为 0,因为值 0xffffff 中的最低有效位(最低?)1 位 位 0 . 其二进制数是 0000 .... 1111 1111 1111 1111 1111 1111

换句话说,您看到的结果是正确的。

例如,如果您在 0xfc 上尝试(二进制 1111 1100),您应该得到 2。这是因为最低有效位位于最右边的位置二进制数:

Hex        F    C
Binary 1111 1100
Bit# 7654 3210
^
|
+-- rightmost (least significant) 1-bit

关于c++ - BSF 操作码不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5677221/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com