13.07.2015 Views

Volume 3: General-Purpose and System Instructions - Stanford ...

Volume 3: General-Purpose and System Instructions - Stanford ...

Volume 3: General-Purpose and System Instructions - Stanford ...

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

24594 Rev. 3.10 February 2005 AMD64 TechnologyBTSBit Test <strong>and</strong> SetCopies a bit, specified by bit index in a register or 8-bit immediate value (secondoper<strong>and</strong>), from a bit string (first oper<strong>and</strong>), also called the bit base, to the carry flag(CF) of the rFLAGS register, <strong>and</strong> then sets the bit in the bit string to 1.If the bit base oper<strong>and</strong> is a register, the instruction uses the modulo 16, 32, or 64(depending on the oper<strong>and</strong> size) of the bit index to select a bit in the register.If the bit base oper<strong>and</strong> is a memory location, bit 0 of the byte at the specified addressis the bit base of the bit string. If the bit index is in a register, the instruction selects abit position relative to the bit base in the range –2 63 to +2 63 – 1 if the oper<strong>and</strong> size is64, –2 31 to +2 31 – 1, if the oper<strong>and</strong> size is 32, <strong>and</strong> –2 15 to +2 15 – 1 if the oper<strong>and</strong> size is16. If the bit index is in an immediate value, the bit selected is that value modulo 16,32, or 64, depending on the oper<strong>and</strong> size.This instruction is useful for implementing semaphores in concurrent operatingsystems. Such applications should precede this instruction with the LOCK prefix. Fordetails about the LOCK prefix, see “Lock Prefix” on page 10.Mnemonic Opcode DescriptionBTS reg/mem16, reg16 0F AB /rBTS reg/mem32, reg32 0F AB /rBTS reg/mem64, reg64 0F AB /rBTS reg/mem16, imm80F BA /5 ibBTS reg/mem32, imm80F BA /5 ibBTS reg/mem64, imm80F BA /5 ibCopy the value of the selected bit to the carry flag, then set theselected bit.Copy the value of the selected bit to the carry flag, then set theselected bit.Copy the value of the selected bit to the carry flag, then set theselected bit.Copy the value of the selected bit to the carry flag, then set theselected bit.Copy the value of the selected bit to the carry flag, then set theselected bit.Copy the value of the selected bit to the carry flag, then set theselected bit.Related <strong>Instructions</strong>BT, BTC, BTRBTS 85

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!