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

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

AMD64 Technology 24594 Rev. 3.10 February 2005BSFBit Scan ForwardSearches the value in a register or a memory location (second oper<strong>and</strong>) for the leastsignificantset bit. If a set bit is found, the instruction clears the zero flag (ZF) <strong>and</strong>stores the index of the least-significant set bit in a destination register (first oper<strong>and</strong>).If the second oper<strong>and</strong> contains 0, the instruction sets ZF to 1 <strong>and</strong> does not change thecontents of the destination register. The bit index is an unsigned offset from bit 0 ofthe searched value.Mnemonic Opcode DescriptionBSF reg16, reg/mem16 0F BC /r Bit scan forward on the contents of reg/mem16.BSF reg32, reg/mem32 0F BC /r Bit scan forward on the contents of reg/mem32.BSF reg64, reg/mem64 0F BC /r Bit scan forward on the contents of reg/mem64Related <strong>Instructions</strong>BSRrFLAGS AffectedID VIP VIF AC VM RF NT IOPL OF DF IF TF SF ZF AF PF CFExceptionsU U M U U U21 20 19 18 17 16 14 13–12 11 10 9 8 7 6 4 2 0Note: Bits 31–22, 15, 5, 3, <strong>and</strong> 1 are reserved. A flag set to 1 or cleared to 0 is M (modified). Unaffected flags are blank. Undefinedflags are U.Exception RealVirtual8086 Protected Cause of ExceptionStack, #SS X X X A memory address exceeded the stack segment limit or was noncanonical.<strong>General</strong> protection,#GPX X XA memory address exceeded a data segment limit or was non-canonical.XA null data segment was used to reference memory.74 BSF

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

Saved successfully!

Ooh no, something went wrong!