title: bt assembly instruction
body: <p>I have quesetion about <code>bt</code> assembly instruction. I have excerpted part of book to provide context. Please see last example, <code>bt Testme, bx</code>. Why does that copy <code>TestMe+8</code>? Shouldn't it copy <code>TestMe+65</code>?</p>
  
  <p>Very much thank you for help!</p>
  
  <blockquote>
    <h3>6.6.4.2 The Bit Test Instructions: BT, BTS, BTR, and BTC</h3>
    
    <p>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</p>
  
  <pre><code>  bt  ax, 12
  </code></pre>
    
    <p>copies bit twelve of ax into the carry flag.</p>
    
    <p>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.</p>
    
    <p>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</p>
  
  <pre><code>  bt  TestMe, bx
  </code></pre>
    
    <p>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.</p>
  </blockquote>