Volume 3 General-Purpose and System Instructions (794097), страница 18
Текст из файла (страница 18)
If the bit index is in a register, the instruction selects a bit position relative to the bit basein the range –263 to +263 – 1 if the operand size is 64, –231 to +231 – 1, if the operand size is 32, and–215 to +215 – 1 if the operand size is 16. If the bit index is in an immediate value, the bit selected isthat value modulo 16, 32, or 64, depending on operand size.When the instruction attempts to copy a bit from memory, it accesses 2, 4, or 8 bytes starting from thespecified memory address for 16-bit, 32-bit, or 64-bit operand sizes, respectively, using the followingformula:Effective Address + (NumBytesi * (BitOffset DIV NumBitsi*8))When using this bit addressing mechanism, avoid referencing areas of memory close to address spaceholes, such as references to memory-mapped I/O registers.
Instead, use a MOV instruction to load aregister from such an address and use a register form of the BT instruction to manipulate the data.MnemonicOpcodeDescriptionBT reg/mem16, reg160F A3 /rCopy the value of the selected bit to the carry flag.BT reg/mem32, reg320F A3 /rCopy the value of the selected bit to the carry flag.BT reg/mem64, reg640F A3 /rCopy the value of the selected bit to the carry flag.BT reg/mem16, imm80F BA /4 ibCopy the value of the selected bit to the carry flag.BT reg/mem32, imm80F BA /4 ibCopy the value of the selected bit to the carry flag.BT reg/mem64, imm80F BA /4 ibCopy the value of the selected bit to the carry flag.Related InstructionsBTC, BTR, BTS68BTInstruction Reference24594—Rev. 3.13—July 2007AMD64 TechnologyrFLAGS AffectedIDVIPVIFACVMRFNTIOPLOFDFIFTFU2120191817161413–12111098SFZFAFPFCFUUUUM76420Note: Bits 31–22, 15, 5, 3, and 1 are reserved.
A flag set to 1 or cleared to 0 is M (modified). Unaffected flags areblank. Undefined flags are U.ExceptionsExceptionVirtualReal 8086 ProtectedCause of ExceptionStack, #SSXXXA memory address exceeded the stack segment limit or wasnon-canonical.General protection,#GPXXXA memory address exceeded a data segment limit or was noncanonical.XA null data segment was used to reference memory.Page fault, #PFXXA page fault resulted from the execution of the instruction.Alignment check,#ACXXAn unaligned memory reference was performed whilealignment checking was enabled.Instruction ReferenceBT69AMD64 Technology24594—Rev.
3.13—July 2007BTCBit Test and ComplementCopies a bit, specified by a bit index in a register or 8-bit immediate value (second operand), from a bitstring (first operand), also called the bit base, to the carry flag (CF) of the rFLAGS register, and thencomplements (toggles) the bit in the bit string.If the bit base operand is a register, the instruction uses the modulo 16, 32, or 64 (depending on theoperand size) of the bit index to select a bit in the register.If the bit base operand is a memory location, bit 0 of the byte at the specified address is the bit base ofthe bit string. If the bit index is in a register, the instruction selects a bit position relative to the bit basein the range –263 to +263 – 1 if the operand size is 64, –231 to +231 – 1, if the operand size is 32, and–215 to +215 – 1 if the operand size is 16.
If the bit index is in an immediate value, the bit selected isthat value modulo 16, 32, or 64, depending the operand size.This instruction is useful for implementing semaphores in concurrent operating systems. Such anapplication should precede this instruction with the LOCK prefix. For details about the LOCK prefix,see “Lock Prefix” on page 8.MnemonicOpcodeDescriptionBTC reg/mem16, reg160F BB /rCopy the value of the selected bit to the carry flag, thencomplement the selected bit.BTC reg/mem32, reg320F BB /rCopy the value of the selected bit to the carry flag, thencomplement the selected bit.BTC reg/mem64, reg640F BB /rCopy the value of the selected bit to the carry flag, thencomplement the selected bit.BTC reg/mem16, imm80F BA /7 ibCopy the value of the selected bit to the carry flag, thencomplement the selected bit.BTC reg/mem32, imm80F BA /7 ibCopy the value of the selected bit to the carry flag, thencomplement the selected bit.BTC reg/mem64, imm80F BA /7 ibCopy the value of the selected bit to the carry flag, thencomplement the selected bit.Related InstructionsBT, BTR, BTS70BTCInstruction Reference24594—Rev.
3.13—July 2007AMD64 TechnologyrFLAGS AffectedIDVIPVIFACVMRFNTIOPLOFDFIFTFU2120191817161413–12111098SFZFAFPFCFUUUUM76420Note: Bits 31–22, 15, 5, 3, and 1 are reserved. A flag set to 1 or cleared to 0 is M (modified). Unaffected flags areblank. Undefined flags are U.ExceptionsExceptionStack, #SSVirtualReal 8086 ProtectedCause of ExceptionXXXA memory address exceeded the stack segment limit or wasnon-canonical.XXXA memory address exceeded a data segment limit or was noncanonical.XThe destination operand was in a non-writable segment.XA null data segment was used to reference memory.General protection,#GPPage fault, #PFXXA page fault resulted from the execution of the instruction.Alignment check,#ACXXAn unaligned memory reference was performed whilealignment checking was enabled.Instruction ReferenceBTC71AMD64 Technology24594—Rev.
3.13—July 2007BTRBit Test and ResetCopies a bit, specified by a bit index in a register or 8-bit immediate value (second operand), from a bitstring (first operand), also called the bit base, to the carry flag (CF) of the rFLAGS register, and thenclears the bit in the bit string to 0.If the bit base operand is a register, the instruction uses the modulo 16, 32, or 64 (depending on theoperand size) of the bit index to select a bit in the register.If the bit base operand is a memory location, bit 0 of the byte at the specified address is the bit base ofthe bit string.
If the bit index is in a register, the instruction selects a bit position relative to the bit basein the range –263 to +263 – 1 if the operand size is 64, –231 to +231 – 1, if the operand size is 32, and–215 to +215 – 1 if the operand size is 16. If the bit index is in an immediate value, the bit selected isthat value modulo 16, 32, or 64, depending on the operand size.This instruction is useful for implementing semaphores in concurrent operating systems. Suchapplications should precede this instruction with the LOCK prefix. For details about the LOCK prefix,see “Lock Prefix” on page 8.MnemonicOpcodeDescriptionBTR reg/mem16, reg160F B3 /rCopy the value of the selected bit to the carry flag, thenclear the selected bit.BTR reg/mem32, reg320F B3 /rCopy the value of the selected bit to the carry flag, thenclear the selected bit.BTR reg/mem64, reg640F B3 /rCopy the value of the selected bit to the carry flag, thenclear the selected bit.BTR reg/mem16, imm80F BA /6 ibCopy the value of the selected bit to the carry flag, thenclear the selected bit.BTR reg/mem32, imm80F BA /6 ibCopy the value of the selected bit to the carry flag, thenclear the selected bit.BTR reg/mem64, imm80F BA /6 ibCopy the value of the selected bit to the carry flag, thenclear the selected bit.Related InstructionsBT, BTC, BTS72BTRInstruction Reference24594—Rev.
3.13—July 2007AMD64 TechnologyrFLAGS AffectedIDVIPVIFACVMRFNTIOPLOFDFIFTFU2120191817161413–12111098SFZFAFPFCFUUUUM76420Note: Bits 31–22, 15, 5, 3, and 1 are reserved. A flag set to 1 or cleared to 0 is M (modified). Unaffected flags areblank. Undefined flags are U.ExceptionsExceptionStack, #SSVirtualReal 8086 ProtectedCause of ExceptionXXXA memory address exceeded the stack segment limit or wasnon-canonical.XXXA memory address exceeded a data segment limit or was noncanonical.XThe destination operand was in a non-writable segment.XA null data segment was used to reference memory.General protection,#GPPage fault, #PFXXA page fault resulted from the execution of the instruction.Alignment check,#ACXXAn unaligned memory reference was performed whilealignment checking was enabled.Instruction ReferenceBTR73AMD64 Technology24594—Rev. 3.13—July 2007BTSBit Test and SetCopies a bit, specified by bit index in a register or 8-bit immediate value (second operand), from a bitstring (first operand), also called the bit base, to the carry flag (CF) of the rFLAGS register, and thensets the bit in the bit string to 1.If the bit base operand is a register, the instruction uses the modulo 16, 32, or 64 (depending on theoperand size) of the bit index to select a bit in the register.If the bit base operand is a memory location, bit 0 of the byte at the specified address is the bit base ofthe bit string.