REP - Repeat String Operation Usage: REP
Modifies flags: None
Repeats execution of string instructions while CX != 0. After each string operation, CX is decremented and the Zero Flag is
tested. The combination of a repeat prefix and a segment override on CPU's before the 386 may result in errors if an interrupt occurs before CX=0. The following code shows code that is susceptible to this and how to avoid it:
again: rep movs byte ptr ES:[DI],ES:[SI] ; vulnerable instr.
jcxz next ; continue if REP successful loop again ; interrupt goofed count next:
Clocks Size Operands 808x 286 386 486 Bytes none 2 2 2 1
REPE/REPZ - Repeat Equal / Repeat Zero Usage: REPE REPZ
Modifies flags: None
Repeats execution of string instructions while CX != 0 and the Zero Flag is set. CX is decremented and the Zero Flag tested after each string operation. The combination of a repeat prefix and a segment override on processors other than the 386 may result in errors if an interrupt occurs before CX=0.
Clocks Size Operands 808x 286 386 486 Bytes none 2 2 2 1
REPNE/REPNZ - Repeat Not Equal / Repeat Not Zero Usage: REPNE REPNZ Modifies flags: None
Repeats execution of string instructions while CX != 0 and the Zero Flag is clear. CX is decremented and the Zero Flag tested after each string operation. The combination of a repeat prefix and a segment override on processors other than the 386 may result in errors if an interrupt occurs before CX=0.
Clocks Size Operands 808x 286 386 486 Bytes none 2 2 2 1
RET/RETF - Return From Procedure
Usage: RET nBytes RETF nBytes RETN nBytes Modifies flags: None
Transfers control from a procedure back to the instruction address saved on the stack. \ release. Far returns pop the IP followed by the CS, while near returns pop only the IP register.
Clocks Size Operands 808x 286 386 486 Bytes retn 16/20 11+m 10+m 5 1 retn immed 20/24 11+m 10+m 5 3 retf 26/34 15+m 18+m 13 1 retf (PM, same priv.) - 32+m 18 1 retf (PM, lesser priv.) - 68 33 1
retf immed 25/33 15+m 18+m 14 3 retf immed (PM, same priv.) 32+m 17 1 retf immed (PM, lesser priv.) 68 33 1
ROL - Rotate Left
Usage: ROL dest,count Modifies flags: CF OF +-+ +---------------+ |C|<++-+|7 <---------- 0|<-+ +-+ | +---------------+ | +---------------------+
Rotates the bits in the destination to the left \ all data pushed out the left side re-entering on the right. The Carry Flag will contain the value of the last bit rotated out. Clocks Size Operands 808x 286 386 486 Bytes reg,1 2 2 3 3 2
mem,1 15+EA 7 7 4 2-4 (W88=23+EA) reg,CL 8+4n 5+n 3 3 2
mem,CL 20+EA+4n 8+n 7 4 2-4 (W88=28+EA+4n) reg,immed8 - 5+n 3 2 3 mem,immed8 - 8+n 7 4 3-5
ROR - Rotate Right
Usage: ROR dest,count Modifies flags: CF OF
+---------------+ +-+ +->|7 +---------> 0|+-+->|C| | +---------------+ | +-+
+---------------------+
Rotates the bits in the destination to the right \ all data pushed out the right side re-entering on the left. The Carry Flag will contain the value of the last bit rotated out. Clocks Size Operands 808x 286 386 486 Bytes reg,1 2 2 3 3 2
mem,1 15+EA 7 7 4 2-4 (W88=23+EA) reg,CL 8+4n 5+n 3 3 2
mem,CL 20+EA+4n 8+n 7 4 2-4 (W88=28+EA+4n) reg,immed8 - 5+n 3 2 3 mem,immed8 - 8+n 7 4 3-5
SAHF - Store AH Register into FLAGS 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.
Clocks Size Operands 808x 286 386 486 Bytes none 4 2 3 2 1
SAL/SHL - Shift Arithmetic Left / Shift Logical Left Usage: SAL dest,count SHL dest,count
Modifies flags: CF OF PF SF ZF (AF undefined) +-+ +---------------+ +-+ |C|<---+|7 <---------- 0|<---+|0|
+-+ +---------------+ +-+
Shifts the destination left by \ in on right. The Carry Flag contains the last bit shifted out. Clocks Size Operands 808x 286 386 486 Bytes reg,1 2 2 3 3 2
mem,1 15+EA 7 7 4 2-4 (W88=23+EA) reg,CL 8+4n 5+n 3 3 2
mem,CL 20+EA+4n 8+n 7 4 2-4 (W88=28+EA+4n) reg,immed8 - 5+n 3 2 3 mem,immed8 - 8+n 7 4 3-5
SAR - Shift Arithmetic Right
Usage: SAR dest,count
Modifies flags: CF OF PF SF ZF (AF undefined) +---------------+ +-+
+-+|7 ----------> 0|---+>|C| | +---------------+ +-+ +---^
Shifts the destination right by \ bit replicated in the leftmost bit. The Carry Flag contains the last bit shifted out.
Clocks Size Operands 808x 286 386 486 Bytes reg,1 2 2 3 3 2
mem,1 15+EA 7 7 4 2-4 (W88=23+EA) reg,CL 8+4n 5+n 3 3 2
mem,CL 20+EA+4n 8+n 7 4 2-4 (W88=28+EA+4n) reg,immed8 - 5+n 3 2 3 mem,immed8 - 8+n 7 4 3-5
SBB - Subtract with Borrow/Carry 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 \
Clocks Size Operands 808x 286 386 486 Bytes reg,reg 3 2 2 1 2
mem,reg 16+EA 7 6 3 2-4 (W88=24+EA) reg,mem 9+EA 7 7 2 2-4 (W88=13+EA) reg,immed 4 3 2 1 3-4
mem,immed 17+EA 7 7 3 3-6 (W88=25+EA) accum,immed 4 3 2 1 2-3
SCAS - Scan String (Byte, Word or Doubleword) Usage: SCAS string SCASB SCASW
SCASD (386+)
Modifies flags: AF CF OF PF SF ZF
Compares value at ES:DI (even if operand is specified) from the accumulator and sets the flags similar to a subtraction. DI is incremented/decremented based on the instruction format (or operand size) and the state of the Direction Flag. Use with REP prefixes.
Clocks Size Operands 808x 286 386 486 Bytes
string 15 7 7 6 1 (W88=19)
SETAE/SETNB - Set if Above or Equal / Set if Not Below (386+) Usage: SETAE dest SETNB dest (unsigned, 386+) Modifies flags: none
Sets the byte in the operand to 1 if the Carry Flag is clear otherwise sets the operand to 0.
Clocks Size Operands 808x 286 386 486 Bytes reg8 - - 4 3 3 mem8 - - 5 4 3
SETB/SETNAE - Set if Below / Set if Not Above or Equal (386+) Usage: SETB dest SETNAE dest (unsigned, 386+) Modifies flags: none
Sets the byte in the operand to 1 if the Carry Flag is set otherwise sets the operand to 0.
Clocks Size Operands 808x 286 386 486 Bytes reg8 - - 4 3 3 mem8 - - 5 4 3
SETBE/SETNA - Set if Below or Equal / Set if Not Above (386+) Usage: SETBE dest SETNA dest (unsigned, 386+) Modifies flags: none
Sets the byte in the operand to 1 if the Carry Flag or the Zero Flag is set, otherwise sets the operand to 0.
Clocks Size Operands 808x 286 386 486 Bytes reg8 - - 4 3 3 mem8 - - 5 4 3
SETE/SETZ - Set if Equal / Set if Zero (386+) Usage: SETE dest SETZ dest Modifies flags: none
Sets the byte in the operand to 1 if the Zero Flag is set, otherwise sets the operand to 0.
Clocks Size Operands 808x 286 386 486 Bytes