SETcc
Usage: SETcc dest Modifies flags:none
Sets the 'dest' operand to 0 or 1 depending on the state of the EFLAGS register (CF, SF, OF, ZF, and PF flags).
Set Byte on Condition
SETcc r/m8 ; 0F 90+cc /2 [386]
SETcc sets the given 8-bit operand to zero if its condition is not satisfied, and to 1 if it is. The 'dest' operand points to a byte register or a byte in memory. The condition code suffix (cc) indicates the condition being tested for.
The terms 'above' and 'below' are associated with the CF flag and refer to the relationship between two unsigned integer values. The terms 'greater' and 'less' are associated with the SF and OF flags and refer to the relationship between two signed integer values.
Many of the SETcc instruction opcodes have alternate mnemonics. For example, SETG (set byte if greater) and SETNLE (set if not less or equal) have the same opcode and test for the same condition: ZF equals 0 and SF equals OF.
These alternate mnemonics are provided to make code more intelligible.
SETE/SETZ Set byte if equal/Set byte if zero
SETNE/SETNZ Set byte if not equal/Set byte if not zero
SETA/SETNBE Set byte if above/Set byte if not below or equal
SETAE/SETNB/SETNC Set byte if above or equal/Set byte if not below/Set byte if not carry
SETB/SETNAE/SETC Set byte if below/Set byte if not above or equal/Set byte if carry
SETBE/SETNA Set byte if below or equal/Set byte if not above
SETG/SETNLE Set byte if greater/Set byte if not less or equal
SETGE/SETNL Set byte if greater or equal/Set byte if not less
SETL/SETNGE Set byte if less/Set byte if not greater or equal
SETLE/SETNG Set byte if less or equal/Set byte if not greater
SETS Set byte if sign (negative)
SETNS Set byte if not sign (non-negative)
SETO Set byte if overflow
SETNO Set byte if not overflow
SETPE/SETP Set byte if parity even/Set byte if parity
SETPO/SETNP Set byte if parity odd/Set byte if not parity
EXAMPLE:
setna Label | sete Label | setz Label | setc Label | setne Label | setnc Label
SCASW
Usage: SCASW Modifies flags: AF CF OF PF SF ZF
Compares word value at EDI from the accumulator and sets the flags similar to a subtraction. EDI is incremented/decremented by 2 and the state of the Direction Flag. Use with REP prefixes.
Scan String
SCASB ; AE [8086]
SCASW ; o16 AF [8086]
SCASD ; o32 AF [386]
SCASB compares the byte in AL with the byte at EDI, and sets the flags accordingly. It then increments or decrements (depending on the direction flag: increments if the flag is clear, decrements if it is set) EDI.
SCASW and SCASD work in the same way, but they compare a word to AX or a doubleword to EAX instead of a byte to AL, and increment or decrement the addressing registers by 2 or 4 instead of 1.
The REPE and REPNE prefixes (equivalently, REPZ and REPNZ) may be used to repeat the instruction up to ECX times until the first unequal or equal byte is found.
Example:
mov edi SourcePointer
mov ecx MAX_POSSIBLE_LENGTH
mov ax 'AA'
repne scasw | je Found
; Not found = repeat
Found:
SCASD
Usage: SCASD Modifies flags: AF CF OF PF SF ZF
Compares doubleword value at EDI from the accumulator and sets the flags similar to a subtraction. EDI is incremented/decremented by 4 and the state of the Direction Flag. Use with REP prefixes.
Scan String
SCASB ; AE [8086]
SCASW ; o16 AF [8086]
SCASD ; o32 AF [386]
SCASB compares the byte in AL with the byte at EDI, and sets the flags accordingly. It then increments or decrements (depending on the direction flag: increments if the flag is clear, decrements if it is set) EDI.
SCASW and SCASD work in the same way, but they compare a word to AX or a doubleword to EAX instead of a byte to AL, and increment or decrement the addressing registers by 2 or 4 instead of 1.
The REPE and REPNE prefixes (equivalently, REPZ and REPNZ) may be used to repeat the instruction up to ECX times until the first unequal or equal byte is found.
Example:
mov edi SourcePointer
mov ecx MAX_POSSIBLE_LENGTH
mov eax 'AAAA'
repne scasd | je Found
; Not found = repeat
Found:
SCASB
Usage: SCASB Modifies flags: AF CF OF PF SF ZF
Compares byte value at EDI from the accumulator and sets the flags similar to a subtraction. EDI is incremented/decremented by 1 and the state of the Direction Flag. Use with REP prefixes.
Scan String
SCASB ; AE [8086]
SCASW ; o16 AF [8086]
SCASD ; o32 AF [386]
SCASB compares the byte in AL with the byte at EDI, and sets the flags accordingly. It then increments or decrements (depending on the direction flag: increments if the flag is clear, decrements if it is set) EDI.
SCASW and SCASD work in the same way, but they compare a word to AX or a doubleword to EAX instead of a byte to AL, and increment or decrement the addressing registers by 2 or 4 instead of 1.
The REPE and REPNE prefixes (equivalently, REPZ and REPNZ) may be used to repeat the instruction up to ECX times until the first unequal or equal byte is found.
Example:
mov edi SourcePointer
mov ecx MAX_POSSIBLE_LENGTH
mov al 'A'
repne scasb | je Found
; Not found = repeat
Found:
SBB
Usage: SBB dest,src Modifies flags: AF CF OF PF SF ZF
Subtracts the source from the destination, and subtracts 1 extra if the Carry Flag is set. Results are returned in 'dest'.
Subtract with Borrow
SBB r/m8,reg8 ; 18 /r [8086]
SBB r/m16,reg16 ; o16 19 /r [8086]
SBB r/m32,reg32 ; o32 19 /r [386]
SBB reg8,r/m8 ; 1A /r [8086]
SBB reg16,r/m16 ; o16 1B /r [8086]
SBB reg32,r/m32 ; o32 1B /r [386]
SBB r/m8,imm8 ; 80 /3 ib [8086]
SBB r/m16,imm16 ; o16 81 /3 iw [8086]
SBB r/m32,imm32 ; o32 81 /3 id [386]
SBB r/m16,imm8 ; o16 83 /3 ib [8086]
SBB r/m32,imm8 ; o32 83 /3 ib [386]
SBB AL,imm8 ; 1C ib [8086]
SBB AX,imm16 ; o16 1D iw [8086]
SBB EAX,imm32 ; o32 1D id [386]
SBB performs integer subtraction: it subtracts its second operand, plus the value of the carry flag, from its first, and leaves the result in its destination (first) operand. The flags are set according to the result of the operation: in particular, the carry flag is affected and can be used by a subsequent SBB instruction.
To subtract one number from another without also subtracting the contents of the carry flag, use SUB.
EXAMPLE:
mov eax 0f
mov ebx 0a
stc
sbb eax ebx ;eax = 4
SAR
Usage: SAR dest,count Modifies flags: CF OF PF SF ZF (AF undefined)
Shifts the 'dest' right by 'count' bits with the current sign bit replicated in the leftmost bit. The Carry Flag contains the last bit shifted out.
Bitwise Arithmetic Shifts
SAL r/m8,1 ; D0 /4 [8086]
SAL r/m8,CL ; D2 /4 [8086]
SAL r/m8,imm8 ; C0 /4 ib [186]
SAL r/m16,1 ; o16 D1 /4 [8086]
SAL r/m16,CL ; o16 D3 /4 [8086]
SAL r/m16,imm8 ; o16 C1 /4 ib [186]
SAL r/m32,1 ; o32 D1 /4 [386]
SAL r/m32,CL ; o32 D3 /4 [386]
SAL r/m32,imm8 ; o32 C1 /4 ib [386]
SAR r/m8,1 ; D0 /7 [8086]
SAR r/m8,CL ; D2 /7 [8086]
SAR r/m8,imm8 ; C0 /7 ib [186]
SAR r/m16,1 ; o16 D1 /7 [8086]
SAR r/m16,CL ; o16 D3 /7 [8086]
SAR r/m16,imm8 ; o16 C1 /7 ib [186]
SAR r/m32,1 ; o32 D1 /7 [386]
SAR r/m32,CL ; o32 D3 /7 [386]
SAR r/m32,imm8 ; o32 C1 /7 ib [386]
SAL and SAR perform an arithmetic shift operation on the given source/destination (first) operand. The vacated bits are filled with zero for SAL, and with copies of the original high bit of the source operand for SAR.
SAL is a synonym for SHL (see SHL). RosAsm will assemble either one to the same code.
The number of bits to shift by is given by the second operand. Only the bottom five bits of the shift count are considered by processors above the 8086.
Example:
shl eax 2 | mov ebx eax | sar ebx 2
add eax ebx ; (eax*4)+(eax*16) = eax * 20
SAL
Usage: SAL dest,count Modifies flags: CF OF PF SF ZF (AF undefined)
Shifts the 'dest' left by 'count' bits with zeroes shifted in on right. The Carry Flag contains the last bit shifted out.
Bitwise Arithmetic Shifts
SAL r/m8,1 ; D0 /4 [8086]
SAL r/m8,CL ; D2 /4 [8086]
SAL r/m8,imm8 ; C0 /4 ib [186]
SAL r/m16,1 ; o16 D1 /4 [8086]
SAL r/m16,CL ; o16 D3 /4 [8086]
SAL r/m16,imm8 ; o16 C1 /4 ib [186]
SAL r/m32,1 ; o32 D1 /4 [386]
SAL r/m32,CL ; o32 D3 /4 [386]
SAL r/m32,imm8 ; o32 C1 /4 ib [386]
SAR r/m8,1 ; D0 /7 [8086]
SAR r/m8,CL ; D2 /7 [8086]
SAR r/m8,imm8 ; C0 /7 ib [186]
SAR r/m16,1 ; o16 D1 /7 [8086]
SAR r/m16,CL ; o16 D3 /7 [8086]
SAR r/m16,imm8 ; o16 C1 /7 ib [186]
SAR r/m32,1 ; o32 D1 /7 [386]
SAR r/m32,CL ; o32 D3 /7 [386]
SAR r/m32,imm8 ; o32 C1 /7 ib [386]
SAL and SAR perform an arithmetic shift operation on the given source/destination (first) operand. The vacated bits are filled with zero for SAL, and with copies of the original high bit of the source operand for SAR.
SAL is a synonym for SHL (see SHL). RosAsm will assemble either one to the same code.
The number of bits to shift by is given by the second operand. Only the bottom five bits of the shift count are considered by processors above the 8086.
Example:
shl eax 2 | mov ebx eax | sal ebx 2
add eax ebx ; (eax*4)+(eax*16) = eax * 20
SAHF
Usage: SAHF Modifies flags: AF CF PF SF ZF
Transfers bits 0-7 of AH into the Flags Register. This includes AF, CF, PF, SF and ZF.
Store AH to Flags
SAHF ; 9E [8086]
SAHF sets the low byte of the flags word according to the contents of the AH register.
The operation of SAHF is:
AH --> SF:ZF:0:AF:0:PF:1:CF
See also LAHF.
Example:
sahf
RSTS
Usage: RSTS src Modifies flags: None
Restore TSR and Descriptor
RSTS m80 ; 0F 7D /0 [486,CYRIX,SMM]
RSTS restores Task State Register (TSR) from mem80.
EXAMPLE:
rsts Label
RSQRTSS
Usage: RSQRTPS dest,src Modifies flags: None
Computes an approximate reciprocal of the square root of the low single-precision floating-point value in the 'src' (second operand) stores the single-precision floating-point result in the 'dest' operand.
Scalar Single-Precision FP Square Root Reciprocal
RSQRTSS xmm1,xmm2/m128 ; F3 0F 52 /r [KATMAI,SSE]
RSQRTSS returns an approximation of the reciprocal of the square root of the lowest order single-precision FP value from the source, and stores it in the low doubleword of the destination register. The upper three fields of xmm1 are preserved. The maximum error for this approximation is: |Error| <= 1.5 x 2^-12
The 'src' operand can be an XMM register or a 32-bit memory location. The 'dest' operand is an XMM register. The three high-order double-words of the 'dest' operand remain unchanged.
EXAMPLE:
rsqrtss xmm1 Label