The Intel 8086 / 8088 / 80186 / 80286 / 80386 / 80486 Instruction Set

This HTML version of the file intel.doc from the PC Game Programmer's guide was produced by Zack T Smith. Fancy HTML modifications are copyright © 2005 by Zack T Smith, all rights reserved. This information is provided in the hope that it will be useful, but without any warranty. It is provided AS-IS, without even the implied warranty of fitness for a particular purpose.

S Instructions

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 "count" bits with zeroes shifted
        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 "count" bits with the current sign
        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 "dest".

                                 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

        reg8              -     -     4     3             3
        mem8              -     -     5     4             3

SETNE/SETNZ - Set if Not Equal / Set if Not Zero (386+)

        Usage:  SETNE   dest
                SETNZ   dest
        Modifies flags: none

        Sets the byte in the operand to 1 if the Zero 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

SETL/SETNGE - Set if Less / Set if Not Greater or Equal (386+)

        Usage:  SETL    dest
                SETNGE  dest
        (signed, 386+)
        Modifies flags: none

        Sets the byte in the operand to 1 if the Sign Flag is not equal
        to the Overflow Flag, otherwise sets the operand to 0.

                                 Clocks                 Size
        Operands         808x  286   386   486          Bytes

        reg8              -     -     4     3             3
        mem8              -     -     5     4             3

SETGE/SETNL - Set if Greater or Equal / Set if Not Less (386+)

        Usage:  SETGE   dest
                SETNL   dest
        (signed, 386+)
        Modifies flags: none

        Sets the byte in the operand to 1 if the Sign Flag equals the
        Overflow Flag, otherwise sets the operand to 0.

                                 Clocks                 Size
        Operands         808x  286   386   486          Bytes

        reg8              -     -     4     3             3
        mem8              -     -     5     4             3

SETLE/SETNG - Set if Less or Equal / Set if Not greater or Equal (386+)

        Usage:  SETLE   dest
                SETNG   dest
        (signed, 386+)
        Modifies flags: none

        Sets the byte in the operand to 1 if the Zero Flag is set or the
        Sign Flag is not equal to the Overflow Flag,  otherwise sets the
        operand to 0.

                                 Clocks                 Size
        Operands         808x  286   386   486          Bytes

        reg8              -     -     4     3             3
        mem8              -     -     5     4             3

SETG/SETNLE - Set if Greater / Set if Not Less or Equal (386+)

        Usage:  SETG    dest
                SETNLE  dest
        (signed, 386+)
        Modifies flags: none

        Sets the byte in the operand to 1 if the Zero Flag is clear or the
        Sign Flag equals to the Overflow Flag,  otherwise sets the operand
        to 0.

                                 Clocks                 Size
        Operands         808x  286   386   486          Bytes

        reg8              -     -     4     3             3
        mem8              -     -     5     4             3

SETS - Set if Signed (386+)

        Usage:  SETS    dest
        Modifies flags: none

        Sets the byte in the operand to 1 if the Sign 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

SETNS - Set if Not Signed (386+)

        Usage:  SETNS   dest
        Modifies flags: none

        Sets the byte in the operand to 1 if the Sign 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

SETC - Set if Carry (386+)

        Usage:  SETC    dest
        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

SETNC - Set if Not Carry (386+)

        Usage:  SETNC   dest
        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

SETO - Set if Overflow (386+)

        Usage:  SETO    dest
        Modifies flags: none

        Sets the byte in the operand to 1 if the Overflow 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

SETNO - Set if Not Overflow (386+)

        Usage:  SETNO   dest
        Modifies flags: none

        Sets the byte in the operand to 1 if the Overflow 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

SETP/SETPE - Set if Parity / Set if Parity Even (386+)

        Usage:  SETP    dest
                SETPE   dest
        Modifies flags: none

        Sets the byte in the operand to 1 if the Parity 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

SETNP/SETPO - Set if No Parity / Set if Parity Odd (386+)

        Usage:  SETNP   dest
                SETPO   dest
        Modifies flags: none

        Sets the byte in the operand to 1 if the Parity 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

SGDT - Store Global Descriptor Table (286+ privileged)

        Usage:  SGDT    dest
        Modifies flags: none

        Stores the Global Descriptor Table (GDT) Register into the
        specified operand.

                                 Clocks                 Size
        Operands         808x  286   386   486          Bytes

        mem64             -     11    9     10            5

SIDT - Store Interrupt Descriptor Table (286+ privileged)

        Usage:  SIDT    dest
        Modifies flags: none

        Stores the Interrupt Descriptor Table (IDT) Register into the
        specified operand.

                                 Clocks                 Size
        Operands         808x  286   386   486          Bytes

        mem64             -     12    9     10            5

