Volume 3 General-Purpose and System Instructions (794097), страница 39
Текст из файла (страница 39)
3.13—July 2007MnemonicOpcodeDescriptionSAR reg/mem32, imm8C1 /7 ibShift a signed 32-bit register or memory location rightthe number of bits specified by an 8-bit immediate value.SAR reg/mem64, 1D1 /7Shift a signed 64-bit register or memory location right 1bit.SAR reg/mem64, CLD3 /7Shift a signed 64-bit register or memory location rightthe number of bits specified in the CL register.SAR reg/mem64, imm8C1 /7 ibShift a signed 64-bit register or memory location rightthe number of bits specified by an 8-bit immediate value.Related InstructionsSAL, SHL, SHR, SHLD, SHRDrFLAGS AffectedIDVIPVIFACVMRFNTIOPLOFDFIFTFM2120191817161413–12111098SFZFAFPFCFMMUMM76420Note: 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.220SARInstruction Reference24594—Rev.
3.13—July 2007AMD64 TechnologySBBSubtract with BorrowSubtracts an immediate value or the value in a register or a memory location (second operand) from aregister or a memory location (first operand), and stores the result in the first operand location. If thecarry flag (CF) is 1, the instruction subtracts 1 from the result. Otherwise, it operates like SUB.The SBB instruction sign-extends immediate value operands to the length of the first operand size.This instruction evaluates the result for both signed and unsigned data types and sets the OF and CFflags to indicate a borrow in a signed or unsigned result, respectively.
It sets the SF flag to indicate thesign of a signed result.This instruction is useful for multibyte (multiword) numbers because it takes into account the borrowfrom a previous SUB instruction.The forms of the SBB instruction that write to memory support the LOCK prefix. For details about theLOCK prefix, see “Lock Prefix” on page 8.MnemonicOpcodeDescriptionSBB AL, imm81C ibSubtract an immediate 8-bit value from the AL registerwith borrow.SBB AX, imm161D iwSubtract an immediate 16-bit value from the AX registerwith borrow.SBB EAX, imm321D idSubtract an immediate 32-bit value from the EAXregister with borrow.SBB RAX, imm321D idSubtract a sign-extended immediate 32-bit value fromthe RAX register with borrow.SBB reg/mem8, imm880 /3 ibSubtract an immediate 8-bit value from an 8-bit registeror memory location with borrow.SBB reg/mem16, imm1681 /3 iwSubtract an immediate 16-bit value from a 16-bit registeror memory location with borrow.SBB reg/mem32, imm3281 /3 idSubtract an immediate 32-bit value from a 32-bit registeror memory location with borrow.SBB reg/mem64, imm3281 /3 idSubtract a sign-extended immediate 32-bit value from a64-bit register or memory location with borrow.SBB reg/mem16, imm883 /3 ibSubtract a sign-extended 8-bit immediate value from a16-bit register or memory location with borrow.SBB reg/mem32, imm883 /3 ibSubtract a sign-extended 8-bit immediate value from a32-bit register or memory location with borrow.SBB reg/mem64, imm883 /3 ibSubtract a sign-extended 8-bit immediate value from a64-bit register or memory location with borrow.SBB reg/mem8, reg818 /rSubtract the contents of an 8-bit register from an 8-bitregister or memory location with borrow.SBB reg/mem16, reg1619 /rSubtract the contents of a 16-bit register from a 16-bitregister or memory location with borrow.Instruction ReferenceSBB221AMD64 Technology24594—Rev.
3.13—July 2007MnemonicOpcodeDescriptionSBB reg/mem32, reg3219 /rSubtract the contents of a 32-bit register from a 32-bitregister or memory location with borrow.SBB reg/mem64, reg6419 /rSubtract the contents of a 64-bit register from a 64-bitregister or memory location with borrow.SBB reg8, reg/mem81A /rSubtract the contents of an 8-bit register or memorylocation from the contents of an 8-bit register withborrow.SBB reg16, reg/mem161B /rSubtract the contents of a 16-bit register or memorylocation from the contents of a 16-bit register withborrow.SBB reg32, reg/mem321B /rSubtract the contents of a 32-bit register or memorylocation from the contents of a 32-bit register withborrow.SBB reg64, reg/mem641B /rSubtract the contents of a 64-bit register or memorylocation from the contents of a 64-bit register withborrow.Related InstructionsSUB, ADD, ADCrFLAGS AffectedIDVIPVIFACVMRFNTIOPLOFDFIFTFM2120191817161413–12111098SFZFAFPFCFMMMMM76420Note: 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.222SBBInstruction Reference24594—Rev. 3.13—July 2007AMD64 TechnologySCASSCASBSCASWSCASDSCASQScan StringCompares the AL, AX, EAX, or RAX register with the byte, word, doubleword, or quadword pointedto by ES:rDI, sets the status flags in the rFLAGS register according to the results, and then incrementsor decrements the rDI register according to the state of the DF flag in the rFLAGS register.If the DF flag is 0, the instruction increments the rDI register; otherwise, it decrements it.
Theinstruction increments or decrements the rDI register by 1, 2, 4, or 8, depending on the size of theoperands.The forms of the SCASx instruction with an explicit operand address the operand at ES:rDI. Theexplicit operand serves only to specify the size of the values being compared.The no-operands forms of the instruction use the ES:rDI registers to point to the value to be compared.The mnemonic determines the size of the operands and the specific register containing the othercomparison value.For block comparisons, the SCASx instructions support the REPE or REPZ prefixes (they aresynonyms) and the REPNE or REPNZ prefixes (they are synonyms). For details about the REPprefixes, see “Repeat Prefixes” on page 9.
A SCASx instruction can also operate inside a loopcontrolled by the LOOPcc instruction.MnemonicOpcodeDescriptionSCAS mem8AECompare the contents of the AL register with the byte atES:rDI, and then increment or decrement rDI.SCAS mem16AFCompare the contents of the AX register with the wordat ES:rDI, and then increment or decrement rDI.SCAS mem32AFCompare the contents of the EAX register with thedoubleword at ES:rDI, and then increment or decrementrDI.SCAS mem64AFCompare the contents of the RAX register with thequadword at ES:rDI, and then increment or decrementrDI.SCASBAECompare the contents of the AL register with the byte atES:rDI, and then increment or decrement rDI.SCASWAFCompare the contents of the AX register with the wordat ES:rDI, and then increment or decrement rDI.Instruction ReferenceSCASx223AMD64 Technology24594—Rev.
3.13—July 2007MnemonicOpcodeDescriptionSCASDAFCompare the contents of the EAX register with thedoubleword at ES:rDI, and then increment or decrementrDI.SCASQAFCompare the contents of the RAX register with thequadword at ES:rDI, and then increment or decrementrDI.Related InstructionsCMP, CMPSxrFLAGS AffectedIDVIPVIFACVMRFNTIOPLOFDFIFTFM2120191817161413–12111098SFZFAFPFCFMMMMM76420Note: 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 ExceptionXA null ES segment was used to reference memory.XXA memory address exceeded the ES segment limit or wasnon-canonical.Page fault, #PFXXA page fault resulted from the execution of the instruction.Alignment check,#ACXXAn unaligned memory reference was performed whilealignment checking was enabled.General protection,#GP224XSCASxInstruction Reference24594—Rev. 3.13—July 2007AMD64 TechnologySETccSet Byte on ConditionChecks the status flags in the rFLAGS register and, if the flags meet the condition specified in themnemonic (cc), sets the value in the specified 8-bit memory location or register to 1. If the flags do notmeet the specified condition, SETcc clears the memory location or register to 0.Mnemonics with the A (above) and B (below) tags are intended for use when performing unsignedinteger comparisons; those with G (greater) and L (less) tags are intended for use with signed integercomparisons.Software typically uses the SETcc instructions to set logical indicators.