gpt4 book ai didi

assembly - bt汇编指令

转载 作者:行者123 更新时间:2023-12-04 13:43:17 26 4
gpt4 key购买 nike

我对bt汇编指令有疑虑。我摘录了本书的一部分以提供上下文。请参阅最后一个示例bt Testme, bx。为什么复制TestMe+8?它不应该复制TestMe+65吗?

非常感谢您的帮助!

6.6.4.2 The Bit Test Instructions: BT, BTS, BTR, and BTC

On an 80386 or later processor, you can use the bt instruction (bit test) to test a single bit. Its second operand specifies the bit index into the first operand. Bt copies the addressed bit into the carry flag. For example, the instruction

  bt  ax, 12

copies bit twelve of ax into the carry flag.

The bt/bts/btr/btc instructions only deal with 16 or 32 bit operands. This is not a limitation of the instruction. After all, if you want to test bit three of the al register, you can just as easily test bit three of the ax register. On the other hand, if the index is larger than the size of a register operand, the result is undefined.

If the first operand is a memory location, the bt instruction tests the bit at the given offset in memory, regardless the value of the index. For example, if bx contains 65 then

  bt  TestMe, bx

will copy bit one of location TestMe+8 into the carry flag. Once again, the size of the operand does not matter. For all intents and purposes, the memory operand is a byte and you can test any bit after that byte with an appropriate index. The actual bit bt tests is at bit position index mod 8 and at memory offset effective address + index/8.

最佳答案

当书中说“位置TestMe+8的一位”时,“8”指的是地址偏移量,以字节为单位。 8字节中有64位,因此第65位是TestMe之后的8个字节的位之一。

  • TestMe处的字节具有位7..0
  • TestMe+1的字节具有位15..8
  • TestMe+2的字节具有位23..16
  • ...
  • TestMe+8的字节具有位71..64

  • 因此,“65”是指地址 TestMe+8处字节的“位1”(从右边开始第二个计数)。

    关于assembly - bt汇编指令,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7508049/

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