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.

C Instructions

CALL - Procedure Call

        Usage:  CALL    destination
        Modifies flags: None

        Pushes Instruction Pointer (and Code Segment for far calls) onto
        stack and loads Instruction Pointer with the address of proc-name.
        Code continues with execution at CS:IP.

                                                         Clocks
                   Operands                     808x   286     386     486

        rel16 (near, IP relative)                19     7      7+m      3
        rel32 (near, IP relative)                -      -      7+m      3

        reg16 (near, register indirect)          16     7      7+m      5
        reg32 (near, register indirect)          -      -      7+m      5

        mem16 (near, memory indirect)            -     21+EA    11    10+m      5
        mem32 (near, memory indirect)            -      -     10+m      5

        ptr16:16 (far, full ptr supplied)        28     13    17+m      18
        ptr16:32 (far, full ptr supplied)        -      -     17+m      18
        ptr16:16 (far, ptr supplied, prot. mode) -      26    34+m      20
        ptr16:32 (far, ptr supplied, prot. mode) -      -     34+m      20
        m16:16 (far, indirect)                 37+EA    16    22+m      17
        m16:32 (far, indirect)                   -      -     22+m      17
        m16:16 (far, indirect, prot. mode)       -      29    38+m      20
        m16:32 (far, indirect, prot. mode)       -      -     38+m      20

        ptr16:16 (task, via TSS or task gate)    -     177     TS     37+TS
        m16:16 (task, via TSS or task gate)      -   180/185  5+TS    37+TS
        m16:32 (task)                            -      -      TS     37+TS
        m16:32 (task)                            -      -     5+TS    37+TS

        ptr16:16 (gate, same privilege)          -      41    52+m      35
        ptr16:32 (gate, same privilege)          -      -     52+m      35
        m16:16 (gate, same privilege)            -      44    56+m      35
        m16:32 (gate, same privilege)            -      -     56+m      35

        ptr16:16 (gate, more priv, no parm)      -      82    86+m      69
        ptr16:32 (gate, more priv, no parm)      -      -     86+m      69
        m16:16 (gate, more priv, no parm)        -      83    90+m      69
        m16:32 (gate, more priv, no parm)        -      -     90+m      69

        ptr16:16 (gate, more priv, x parms)      -    86+4x  94+4x+m  77+4x
        ptr16:32 (gate, more priv, x parms)      -      -    94+4x+m  77+4x
        m16:16 (gate, more priv, x parms)        -    90+4x  98+4x+m  77+4x
        m16:32 (gate, more priv, x parms)        -      -    98+4x+m  77+4x

CBW - Convert Byte to Word

        Usage:  CBW
        Modifies flags: None

        Converts byte in AL to word Value in AX by extending sign of AL
        throughout register AH.

                                 Clocks                 Size
        Operands         808x  286   386   486          Bytes

        none              2     2     3     3             1

CDQ - Convert Double to Quad (386+)

        Usage:  CDQ
        Modifies flags: None

        Converts signed DWORD in EAX to a signed quad word in EDX:EAX by
        extending the high order bit of EAX throughout EDX

                                 Clocks                 Size
        Operands         808x  286   386   486          Bytes

        none              -     -     2     3             1

CLC - Clear Carry

        Usage:  CLC
        Modifies flags: CF

        Clears the Carry Flag.

                                 Clocks                 Size
        Operands         808x  286   386   486          Bytes

        none              2     2     2     2             1

CLD - Clear Direction Flag

        Usage:  CLD
        Modifies flags: DF

        Clears the Direction Flag causing string instructions to increment
        the SI and DI index registers.

                                 Clocks                 Size
        Operands         808x  286   386   486          Bytes

        none              2     2     2     2             1

CLI - Clear Interrupt Flag (disable)

        Usage:  CLI
        Modifies flags: IF

        Disables the maskable hardware interrupts by clearing the Interrupt
        flag.  NMI's and software interrupts are not inhibited.

                                 Clocks                 Size
        Operands         808x  286   386   486          Bytes

        none              2     2     3     5             1

CLTS - Clear Task Switched Flag (286+ privileged)

        Usage:  CLTS
        Modifies flags: None

        Clears the Task Switched Flag in the Machine Status Register.  This
        is a privileged operation and is generally used only by operating
        system code.

                                 Clocks                 Size
        Operands         808x  286   386   486          Bytes

        none              -     2     5     7             2

CMC - Complement Carry Flag

        Usage:  CMC
        Modifies flags: CF

        Toggles (inverts) the Carry Flag

                                 Clocks                 Size
        Operands         808x  286   386   486          Bytes

        none              2     2     2     2             1

CMP - Compare

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

        Subtracts source from destination and updates the flags but does
        not save result.  Flags can subsequently be checked for conditions.

                                 Clocks                 Size
        Operands         808x  286   386   486          Bytes

        reg,reg           3     2     2     1             2
        mem,reg          9+EA   7     5     2            2-4  (W88=13+EA)
        reg,mem          9+EA   6     6     2            2-4  (W88=13+EA)
        reg,immed         4     3     2     1            3-4
        mem,immed       10+EA   6     5     2            3-6  (W88=14+EA)
        accum,immed       4     3     2     1            2-3

CMPS - Compare String (Byte, Word or Doubleword)

        Usage:  CMPS    dest,src
                CMPSB
                CMPSW
                CMPSD   (386+)
        Modifies flags: AF CF OF PF SF ZF

        Subtracts destination value from source without saving results.
        Updates flags based on the subtraction and  the index registers
        (E)SI and (E)DI are incremented or decremented depending on the
        state of the Direction Flag.  CMPSB inc/decrements the index
        registers by 1, CMPSW inc/decrements by 2, while CMPSD increments
        or decrements by 4.  The REP prefixes can be used to process
        entire data items.

                                 Clocks                 Size
        Operands         808x  286   386   486          Bytes

        dest,src          22    8     10    8             1  (W88=30)

CMPXCHG - Compare and Exchange

        Usage:  CMPXCHG dest,src  (486+)
        Modifies flags: AF CF OF PF SF ZF

        Compares the accumulator (8-32 bits) with "dest".  If equal the
        "dest" is loaded with "src", otherwise the accumulator is loaded
        with "dest".

                                 Clocks                 Size
        Operands         808x  286   386   486          Bytes

        reg,reg           -     -     -     6             2
        mem,reg           -     -     -     7             2

        - add 3 clocks if the "mem,reg" comparison fails

CWD - Convert Word to Doubleword

        Usage:  CWD
        Modifies flags: None

        Extends sign of word in register AX throughout register DX forming
        a doubleword quantity in DX:AX.

                                 Clocks                 Size
        Operands         808x  286   386   486          Bytes

        none              5     2     2     3             1

CWDE - Convert Word to Extended Doubleword (386+)

        Usage:  CWDE
        Modifies flags: None

        Converts a signed word in AX to a signed doubleword in EAX by
        extending the sign bit of AX throughout EAX.

                                 Clocks                 Size
        Operands         808x  286   386   486          Bytes

        none              -     -     3     3             1