SHL - Shift Logical Left
        See: SAL

SHR - Shift Logical Right

        Usage:  SHR     dest,count
        Modifies flags: CF OF PF SF ZF (AF undefined)

        +-----------------------+   +---+
    0-->| 7 ----------------> 0 |-->| C |
        +-----------------------+   +---+ 

        Shifts the destination right by "count" bits with zeroes shifted
        in on the left.  The Carry Flag contains the last bit shifted out.

                                 Clocks                 Size
        Operands         808x  286   386   486          Bytes

        reg,1             2     2     3                   2
        mem,1           15+EA   7     7                  2-4   (W88=23+EA)
        reg,CL           8+4n  5+n    3                   2
        mem,CL        20+EA+4n 8+n    7                  2-4   (W88=28+EA+4n)
        reg,immed8        -    5+n    3                   3
        mem,immed8        -    8+n    7                  3-5

SHLD/SHRD - Double Precision Shift (386+)

        Usage:  SHLD    dest,src,count
                SHRD    dest,src,count
        Modifies flags: CF PF SF ZF (OF,AF undefined)

        SHLD shifts "dest" to the left "count" times and the bit positions
        opened are filled with the most significant bits of "src".  SHRD
        shifts "dest" to the right "count" times and the bit positions
        opened are filled with the least significant bits of the second
        operand.  Only the 5 lower bits of "count" are used.

                                        Clocks                  Size
        Operands                808x  286   386   486           Bytes

        reg16,reg16,immed8       -     -     3     2              4
        reg32,reg32,immed8       -     -     3     2              4
        mem16,reg16,immed8       -     -     7     3              6
        mem32,reg32,immed8       -     -     7     3              6
        reg16,reg16,CL           -     -     3     3              3
        reg32,reg32,CL           -     -     3     3              3
        mem16,reg16,CL           -     -     7     4              5
        mem32,reg32,CL           -     -     7     4              5

SLDT - Store Local Descriptor Table (286+ privileged)

        Usage:  SLDT    dest
        Modifies flags: none

        Stores the Local Descriptor Table (LDT) Register into the
        specified operand.

                                 Clocks                 Size
        Operands         808x  286   386   486          Bytes

        reg16             -     2     2     2             3
        mem16             -     2     2     3             5

SMSW - Store Machine Status Word (286+ privileged)

        Usage:  SMSW    dest
        Modifies flags: none

        Store Machine Status Word (MSW) into "dest".

                                 Clocks                 Size
        Operands         808x  286   386   486          Bytes

        reg16             -     2     10    2             3
        mem16             -     3     3     3             5

STC - Set Carry

        Usage:  STC
        Modifies flags: CF

        Sets the Carry Flag to 1.

                                 Clocks                 Size
        Operands         808x  286   386   486          Bytes

        none              2     2     2     2             1

STD - Set Direction Flag

        Usage:  STD
        Modifies flags: DF

        Sets the Direction Flag to 1 causing string instructions to
        auto-decrement SI and DI instead of auto-increment.

                                 Clocks                 Size
        Operands         808x  286   386   486          Bytes

        none              2     2     2     2             1

STI - Set Interrupt Flag (Enable Interrupts)

        Usage:  STI
        Modifies flags: IF

        Sets the Interrupt Flag to 1, which enables recognition of all
        hardware interrupts.  If an interrupt is generated by a hardware
        device, an End of Interrupt (EOI) must also be issued to enable
        other hardware interrupts of the same or lower priority.

                                 Clocks                 Size
        Operands         808x  286   386   486          Bytes

        none              2     2     2     5             1

STOS - Store String (Byte, Word or Doubleword)

        Usage:  STOS    dest
                STOSB
                STOSW
                STOSD
        Modifies flags: None

        Stores value in accumulator to location at ES:(E)DI (even if operand
        is given).  (E)DI is incremented/decremented based on the size of
        the operand (or instruction format) and the state of the Direction
        Flag.   Use with REP prefixes.

                                 Clocks                 Size
        Operands         808x  286   386   486          Bytes

        dest              11    3     4     5             1  (W88=15)

STR - Store Task Register (286+ privileged)

        Usage:  STR     dest
        Modifies flags: None

        Stores the current Task Register to the specified operand.

                                 Clocks                 Size
        Operands         808x  286   386   486          Bytes

        reg16             -     2     2     2             3
        mem16             -     3     2     3             5

SUB - Subtract

        Usage:  SUB     dest,src
        Modifies flags: AF CF OF PF SF ZF

        The source is subtracted from the destination and the result is
        stored in the destination.

                                 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