home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / nasmide.zip / 8086help.hlp (.txt) next >
Borland Turbo Vision Help  |  1997-12-22  |  277KB  |  3,058 lines

  1.  80x86 integer opcode help
  2. Welcome to the NASM-IDE 1.1 online help. This section contains details on the Intel 80x86 instruction set, covering instructions supported by the 8086 up to the Pentium(tm) Pro class computers of today. 
  3.  Contents
  4.  Using
  5. opcode
  6. listings
  7.  Alphabetical
  8. opcode
  9. listing
  10.  Opcode
  11. listing
  12. minimum
  13. processor
  14. requirement
  15.  Using 80x86 integer opcode help
  16. This help file contains entries for all 80x86 instructions. Each entry contains the following sections: 
  17.  Description
  18. This contains a detailed description of how the instruction works. This information is based on the Intel Architecture Software Developer's Manual Volume 2, Instruction Set Reference (#243191), available from Intel's web site (http://www.intel.com/). 
  19.  Flags affected
  20. Describes any changes to the EFLAGS register as a result of the instruction being executed. !
  21.  Instruction size and timings
  22. Contains a table showing the size of an instruction in bytes and the number of clock cycles the instruction takes to executed. Timings are shown for the 8086 up to the Pentium processor. Instruction pairing information is also included for the Pentium timings. This information is taken from a HTML document available from http://www.quantasm.com/. 6
  23. The following symbols are used in the timing tables: 
  24.  Operands
  25.  acc   = AL, AX or EAX unless specified otherwise
  26.  reg   = any general register
  27.  r8    = any 8-bit register
  28.  r16   = any general purpose 16-bit register
  29.  r32   = any general purpose 32-bit register
  30.  imm   = immediate data
  31.  imm8  = 8-bit immediate data
  32.  imm16 = 16-bit immediate data
  33.  mem   = memory address
  34.  mem8  = address of 8-bit data item
  35.  mem16 = address of 16-bit data item
  36.  mem32 = address of 32-bit data item
  37.  mem48 = address of 48-bit data item
  38.  dest  = 16/32-bit destination
  39.  short = 8-bit destination
  40.  Instruction timings
  41.  n  -  generally refers to a number of repeated counts
  42.  m  -  in a jump or call;
  43.           286     : bytes in next instruction
  44.           386/486 : number of components
  45.                     (each byte of opcode) + 1 (if immediate data)
  46.                     + 1 (if displacement)
  47.  EA = cycles to calculate the Effective Address
  48.           8088/8086: base                             = 5
  49.                      BP + DI or BX + SI               = 7
  50.                      BP + DI + disp or BX + SI + disp = 11
  51.                      index                            = 5
  52.                      BX + DI or BP + SI               = 8
  53.                      BX + DI + disp or BP + SI + disp = 12
  54.                      disp                             = 6
  55.                      segment override                 = +2
  56.           286 - 486: base + index + disp              = +1
  57.                      all others, no penalty
  58.  Instruction length
  59. The byte count includes the opcode length and length of any required displacement or immediate data. If the displacement is optional, it is shown as d() with the possible lengths in parentheses. If the immediate data is optional, it is shown as i() with the possible lengths in parentheses. B
  60.  Pairing categories for Pentium
  61.  NP = not pairable
  62.  UV = pairable in the U pipe or V pipe
  63.  PU = pairable in the U pipe only
  64.  PV = pairable in the V pipe only
  65.  Example
  66. This section contains an example of how the instruction can be used. 
  67. contents
  68. screen
  69.  80x86 integer opcodes (alphabetical)
  70.  AAA                           - ASCII adjust after addition
  71.  AAD                           - ASCII adjust AX before division
  72.  AAM                           - ASCII adjust AX after multiplication
  73.  AAS                           - ASCII adjust AL after subtraction
  74.  ADC                           - Add with carry
  75.  ADD                           - Integer addition
  76.  AND                           - Logical AND
  77.  ARPL                          - Adjusted Requested Privilege Level of selector (286+)
  78.  BOUND                         - Array index bound check (186+)
  79.  BSF                           - Bit scan forward (386+)
  80.  BSR                           - Bit scan reverse (386+)
  81.  BSWAP                         - Byte swap (486+)
  82.  BT                            - Bit test (386+)
  83.  BTC                           - Bit test with compliment (386+)
  84.  BTR                           - Bit test with reset (386+)
  85.  BTS                           - Bit test and set (386+)
  86.  CALL                          - Call subroutine
  87.  CBW                           - Convert byte to word
  88.  CDQ                           - Convert double to quad (386+)
  89.  CLC                           - Clear carry
  90.  CLD                           - Clear direction flag
  91.  CLI                           - Clear interrupt flag
  92.  CLTS                          - Clear task switched flag (286+)
  93.  CMC                           - Complement carry flag
  94.  CMOVcc                        - Conditional move (Pentium Pro+)
  95.  CMP                           - Compare
  96.  CMPS                          - Compare string (byte, word or doubleword)
  97.  CMPXCHG                       - Compare and exchange (486+)
  98.  CMPXCHG8B                     - Compare and exchange 8 bytes (Pentium+)
  99.  CPUID                         - CPU identification (486+)
  100.  CWD                           - Convert word to doubleword
  101.  CWDE                          - Convert word to extended doubleword (386+)
  102.  DAA                           - Decimal adjust AL after addition
  103.  DAS                           - Decimal adjust AL after subtraction
  104.  DEC                           - Decrement
  105.  DIV                           - Unsigned divide
  106.  EMMS                          - Empty MMX state (MMX)
  107.  ENTER                         - Make stack frame for procedure parameters (186+)
  108.  ESC                           - Escape
  109.  HLT                           - Halt CPU
  110.  IDIV                          - Signed integer division
  111.  IMUL                          - Signed multiply
  112.  IN                            - Input byte or word from port
  113.  INC                           - Increment
  114.  INS                           - Input string from port (byte, word or doubleword) (186+)
  115.  INT                           - Interrupt
  116.  INTO                          - Interrupt on overflow
  117.  INVD                          - Invalidate data cache (486+)
  118.  INVLPG                        - Invalidate translation look-aside buffer (TLB) entry (486+)
  119.  IRET/IRETD                    - Interrupt return (IRETD 386+)
  120.  Jcc                           - Jump on condition code
  121.  JMP                           - Unconditional jump
  122.  LAHF                          - Load register flags into AH
  123.  LAR                           - Load access rights (286+)
  124.  LDS                           - Load far pointer
  125.  LEA                           - Load effective address
  126.  LEAVE                         - Restore stack for procedure exit (186+)
  127.  LES                           - Load far pointer
  128.  LFS                           - Load far pointer (386+)
  129.  LGDT                          - Load Global Descriptor Table (286+)
  130.  LGS                           - Load far pointer (386+)
  131.  LIDT                          - Load Interrupt Descriptor Table (286+)
  132.  LLDT                          - Load Local Descriptor Table (286+)
  133.  LMSW                          - Load Machine Status Word (286+)
  134.  LOCK                          - Lock bus
  135.  LODS                          - Load string (byte, word or doubleword)
  136.  LOOP                          - Decrement CX and loop if CX not zero
  137.  LOOPE/LOOPZ                   - Loop while equal / loop while zero
  138.  LOOPNZ/LOOPNE                 - Loop while not zero / loop while not equal
  139.  LSL                           - Load segment limit (286+)
  140.  LSS                           - Load far pointer (386+)
  141.  LTR                           - Load task register (286+)
  142.  MOV                           - Move data
  143.  MOVD                          - Move 32 bits (doubleword) (MMX)
  144.  MOVQ                          - Move 64 bits (quadword) (MMX)
  145.  MOVS                          - Move string (byte, word or doubleword)
  146.  MOVSX                         - Move with sign extend (386+)
  147.  MOVZX                         - Move with zero extend (386+)
  148.  MUL                           - Unsigned multiply
  149.  NEG                           - Two's complement negation
  150.  NOP                           - No operation
  151.  NOT                           - One's compliment negation (Logical NOT)
  152.  OR                            - Inclusive logical OR
  153.  OUT                           - Output data to port
  154.  OUTS                          - Output string to port (byte, word or doubleword) (186+)
  155.  PACKSSWB/PACKSSDW             - Pack with signed saturation (MMX)
  156.  PACKUSWB                      - Pack with unsigned saturation (MMX)
  157.  PADDB/PADDW/PADDD             - Packed add (MMX)
  158.  PADDSB/PADDSW                 - Packed add with saturation (MMX)
  159.  PADDUSB/PADDUSW               - Packed add unsigned with saturation (MMX)
  160.  PAND                          - Logical AND (MMX)
  161.  PANDN                         - Logical AND NOT (MMX)
  162.  PCMPEQB/PCMPEQW/PCMPEQD       - Packed compare for equal (MMX)
  163.  PCMPGTB/PCMPGTW/PCMPGTD       - Packed compare for greater than (MMX)
  164.  PMADDWD                       - Packed multiply and add (MMX)
  165.  PMULHW                        - Packed multiply high (MMX)
  166.  PMULLW                        - Packed multiply low (MMX)
  167.  POP                           - Pop word off stack
  168.  POPA/POPAD                    - Pop all registers onto stack (186+)
  169.  POPF/POPFD                    - Pop flags off stack
  170.  POR                           - Bitwise logical OR (MMX)
  171.  PSLLW/PSLLD/PSLLQ             - Packed shift left logical (MMX)
  172.  PSRAW/PSRAD                   - Packed shift right arithmetic (MMX)
  173.  PSRLW/PSRLD/PSRLQ             - Packed shift right logical (MMX)
  174.  PSUBB/PSUBW/PSUBD             - Packed subtract (MMX)
  175.  PSUBSB/PSUBSW                 - Packed subtract with saturation (MMX)
  176.  PSUBUSB/PSUBUSW               - Packed subtract unsigned with saturation (MMX)
  177.  PUNPCKHBW/PUNPCKHWD/PUNPCKHDQ - Unpack high packed data (MMX)
  178.  PUNPCKLBW/PUNPCKLWD/PUNPCKLDQ - Unpack low packed data (MMX)
  179.  PUSH                          - Push word onto stack
  180.  PUSHA/PUSHAD                  - Push all registers onto stack (186+)
  181.  PUSHF/PUSHFD                  - Push flags onto stack
  182.  PXOR                          - Logical exclusive OR (MMX)
  183.  RCL                           - Rotate through carry left
  184.  RCR                           - Rotate through carry right
  185.  RDMSR                         - Read from Model Specific Register (Pentium+)
  186.  RDPMC                         - Read Performance-Monitoring Counters (MMX/Pentium Pro+)
  187.  RDTSC                         - Read Time-Stamp Counter (Pentium+)
  188.  REP                           - Repeat string operation
  189.  REPE/REPZ                     - Repeat while equal / repeat while zero
  190.  REPNE/REPNZ                   - Repeat while not equal / repeat while not zero
  191.  RET/RETF                      - Return from procedure
  192.  ROL                           - Rotate left
  193.  ROR                           - Rotate right
  194.  RSM                           - Resume from System Management Mode (Pentium+)
  195.  SAHF                          - Store AH register into flags
  196.  SAL                           - Shift arithmetic left
  197.  SAR                           - Shift arithmetic right
  198.  SBB                           - Subtract with borrow / carry
  199.  SCAS                          - Scan string  (byte, word or doubleword)
  200.  SETcc                         - Set byte on condition (386+)
  201.  SGDT                          - Store Global Descriptor Table (286+)
  202.  SIDT                          - Store Interrupt Descriptor Table (286+)
  203.  SHL                           - Shift logical left
  204.  SHR                           - Shift logical right
  205.  SHLD                          - Double precision shift left (386+)
  206.  SHRD                          - Double precision shift right (386+)
  207.  SLDT                          - Store Local Descriptor Table (286+)
  208.  SMSW                          - Store Machine Status Word (286+)
  209.  STC                           - Set carry flag
  210.  STD                           - Set direction flag
  211.  STI                           - Set interrupt flag (enable interrupts)
  212.  STOS                          - Store string (byte, word or doubleword)
  213.  STR                           - Store task register (286+)
  214.  SUB                           - Subtract
  215.  TEST                          - Test for bit pattern (logical compare)
  216.  UD2                           - Undefined instruction
  217.  VERR                          - Verify read (286+)
  218.  VERW                          - Verify write (286+)
  219.  WAIT                          - Wait for coprocessor
  220.  WBINVD                        - Write-back and invalidate data cache (486+)
  221.  WRMSR                         - Write to Model Specific Register (Pentium+)
  222.  XADD                          - Exchange and add (486+)
  223.  XCHG                          - Exchange
  224.  XLAT/XLATB                    - Translate
  225.  XOR                           - Exclusive OR
  226. contents
  227. screen
  228.  80x86 integer opcodes (by processor)
  229.  8086 and above
  230.  AAA                           - ASCII adjust after addition
  231.  AAD                           - ASCII adjust AX before division
  232.  AAM                           - ASCII adjust AX after multiplication
  233.  AAS                           - ASCII adjust AL after subtraction
  234.  ADC                           - Add with carry
  235.  ADD                           - Integer addition
  236.  AND                           - Logical AND
  237.  CALL                          - Call subroutine
  238.  CBW                           - Convert byte to word
  239.  CLC                           - Clear carry
  240.  CLD                           - Clear direction flag
  241.  CLI                           - Clear interrupt flag
  242.  CMC                           - Complement carry flag
  243.  CMP                           - Compare
  244.  CMPS                          - Compare string (byte, word or doubleword)
  245.  CWD                           - Convert word to doubleword
  246.  DAA                           - Decimal adjust AL after addition
  247.  DAS                           - Decimal adjust AL after subtraction
  248.  DEC                           - Decrement
  249.  DIV                           - Unsigned divide
  250.  ESC                           - Escape
  251.  HLT                           - Halt CPU
  252.  IDIV                          - Signed integer division
  253.  IMUL                          - Signed multiply
  254.  IN                            - Input byte or word from port
  255.  INC                           - Increment
  256.  INT                           - Interrupt
  257.  INTO                          - Interrupt on overflow
  258.  IRET                          - Interrupt return
  259.  Jcc                           - Jump on condition code
  260.  JMP                           - Unconditional jump
  261.  LAHF                          - Load register flags into AH
  262.  LDS                           - Load far pointer
  263.  LEA                           - Load effective address
  264.  LES                           - Load far pointer
  265.  LOCK                          - Lock bus
  266.  LODS                          - Load string (byte, word or doubleword)
  267.  LOOP                          - Decrement CX and loop if CX not zero
  268.  LOOPE/LOOPZ                   - Loop while equal / loop while zero
  269.  LOOPNZ/LOOPNE                 - Loop while not zero / loop while not equal
  270.  MOV                           - Move data
  271.  MOVS                          - Move string (byte, word or doubleword)
  272.  MUL                           - Unsigned multiply
  273.  NEG                           - Two's complement negation
  274.  NOP                           - No operation
  275.  NOT                           - One's compliment negation (Logical NOT)
  276.  OR                            - Inclusive logical OR
  277.  OUT                           - Output data to port
  278.  POP                           - Pop word off stack
  279.  POPF/POPFD                    - Pop flags off stack
  280.  PUSH                          - Push word onto stack
  281.  PUSHF/PUSHFD                  - Push flags onto stack
  282.  RCL                           - Rotate through carry left
  283.  RCR                           - Rotate through carry right
  284.  REP                           - Repeat string operation
  285.  REPE/REPZ                     - Repeat while equal / repeat while zero
  286.  REPNE/REPNZ                   - Repeat while not equal / repeat while not zero
  287.  RET/RETF                      - Return from procedure
  288.  ROL                           - Rotate left
  289.  ROR                           - Rotate right
  290.  SAHF                          - Store AH register into flags
  291.  SAL                           - Shift arithmetic left
  292.  SAR                           - Shift arithmetic right
  293.  SBB                           - Subtract with borrow / carry
  294.  SCAS                          - Scan string  (byte, word or doubleword)
  295.  SHL                           - Shift logical left
  296.  SHR                           - Shift logical right
  297.  STC                           - Set carry flag
  298.  STD                           - Set direction flag
  299.  STI                           - Set interrupt flag (enable interrupts)
  300.  STOS                          - Store string (byte, word or doubleword)
  301.  SUB                           - Subtract
  302.  TEST                          - Test for bit pattern (logical compare)
  303.  UD2                           - Undefined instruction
  304.  WAIT                          - Wait for coprocessor
  305.  XCHG                          - Exchange
  306.  XLAT/XLATB                    - Translate
  307.  XOR                           - Exclusive OR
  308.  186 and above
  309.  BOUND                         - Array index bound check (186+)
  310.  ENTER                         - Make stack frame for procedure parameters (186+)
  311.  INS                           - Input string from port (byte, word or doubleword) (186+)
  312.  LEAVE                         - Restore stack for procedure exit (186+)
  313.  OUTS                          - Output string to port (byte, word or doubleword) (186+)
  314.  POPA/POPAD                    - Pop all registers onto stack (186+)
  315.  PUSHA/PUSHAD                  - Push all registers onto stack (186+)
  316.  286 and above
  317.  ARPL                          - Adjusted Requested Privilege Level of selector (286+)
  318.  CLTS                          - Clear task switched flag (286+)
  319.  LAR                           - Load access rights (286+)
  320.  LGDT                          - Load Global Descriptor Table (286+)
  321.  LIDT                          - Load Interrupt Descriptor Table (286+)
  322.  LLDT                          - Load Local Descriptor Table (286+)
  323.  LMSW                          - Load Machine Status Word (286+)
  324.  LSL                           - Load segment limit (286+)
  325.  LTR                           - Load task register (286+)
  326.  SGDT                          - Store Global Descriptor Table (286+)
  327.  SIDT                          - Store Interrupt Descriptor Table (286+)
  328.  SLDT                          - Store Local Descriptor Table (286+)
  329.  SMSW                          - Store Machine Status Word (286+)
  330.  STR                           - Store task register (286+)
  331.  VERR                          - Verify read (286+)
  332.  VERW                          - Verify write (286+)
  333.  386 and above
  334.  BSF                           - Bit scan forward (386+)
  335.  BSR                           - Bit scan reverse (386+)
  336.  BT                            - Bit test (386+)
  337.  BTC                           - Bit test with compliment (386+)
  338.  BTR                           - Bit test with reset (386+)
  339.  BTS                           - Bit test and set (386+)
  340.  CDQ                           - Convert double to quad (386+)
  341.  CWDE                          - Convert word to extended doubleword (386+)
  342.  IRETD                         - Interrupt return (386+)
  343.  LFS                           - Load far pointer (386+)
  344.  LGS                           - Load far pointer (386+)
  345.  LSS                           - Load far pointer (386+)
  346.  MOVSX                         - Move with sign extend (386+)
  347.  MOVZX                         - Move with zero extend (386+)
  348.  SETcc                         - Set byte on condition (386+)
  349.  SHLD                          - Double precision shift left (386+)
  350.  SHRD                          - Double precision shift right (386+)
  351.  486 and above
  352.  BSWAP                         - Byte swap (486+)
  353.  CMPXCHG                       - Compare and exchange (486+)
  354.  CPUID                         - CPU identification (486+)
  355.  INVD                          - Invalidate data cache (486+)
  356.  INVLPG                        - Invalidate translation look-aside buffer (TLB) entry (486+)
  357.  WBINVD                        - Write-back and invalidate data cache (486+)
  358.  XADD                          - Exchange and add (486+)
  359.  Pentium(tm) class and above
  360.  CMPXCHG8B                     - Compare and exchange 8 bytes (Pentium+)
  361.  RDMSR                         - Read from Model Specific Register (Pentium+)
  362.  RDTSC                         - Read Time-Stamp Counter (Pentium+)
  363.  RSM                           - Resume from System Management Mode (Pentium+)
  364.  WRMSR                         - Write to Model Specific Register (Pentium+)
  365.  Pentium Pro(tm) class and above
  366.  CMOVcc                        - Conditional move (Pentium Pro+)
  367.  RDPMC                         - Read Performance-Monitoring Counters (MMX/Pentium Pro+)
  368.  Multimedia Extensions (MMX) opcodes
  369.  EMMS                          - Empty MMX state (MMX)
  370.  MOVD                          - Move 32 bits (doubleword) (MMX)
  371.  MOVQ                          - Move 64 bits (quadword) (MMX)
  372.  PACKSSWB/PACKSSDW             - Pack with signed saturation (MMX)
  373.  PACKUSWB                      - Pack with unsigned saturation (MMX)
  374.  PADDB/PADDW/PADDD             - Packed add (MMX)
  375.  PADDSB/PADDSW                 - Packed add with saturation (MMX)
  376.  PADDUSB/PADDUSW               - Packed add unsigned with saturation (MMX)
  377.  PAND                          - Logical AND (MMX)
  378.  PANDN                         - Logical AND NOT (MMX)
  379.  PCMPEQB/PCMPEQW/PCMPEQD       - Packed compare for equal (MMX)
  380.  PCMPGTB/PCMPGTW/PCMPGTD       - Packed compare for greater than (MMX)
  381.  PMADDWD                       - Packed multiply and add (MMX)
  382.  PMULHW                        - Packed multiply high (MMX)
  383.  PMULLW                        - Packed multiply low (MMX)
  384.  POR                           - Bitwise logical OR (MMX)
  385.  PSLLW/PSLLD/PSLLQ             - Packed shift left logical (MMX)
  386.  PSRAW/PSRAD                   - Packed shift right arithmetic (MMX)
  387.  PSRLW/PSRLD/PSRLQ             - Packed shift right logical (MMX)
  388.  PSUBB/PSUBW/PSUBD             - Packed subtract (MMX)
  389.  PSUBSB/PSUBSW                 - Packed subtract with saturation (MMX)
  390.  PSUBUSB/PSUBUSW               - Packed subtract unsigned with saturation (MMX)
  391.  PUNPCKHBW/PUNPCKHWD/PUNPCKHDQ - Unpack high packed data (MMX)
  392.  PUNPCKLBW/PUNPCKLWD/PUNPCKLDQ - Unpack low packed data (MMX)
  393.  PXOR                          - Logical exclusive OR (MMX)
  394.  RDPMC                         - Read Performance-Monitoring Counters (MMX/Pentium Pro+)
  395. contents
  396. screen
  397.  AAA - ASCII adjust after addition
  398.  Description
  399. Adjusts the sum of two unpacked BCD values to create an unpacked BCD result. The AL register is the implied source and destination operand for this instruction. The AAA instruction is only useful when it follows an ADD instruction that adds (binary addition) two unpacked BCD values and stores a byte result in the AL register. The AAA instruction then adjusts the contents of the AL register to contain the correct 1-digit unpacked BCD result. 
  400. If the addition produces a decimal carry, the AH register is incremented by 1, and the CF and AF flags are set. If there was no decimal carry, the CF and AF flags are cleared and the AH register is unchanged. In either case, bits 4 through 7 of the AL register are cleared to 0. '
  401.  Flags affected
  402. The AF and CF flags are set to 1 if the adjustment results in a decimal carry; otherwise they are cleared to 0. The OF, SF, ZF, and PF flags are undefined. C
  403.  Instruction size and timings
  404.  bytes   8088    186     286     386     486     Pentium
  405.   1       8       8       3       4       3       3   NP
  406.  Example
  407.  aaa       ; ASCII adjust after addition
  408. contents
  409. screen
  410.  AAD - ASCII adjust for division
  411.  Description
  412. Adjusts two unpacked BCD digits (the least-significant digit in the AL register and the most-significant digit in the AH register) so that a division operation performed on the result will yield a correct unpacked BCD value. The AAD instruction is only useful when it precedes a DIV instruction that divides (binary division) the adjusted value in the AX register by an unpacked BCD value. 
  413. The AAD instruction sets the value in the AL register to (AL + (10 * AH)), and then clears the AH register to 00H. The value in the AX register is then equal to the binary equivalent of the original unpacked two-digit (base 10) number in registers AH and AL. '
  414.  Flags affected
  415. The SF, ZF, and PF flags are set according to the result; the OF, AF, and CF flags are undefined. C
  416.  Instruction size and timings
  417.  bytes   8088    186     286     386     486     Pentium
  418.   2      60      15      14      19      14      10   NP
  419.  Example
  420.  aad       ; ASCII adjust for division
  421. contents
  422. screen
  423.  AAM - ASCII adjust for multiplication
  424.  Description
  425. Adjusts the result of the multiplication of two unpacked BCD values to create a pair of unpacked (base 10) BCD values. The AX register is the implied source and destination operand for this instruction. The AAM instruction is only useful when it follows a MUL instruction that multiplies (binary multiplication) two unpacked BCD values and stores a word result in the AX register. The AAM instruction then adjusts the contents of the AX register to contain the correct 2-digit unpacked (base 10) BCD result. '
  426.  Flags affected
  427. The SF, ZF, and PF flags are set according to the result. The OF, AF, and CF flags are undefined. C
  428.  Instruction size and timings
  429.  bytes   8088    186     286     386     486     Pentium
  430.   2      83      19      16      17      15      18   NP
  431.  Example
  432.  aam       ; ASCII adjust for multiplication
  433. contents
  434. screen
  435.  AAS - ASCII adjust after subtraction
  436.  Description
  437. Adjusts the result of the subtraction of two unpacked BCD values to create a unpacked BCD result. The AL register is the implied source and destination operand for this instruction. The AAS instruction is only useful when it follows a SUB instruction that subtracts (binary subtraction) one unpacked BCD value from another and stores a byte result in the AL register. The AAA instruction then adjusts the contents of the AL register to contain the correct 1-digit unpacked BCD result. 
  438. If the subtraction produced a decimal carry, the AH register is decremented by 1, and the CF and AF flags are set. If no decimal carry occurred, the CF and AF flags are cleared, and the AH register is unchanged. In either case, the AL register is left with its top nibble set to 0. &
  439.  Flags affected
  440. The AF and CF flags are set to 1 if there is a decimal borrow; otherwise, they are cleared to 0. -
  441. The OF, SF, ZF, and PF flags are undefined. C
  442.  Instruction size and timings
  443.  bytes   8088    186     286     386     486     Pentium
  444.   1       8       7       3       4       3       3   NP
  445.  Example
  446.  aas       ; ASCII adjust after subtraction
  447. contents
  448. screen
  449.  ADC - Add with carry
  450.  Description
  451. Adds the destination operand (first operand), the source operand (second operand), and the carry (CF) flag and stores the result in the destination operand. 
  452. The destination operand can be a register or a memory location; the source operand can be an immediate, a register, or a memory location. (However, two memory operands cannot be used in one instruction.) 
  453. The state of the CF flag represents a carry from a previous addition. When an immediate value is used as an operand, it is sign-extended to the length of the destination operand format. %
  454. The ADC instruction does not distinguish between signed or unsigned operands. Instead, the processor evaluates the result for both data types and sets the OF and CF flags to indicate a carry in the signed or unsigned result, respectively. The SF flag indicates the sign of the signed result. 
  455. The ADC instruction is usually executed as part of a multibyte or multiword addition in which an ADD instruction is followed by an ADC instruction. '
  456.  Flags affected
  457. The OF, SF, ZF, AF, CF, and PF flags are set according to the result. C
  458.  Instruction size and timings
  459.  operands    bytes   8088    186     286     386     486     Pentium
  460.  reg, reg     2       3       3       2       2       1       1   PU
  461.  mem, reg  2+d(0,2)  24+EA   10       7       7       3       3   PU
  462.  reg, mem  2+d(0,2)  13+EA   10       7       6       2       2   PU
  463.  reg, imm  2+i(1,2)   4       4       3       2       1       1   PU
  464.  mem, imm  2+d(0,2)  23+EA   16       7       7       3       3   PU*
  465.             +i(1,2)
  466.  acc, imm  1+i(1,2)   4       4       3       2       1       1   PU
  467.  * = not pairable if there is a displacement and immediate
  468.  Example
  469.  adc  eax, ebx  ; add with carry
  470. contents
  471. screen
  472.  ADD - addition
  473.  Description
  474. Adds the first operand (destination operand) and the second operand (source operand) and stores the result in the destination operand. The destination operand can be a register or a memory location; the source operand can be an immediate, a register, or a memory location. (However, two memory operands cannot be used in one instruction.) u
  475. When an immediate value is used as an operand, it is sign-extended to the length of the destination operand format. 
  476. The ADD instruction does not distinguish between signed or unsigned operands. Instead, the processor evaluates the result for both data types and sets the OF and CF flags to indicate a carry in the signed or unsigned result, respectively. 6
  477. The SF flag indicates the sign of the signed result. '
  478.  Flags affected
  479. The OF, SF, ZF, AF, CF, and PF flags are set according to the result. C
  480.  Instruction size and timings
  481.  operands    bytes   8088    186     286     386     486     Pentium
  482.  reg, reg     2       3       3       2       2       1       1   UV
  483.  mem, reg  2+d(0,2)  24+EA   10       7       7       3       3   UV
  484.  reg, mem  2+d(0,2)  13+EA   10       7       6       2       2   UV
  485.  reg, imm  2+i(1,2)   4       4       3       2       1       1   UV
  486.  mem, imm  2+d(0,2)  23+EA   16       7       7       3       3   UV*
  487.             +i(1,2)
  488.  acc, imm  1+i(1,2)   4       4       3       2       1       1   UV
  489.  * = not pairable if there is a displacement and immediate
  490.  Example
  491.  add  eax, ebx  ; addition
  492. contents
  493. screen
  494.  AND - Logical AND
  495.  Description
  496. Performs a bitwise AND operation on the destination (first) and source (second) operands and stores the result in the destination operand location. The source operand can be an immediate, a register, or a memory location; the destination operand can be a register or a memory location. (However, two memory operands cannot be used in one instruction.) Each bit of the result of the AND instruction is a 1 if both corresponding bits of the operands are 1; otherwise, it becomes a 0. '
  497.  Flags affected
  498. The OF and CF flags are cleared; the SF, ZF, and PF flags are set according to the result. The state of the AF flag is undefined. C
  499.  Instruction size and timings
  500.  operands    bytes   8088    186     286     386     486     Pentium
  501.  reg, reg     2       3       3       2       2       1       1   UV
  502.  mem, reg  2+d(0,2)  24+EA   10       7       7       3       3   UV
  503.  reg, mem  2+d(0,2)  13+EA   10       7       6       2       2   UV
  504.  reg, imm  2+i(1,2)   4       4       3       2       1       1   UV
  505.  mem, imm  2+d(0,2)  23+EA   16       7       7       3       3   UV*
  506.             +i(1,2)
  507.  acc, imm  1+i(1,2)   4       4       3       2       1       1   UV
  508.  * = not pairable if there is a displacement and immediate
  509.  Example
  510.  and  eax, abx  ; logical AND
  511. contents
  512. screen
  513.  ARPL - Adjust RPL field of segment selector (286+)
  514.  Description
  515. Compares the RPL fields of two segment selectors. The first operand (the destination operand) contains one segment selector and the second operand (source operand) contains the other. (The RPL field is located in bits 0 and 1 of each operand.) 
  516. If the RPL field of the destination operand is less than the RPL field of the source operand, the ZF flag is set and the RPL field of the destination operand is increased to match that of the source operand. Otherwise, the ZF flag is cleared and no change is made to the destination operand. (The destination operand can be a word register or a memory location; the source operand must be a word register.) V
  517. The ARPL instruction is provided for use by operating-system procedures (however, it can also be used by applications). It is generally used to adjust the RPL of a segment selector that has been passed to the operating system by an application program to match the privilege level of the application program. Here the segment selector passed to the operating system is placed in the destination operand and segment selector for the application program's code segment is placed in the source operand. (The RPL field in the source operand represents the privilege level of the application program.) S
  518. Execution of the ARPL instruction then insures that the RPL of the segment selector received by the operating system is no lower (does not have a higher privilege) than the privilege level of the application program. (The segment selector for the application program's code segment can be read from the stack following a procedure call.) '
  519.  Flags affected
  520. The ZF flag is set to 1 if the RPL field of the destination operand is less than that of the source operand; otherwise, is cleared to 0. C
  521.  Instruction size and timings
  522.  operands   bytes                   286     386     486     Pentium
  523.  reg, reg    2                      10      20       9       7   NP
  524.  mem, reg  2+d(0-2)                 11      21       9       7   NP
  525.  Example
  526.  arpl  ax, bx  ; Adjust RPL field of selector
  527. contents
  528. screen
  529.  BOUND - Check array index against bounds (186+)
  530.  Description
  531. Determines if the first operand (array index) is within the bounds of an array specified the second operand (bounds operand). The array index is a signed integer located in a register. The bounds operand is a memory location that contains a pair of signed doubleword-integers (when the operand-size attribute is 32) or a pair of signed word-integers (when the operand-size attribute is 16). 
  532. The first doubleword (or word) is the lower bound of the array and the second doubleword (or word) is the upper bound of the array. The array index must be greater than or equal to the lower bound and less than or equal to the upper bound plus the operand size in bytes. 
  533. If the index is not within bounds, a BOUND range exceeded exception (#BR) is signaled. (When a this exception is generated, the saved return instruction pointer points to the BOUND instruction.) 
  534. The bounds limit data structure (two words or doublewords containing the lower and upper limits of the array) is usually placed just before the array itself, making the limits addressable via a constant offset from the beginning of the array. Because the address of the array already will be present in a register, this practice avoids extra bus cycles to obtain the effective address of the array bounds. '
  535.  Flags affected
  536. None. C
  537.  Instruction size and timings
  538.  operands  bytes           186     286     386     486     Pentium
  539.  reg, mem    4             35      13      10       7       8   NP
  540.  Example
  541.  bound  bx, array       ; check array index (bx) against bounds
  542. contents
  543. screen
  544.  BSF - Bit scan forward (386+)
  545.  Description
  546. Searches the source operand (second operand) for the least significant set bit (1 bit). If a least significant 1 bit is found, its bit index is stored in the destination operand (first operand). 
  547. The source operand can be a register or a memory location; the destination operand is a register. The bit index is an unsigned offset from bit 0 of the source operand. If the contents source operand are 0, the contents of the destination operand is undefined. '
  548.  Flags affected
  549. The ZF flag is set to 1 if all the source operand is 0; otherwise, the ZF flag is cleared. The CF, OF, SF, AF, and PF, flags are undefined. C
  550.  Instruction size and timings
  551.  operands    bytes                           386     486     Pentium
  552.  r16, r16     3                             10+3n    6-42   6-34  NP
  553.  r32, r32     3                             10+3n    6-42   6-42  NP
  554.  r16, m16  3+d(0,1,2)                       10+3n    7-43   6-35  NP
  555.  r32, m32  3+d(0,1,2,4)                     10+3n    7-43   6-43  NP
  556.  Example
  557.  bsf  eax, [esi]  ; Bit scan forward
  558. contents
  559. screen
  560.  BSR - Bit scan reverse (386+)
  561.  Description
  562. Searches the source operand (second operand) for the most significant set bit (1 bit). If a most significant 1 bit is found, its bit index is stored in the destination operand (first operand). The source operand can be a register or a memory location; the destination operand is a register. The bit index is an unsigned offset from bit 0 of the source operand. If the contents source operand are 0, the contents of the destination operand is undefined. '
  563.  Flags affected
  564. The ZF flag is set to 1 if all the source operand is 0; otherwise, the ZF flag is cleared. The CF, OF, SF, AF, and PF, flags are undefined. C
  565.  Instruction size and timings
  566.  operands    bytes                           386     486     Pentium
  567.  r16, r16     3                             10+3n    6-103  7-39  NP
  568.  r32, r32     3                             10+3n    7-104  7-71  NP
  569.  r16, m16  3+d(0,1,2)                       10+3n    6-103  7-40  NP
  570.  r32, m32  3+d(0,1,2,4)                     10+3n    7-104  7-72  NP
  571.  Example
  572.  bsr  eax, [esi]  ; Bit scan reverse
  573. contents
  574. screen
  575.  BSWAP - Byte swap (486+)
  576.  Description
  577. Reverses the byte order of a 32-bit (destination) register: bits 0 through 7 are swapped with bits 24 through 31, and bits 8 through 15 are swapped with bits 16 through 23. This instruction is provided for converting little-endian values to big-endian format and vice versa. To swap bytes in a word value (16-bit register), use the XCHG instruction. When the BSWAP instruction references a 16-bit register, the result is undefined. '
  578.  Flags affected
  579. None. C
  580.  Instruction size and timings
  581.  operand   bytes                                   486     Pentium
  582.  r32        2                                       1       1   NP
  583.  Example
  584.  bswap  eax  ; byte swap
  585. contents
  586. screen
  587.  BT - Bit test (386+)
  588.  Description
  589. Selects the bit in a bit string (specified with the first operand, called the bit base) at the bit-position designated by the bit offset operand (second operand) and stores the value of the bit in the CF flag. f
  590. The bit base operand can be a register or a memory location; the bit offset operand can be a register or an immediate value. If the bit base operand specifies a register, the instruction takes the modulo 16 or 32 (depending on the register size) of the bit offset operand, allowing any bit position to be selected in a 16- or 32-bit register, respectively. ?
  591. If the bit base operand specifies a memory location, it represents the address of the byte in memory that contains the bit base (bit 0 of the specified byte) of the bit string. The offset operand then selects a bit position within the range -2^31 to 2^31 - 1 for a register offset and 0 to 31 for an immediate offset. '
  592.  Flags affected
  593. The CF flag contains the value of the selected bit. The OF, SF, ZF, AF, and PF flags are undefined. C
  594.  Instruction size and timings
  595.  operands     bytes                           386     486     Pentium
  596.  reg, reg      3                               3       3       4   NP
  597.  mem, reg    3+d(0,1,2,4)                     12       8       9   NP
  598.  reg, imm8     3+i(1)                          3       3       4   NP
  599.  mem, imm8   3+d(0,1,2,4)+i(1)                 6       3       4   NP
  600.  Example
  601.  bt  eax, 4  ; Bit test
  602. contents
  603. screen
  604.  BTC - Bit test and complement (386+)
  605.  Description
  606. Selects the bit in a bit string (specified with the first operand, called the bit base) at the bit-position designated by the bit offset operand (second operand), stores the value of the bit in the CF flag, and complements the selected bit in the bit string. f
  607. The bit base operand can be a register or a memory location; the bit offset operand can be a register or an immediate value. If the bit base operand specifies a register, the instruction takes the modulo 16 or 32 (depending on the register size) of the bit offset operand, allowing any bit position to be selected in a 16- or 32-bit register, respectively. 
  608. If the bit base operand specifies a memory location, it represents the address of the byte in memory that contains the bit base (bit 0 of the specified byte) of the bit string. 
  609. The offset operand then selects a bit position within the range -2^31 to 2^31 - 1 for a register offset and 0 to 31 for an immediate offset. '
  610.  Flags affected
  611. The CF flag contains the value of the selected bit before it is complemented. The OF, SF, ZF, AF, and PF flags are undefined. C
  612.  Instruction size and timings
  613.  operands    bytes                           386     486     Pentium
  614.  reg, reg     3                               6       6       7   NP
  615.  mem, reg   3+d(0,1,2,4)                     13      13      13   NP
  616.  reg, imm8    3+i(1)                          6       6       7   NP
  617.  mem, imm8  3+d(0,1,2,4)+i(1)                 8       8       8   NP
  618.  Example
  619.  btc  eax, 4  ; Bit test and complement
  620. contents
  621. screen
  622.  BTR - Bit test and reset (386+)
  623.  Description
  624. Selects the bit in a bit string (specified with the first operand, called the bit base) at the bit-position designated by the bit offset operand (second operand), stores the value of the bit in the CF flag, and clears the selected bit in the bit string to 0. The bit base operand can be a register or a memory location; the bit offset operand can be a register or an immediate value. 
  625. If the bit base operand specifies a register, the instruction takes the modulo 16 or 32 (depending on the register size) of the bit offset operand, allowing any bit position to be selected in a 16- or 32-bit register, respectively. 
  626. If the bit base operand specifies a memory location, it represents the address of the byte in memory that contains the bit base (bit 0 of the specified byte) of the bit string. 
  627. The offset operand then selects a bit position within the range -2^31 to 2^31 - 1 for a register offset and 0 to 31 for an immediate offset. '
  628.  Flags affected
  629. The CF flag contains the value of the selected bit before it is cleared. The OF, SF, ZF, AF, and PF flags are undefined. C
  630.  Instruction size and timings
  631.  operands    bytes                           386     486     Pentium
  632.  reg, reg     3                               6       6       7   NP
  633.  mem, reg   3+d(0,1,2,4)                     13      13      13   NP
  634.  reg, imm8    3+i(1)                          6       6       7   NP
  635.  mem, imm8  3+d(0,1,2,4)+i(1)                 8       8       8   NP
  636.  Example
  637.  btr  eax, 4    ; Bit test and reset
  638. contents
  639. screen
  640.  BTS - Bit test and set (386+)
  641.  Description
  642. Selects the bit in a bit string (specified with the first operand, called the bit base) at the bit-position designated by the bit offset operand (second operand), stores the value of the bit in the CF flag, and sets the selected bit in the bit string to 1. The bit base operand can be a register or a memory location; the bit offset operand can be a register or an immediate value. 
  643. If the bit base operand specifies a register, the instruction takes the modulo 16 or 32 (depending on the register size) of the bit offset operand, allowing any bit position to be selected in a 16- or 32-bit register, respectively. 
  644. If the bit base operand specifies a memory location, it represents the address of the byte in memory that contains the bit base (bit 0 of the specified byte) of the bit string). 
  645. The offset operand then selects a bit position within the range -2^31 to 2^31 - 1 for a register offset and 0 to 31 for an immediate offset. '
  646.  Flags affected
  647. The CF flag contains the value of the selected bit before it is set. The OF, SF, ZF, AF, and PF flags are undefined. C
  648.  Instruction size and timings
  649.  operands    bytes                           386     486     Pentium
  650.  reg, reg     3                               6       6       7   NP
  651.  mem, reg   3+d(0,1,2,4)                     13      13      13   NP
  652.  reg, imm8    3+i(1)                          6       6       7   NP
  653.  mem, imm8  3+d(0,1,2,4)+i(1)                 8       8       8   NP
  654.  Example
  655.  bts  eax, 4    ; Bit test and set
  656. contents
  657. screen
  658.  CALL - procedure call
  659.  Description
  660. Pushes the Instruction Pointer (and Code Segment for far calls) onto the stack and loads Instruction Pointer with the address of the procedure. Code continues with execution at CS:IP. &
  661.  Flags affected
  662. None. B
  663.  Instruction size and timings
  664.  operand    bytes   8088    186     286     386     486     Pentium
  665.  near        3      23      14      7+m     7+m      3       1   PV
  666.  reg         2      20      13      7+m     7+m      5       2   NP
  667.  mem16    2+d(0-2)  29+EA   19      11+m    10+m     5       2   NP
  668.  far         5      36      23      13+m    17+m    18       4   NP
  669.  mem32    2+d(0-2)  53+EA   38      16+m    22+m    17       4   NP
  670.  Protected Mode
  671.  operand    bytes                   286     386     486     Pentium
  672.  far         5                      26+m    34+m    20     4-13  NP
  673.  mem32    2+d(0-2)                  29+m    38+m    20     5-14  NP
  674.  Cycles not shown for calls through call and task gates
  675.  Example
  676.  call my_procedure      ; Call procedure 'my_procedure'
  677. contents
  678. screen
  679.  CBW - Convert byte to word
  680.  Description
  681. Converts byte in AL to word value in AX by extending sign of AL throughout register AH. '
  682.  Flags affected
  683. None. C
  684.  Instruction size and timings
  685.  bytes   8088    186     286     386     486     Pentium
  686.   1       2       2       2       3       3       3   NP
  687.  Example
  688.  cbw       ; Convert byte to word
  689. contents
  690. screen
  691.  CDQ - Convert double to quad (386+)
  692.  Description
  693. Converts signed DWORD in EAX to a signed quad word in EDX:EAX by extending the high order bit of EAX throughout EDX. '
  694.  Flags affected
  695. None. C
  696.  Instruction size and timings
  697.  bytes                           386     486     Pentium
  698.   1                               2       3       2   NP
  699.  Example
  700.  cdq       ; Convert double to quad
  701. contents
  702. screen
  703.  CLC - Clear carry
  704.  Description
  705. Clears the Carry Flag in the EFLAGS register (sets it to 0). &
  706.  Flags affected
  707. Modifies CF. C
  708.  Instruction size and timings
  709.  bytes   8088    186     286     386     486     Pentium
  710.   1       2       2       2       2       2       2   NP
  711.  Example
  712.  clc       ; Clear carry flag
  713. contents
  714. screen
  715.  CLD - Clear direction flag
  716.  Description
  717. Clears the Direction Flag in the EFLAGS register causing string instructions to increment the (E)SI and (E)DI index registers. '
  718.  Flags affected
  719. Modifies DF. C
  720.  Instruction size and timings
  721.  bytes   8088    186     286     386     486     Pentium
  722.   1       2       2       2       2       2       2   NP
  723.  Example
  724.  cld       ; Clear direction flag
  725. contents
  726. screen
  727.  CLI - Clear interrupt flag
  728.  Description
  729. Clears the IF flag in the EFLAGS register. No other flags are affected. Clearing the IF flag causes the processor to ignore maskable external interrupts. The IF flag and the CLI and STI instructions have no affect on the generation of exceptions and NMI interrupts. '
  730.  Flags affected
  731. Modifies IF. C
  732.  Instruction size and timings
  733.  bytes   8088    186     286     386     486     Pentium
  734.   1       2       2       3       3       5       7   NP
  735.  Example
  736.  cli       ; Clear interrupt flag
  737. contents
  738. screen
  739.  CLTS - Clear task switched flag (286+)
  740.  Description
  741. Clears the task-switched (TS) flag in the CR0 register. This instruction is intended for use in operating-system procedures. It is a privileged instruction that can only be executed at a CPL of 0. It is allowed to be executed in real-address mode to allow initialization for protected mode. 
  742. The processor sets the TS flag every time a task switch occurs. The flag is used to synchronize the saving of FPU context in multitasking applications. '
  743.  Flags affected
  744. Modifies the TS flag in the CR0 register. C
  745.  Instruction size and timings
  746.  bytes                   286     386     486     Pentium
  747.   2                       3       5       7      10   NP
  748.  Example
  749.  clts       ; Clear task switched flag
  750. contents
  751. screen
  752.  CMC - Complement carry flag
  753.  Description
  754. Complements the carry flag in the EFLAGS register. '
  755.  Flags affected
  756. Modifies CF to the value of ~CF. C
  757.  Instruction size and timings
  758.  bytes   8088    186     286     386     486     Pentium
  759.   1       2       2       2       2       2       2   NP
  760.  Example
  761.  cmc        ; Complement carry flag
  762. contents
  763. screen
  764.  CMOVcc - Conditional move
  765.  Description
  766. The CMOVcc instructions check the state of one or more of the status flags in the EFLAGS register (CF, OF, PF, SF, and ZF) and perform a move operation if the flags are in a specified state (or condition). A condition code (cc) is associated with each instruction to indicate the condition being tested for. If the condition is not satisfied, a move is not performed and execution continues with the instruction following the CMOVcc instruction. 
  767. These instructions can move a 16 or 32 bit value from memory to a general purpose register or from one general purpose register to another. Conditional moves of 8 bit register operands are not supported. 
  768. The conditions for each CMOVcc mnemonic is given in the description column of the table below. The terms "less" and "greater" are used for comparisons of signed integers and the terms "above" and "below" are used for unsigned integers. 2
  769. Because a particular state of the status flags can sometimes be interpreted in two ways, two mnemonics are defined for some opcodes. For example, the CMOVA (conditional move if above) instruction and the CMOVNBE (conditional move if not below or equal) instruction are alternate mnemonics for the opcode. 
  770. The CMOVcc instructions are new for the Pentium Pro processor family; however, they may not be supported by all the processors in the family. Software can determine if the CMOVcc instructions are supported by checking the processor's feature information with the CPUID instruction. 
  771.  Instruction    Description
  772.  CMOVA          Move if above (CF=0 and ZF=0)
  773.  CMOVAE         Move if above or equal (CF=0)
  774.  CMOVB          Move if below (CF=1)
  775.  CMOVBE         Move if below or equal (CF=1 or ZF=1)
  776.  CMOVC          Move if carry (CF=1)
  777.  CMOVE          Move if equal (ZF=1)
  778.  CMOVG          Move if greater (ZF=0 and SF=OF)
  779.  CMOVGE         Move if greater or equal (SF=OF)
  780.  CMOVL          Move if less (SF<>OF)
  781.  CMOVLE         Move if less or equal (ZF=1 or SF<>OF)
  782.  CMOVNA         Move if not above (CF=1 or ZF=1)
  783.  CMOVNAE        Move if not above or equal (CF=1)
  784.  CMOVNB         Move if not below (CF=0)
  785.  CMOVNBE        Move if not below or equal (CF=0 and ZF=0)
  786.  CMOVNC         Move if not carry (CF=0)
  787.  CMOVNE         Move if not equal (ZF=0)
  788.  CMOVNG         Move if not greater (ZF=1 or SF<>OF)
  789.  CMOVNGE        Move if not greater or equal (SF<>OF)
  790.  CMOVNL         Move if not less (SF=OF)
  791.  CMOVNLE        Move if not less or equal (ZF=0 and SF=OF)
  792.  CMOVNO         Move if not overflow (OF=0)
  793.  CMOVNP         Move if not parity (PF=0)
  794.  CMOVNS         Move if not sign (SF=0)
  795.  CMOVNZ         Move if not zero (ZF=0)
  796.  CMOVO          Move if overflow (OF=0)
  797.  CMOVP          Move if parity (PF=1)
  798.  CMOVPE         Move if parity even (PF=1)
  799.  CMOVPO         Move if parity odd (PF=0)
  800.  CMOVS          Move if sign (SF=1)
  801.  CMOVZ          Move if zero (ZF=1)
  802.  Flags affected
  803. None. C
  804.  Instruction size and timings
  805. Not available. 
  806.  Example
  807.  cmovs ax, bx   ; Move ax to bx if the sign flag is set (SF = 1)
  808. contents
  809. screen
  810.  CMP - Compare two operands
  811.  Description
  812. Compares the first source operand with the second source operand and sets the status flags in the EFLAGS register according to the results. The comparison is performed by subtracting the second operand from the first operand and then setting the status flags in the same manner as the SUB instruction. h
  813. When an immediate value is used as an operand, it is sign-extended to the length of the first operand. 
  814. The CMP instruction is typically used in conjunction with a conditional jump (Jcc), condition move (CMOVcc), or SETcc instruction. The condition codes used by the Jcc, CMOVcc, and SETcc instructions are based on the results of a CMP instruction. '
  815.  Flags affected
  816. The CF, OF, SF, ZF, AF, and PF flags are set according to the result. C
  817.  Instruction size and timings
  818.  operands    bytes   8088    186     286     386     486     Pentium
  819.  reg, reg     2       3       3       2       2       1       1   UV
  820.  mem, reg  2+d(0,2)  13+EA   10       7       5       2       2   UV
  821.  reg, mem  2+d(0,2)  13+EA   10       6       6       2       2   UV
  822.  reg, imm  2+i(1,2)   4       4       3       2       1       1   UV
  823.  mem, imm  2+d(0,2)  14+EA   10       6       5       2       2   UV*
  824.             +i(1,2)
  825.  acc, imm  1+i(1,2)   4       4       3       2       1       1   UV
  826.         * = not pairable if there is a displacement and immediate
  827.  Example
  828.  cmp eax, 3     ; Compare eax register with 3
  829. contents
  830. screen
  831.  CMPS - Compare string operands
  832.  Description
  833. Compares the byte, word, or double word specified with the first source operand with the byte, word, or double word specified with the second source operand and sets the status flags in the EFLAGS register according to the results. 
  834. Both the source operands are located in memory. The address of the first source operand is read from either the DS:ESI or the DS:SI registers (depending on the address-size attribute of the instruction, 32 or 16, respectively). 
  835. The address of the second source operand is read from either the ES:EDI or the ES:DI registers (again depending on the address-size attribute of the instruction). The DS segment may be overridden with a segment override prefix, but the ES segment cannot be overridden. 
  836. After the comparison, the (E)SI and (E)DI registers are incremented or decremented automatically according to the setting of the DF flag in the EFLAGS register. (If the DF flag is 0, the (E)SI and (E)DI register are incremented; if the DF flag is 1, the (E)SI and (E)DI registers are decremented.) The registers are incremented or decremented by 1 for byte operations, by 2 for word operations, or by 4 for doubleword operations. 4
  837. The CMPSB, CMPSW, and CMPSD instructions can be preceded by the REP prefix for block comparisons of ECX bytes, words, or doublewords. More often, however, these instructions will be used in a LOOP construct that takes some action based on the setting of the status flags before the next comparison is made. 
  838. Please note that NASM does not support the CMPS instruction. It does however support the CMPSB, CMPSW and CMPSD versions of the instruction. '
  839.  Flags affected
  840. The CF, OF, SF, ZF, AF, and PF flags are set according to the temporary result of the comparison. C
  841.  Instruction size and timings
  842.  variations    bytes   8088    186     286     386     486     Pentium
  843.  cmpsb          1      30      22       8      10       8       5   NP
  844.  cmpsw          1      -       -        -      10       8       5   NP
  845.  cmpsd          1      -       -        -      10       8       5   NP
  846.  repX cmpsb     2      9+30n   5+22n   5+9n    5+9n    7+7n*   9+4n NP
  847.  repX cmpsw     2      9+30n   5+22n   5+9n    5+9n    7+7n*   9+4n NP
  848.  repX cmpsd     2       -       -       -      5+9n    7+7n*   9+4n NP
  849.  repX = repe, repz, repne or repnz
  850.  * : 5 if n = 0
  851.  Example
  852.  repne cmpsb        ; Repeat compare until operands are not equal
  853. contents
  854. screen
  855.  CMPXCHG - Compare and exchange (486+)
  856.  Description
  857. Compares the value in the AL, AX, or EAX register (depending on the size of the operand) with the first operand (destination operand). If the two values are equal, the second operand (source operand) is loaded into the destination operand. Otherwise, the destination operand is loaded into the AL, AX, or EAX register. '
  858.  Flags affected
  859. The ZF flag is set if the values in the destination operand and register AL, AX, or EAX are equal; otherwise it is cleared. The CF, PF, AF, SF, and OF flags are set according to the results of the comparison operation. C
  860.  Instruction size and timings
  861.  operands        bytes                           486     Pentium
  862.  reg, reg         3                               6       5   NP
  863.  mem, reg       3+d(0-2)                         7-10     6   NP
  864.  Example
  865.  cmpxchg ebx, edx   ; Compare and exchange ebx and edx
  866. contents
  867. screen
  868.  CMPXCHG8B - Compare and exchange 8 bytes (Pentium+)
  869.  Description
  870. Compares the 64-bit value in EDX:EAX with the operand (destination operand). If the values are equal, the 64-bit value in ECX:EBX is stored in the destination operand. Otherwise, the value in the destination operand is loaded into EDX:EAX. The destination operand is an 8-byte memory location. For the EDX:EAX and ECX:EBX register pairs, EDX and ECX contain the high-order 32 bits and EAX and EBX contain the low-order 32 bits of a 64-bit value. '
  871.  Flags affected
  872. The ZF flag is set if the destination operand and EDX:EAX are equal; otherwise it is cleared. The CF, PF, AF, SF, and OF flags are unaffected. C
  873.  Instruction size and timings
  874.  operands      bytes                                   Pentium
  875.  mem, reg     3+d(0-2)                                 10   NP
  876.  Example
  877.  cmpxchg8b [ebx], edx   ; Compare and exchange ebx and edx
  878. contents
  879. screen
  880.  CPUID - CPU identification (486+)
  881.  Description
  882. Provides processor identification information in registers EAX, EBX, ECX, and EDX. This information identifies the vendor, family, model, and stepping of the processor, feature information, and cache information. 
  883. Note that only later versions of 486 processors support the CPUID instruction. The CPUID instruction officially became available on Pentium processors. e
  884. An input value loaded into the EAX register determines what information is returned as shown below. K
  885.  Initial
  886.    EAX          Information Provided about the Processor
  887.   Value
  888.     0           EAX  Maximum CPUID Input Value (2 for the Pentium 
  889.                      processor and 1 for the Pentium processor and the later
  890.                      versions of 486 class processors that support the
  891.                      CPUID instruction).
  892.                 EBX, ECX and EDX contain a vendor name, e.g.
  893.                      "GenuineIntel" for Intel processors
  894.                      "AuthenticAMD" for AMD processors
  895.                      "CyrixInstead" for Cyrix processors
  896.                      "UMCUMCUMCUMC" for UMC processors
  897.     1           EAX  Version Information (Type, Family, Model, and Stepping ID)
  898.                 EBX  Reserved
  899.                 ECX  Reserved
  900.                 EDX  Feature Information
  901.     2           EAX  Cache and TLB Information
  902.                 EBX  Cache and TLB Information
  903.                 ECX  Cache and TLB Information
  904.                 EDX  Cache and TLB Information
  905. Bit 21 of the EFLAGS register can be used to determine if the CPUID instruction is supported by the processor. \
  906. The following information details the contents of the registers for the CPUID instruction. &
  907.  Calling CPUID with EAX = 1 returns:
  908.          EAX[3:0]       <- Stepping ID
  909.          EAX[7:4]       <- Model
  910.          EAX[11:8]      <- Family
  911.                                  ; 3 - 386 family
  912.                                  ; 4 - 486 family
  913.                                  ; 5 - Pentium family
  914.                                  ; 6 - Pentium Pro family
  915.          EAX[15:12]     <- Reserved
  916.                                  ; 0 - Original OEM processor
  917.                                  ; 1 - OverDrive
  918.                                  ; 2 - Dual Processor
  919.          Note: Pentium chips have pin CPUTYPE which defines which socket the
  920.                CPU is located in. For example: if the chip is in the first
  921.                socket AX = 0245h, however in the second socket it would
  922.                equal 2425h
  923.          EAX[31:16]     <- Reserved and set to zeros
  924.          EDX            <- Compability flags (a bit is set if a feature
  925.                            is supported by the CPU)
  926.          EDX[0]         <- FPU : FPU on Chip
  927.          EDX[1]         <- VME : Virtual Mode Extension present
  928.          EDX[2]         <- DE  : Debbuging Extentions
  929.          EDX[3]         <- PSE : CPU supports 4MB size pages
  930.          EDX[4]         <- TSC : TSC present (see RDTSC opcode)
  931.          EDX[5]         <- MSR : CPU has Pentium Compatible MSRs
  932.          EDX[6]         <- PAE : Physical Address Extension
  933.          EDX[7]         <- MCE : Machine Check Exception
  934.          EDX[8]         <- CX8 : Supports the CMPXCHG8B instruction
  935.          EDX[9]         <- APIC: Local APIC on Chip (Intel)
  936.                            PGE : Page Global Extension (AMD K5)
  937.          EDX[10]        <- Reserved
  938.          EDX[11]        <- Reserved
  939.          EDX[12]        <- MTRR: CPU supports Memory Type Range Register
  940.                                  (MTRR)
  941.          EDX[13]        <- PGE : Page Global Feature support
  942.          EDX[14]        <- MCA : Machine Check Architecture
  943.          EDX[15]        <- CMOV: CPU supports CMOVcc instruction
  944.          EDX[22..16]    <- Reserved
  945.          EDX[23]        <- MMX : CPU supports IA MMX
  946.          EDX[31:24]     <- Reserved and set to zeros
  947.  Calling CPUID with EAX = 2 returns (Pentium Pro+):
  948.          AL = 1     (Pentium Pro)
  949.          The remainder of EAX and EBX, ECX and EDX contain bytes which
  950.          described cache architecture on the chip.
  951.          Value         Description
  952.          00h           None
  953.          01h           Instruction TLB, 4K page, 4 way, 64 entry
  954.          02h           Instruction TLB, 4M page, 4 way, 4 entry
  955.          03h           Data TLB, 4K page, 4 way, 64 entry
  956.          04h           Data TLB, 4M page, 4 way, 8 entry
  957.          06h           Instruction Cache, 8K, 4 way, 32 bytes per line
  958.          0Ah           Data cache, 8K, 2 way, 32 bytes per line
  959.          41h           Unified cache, 32 bytes per line, 4 way, 128KB
  960.          42h           Unified cache, 32 bytes per line, 4 way, 256KB
  961.          43h           Unified cache, 32 bytes per line, 4 way, 512KB
  962.  Flags affected
  963. None. C
  964.  Instruction size and timings
  965.  bytes                                           Pentium
  966.   2                                              14   NP
  967.  Example
  968.  cpuid          ; Get CPU information
  969. contents
  970. screen
  971.  CWD - Convert word to doubleword
  972.  Description
  973. Extends sign of word in register AX throughout register DX forming a doubleword quantity in DX:AX. '
  974.  Flags affected
  975. None. C
  976.  Instruction size and timings
  977.  bytes   8088    186     286     386     486     Pentium
  978.   1       5       4       2       2       3       2   NP
  979.  Example
  980.  cwd            ; Convert word in AX to doubleword in DX:AX
  981. contents
  982. screen
  983.  CWDE - Convert word to extended doubleword (386+)
  984.  Description
  985. Converts a signed word in AX to a signed doubleword in EAX by extending the sign bit of AX throughout EAX. '
  986.  Flags affected
  987. None. C
  988.  Instruction size and timings
  989.  bytes                           386     486     Pentium
  990.   1                               3       3       3   NP
  991.  Example
  992.  cwde           ; Convert word in AX to doubleword in EAX
  993. contents
  994. screen
  995.  DAA - Decimal adjust AL after addition
  996.  Description
  997. Adjusts the sum of two packed BCD values to create a packed BCD result. The AL register is the implied source and destination operand. The DAA instruction is only useful when it follows an ADD instruction that adds (binary addition) two 2-digit, packed BCD values and stores a byte result in the AL register. The DAA instruction then adjusts the contents of the AL register to contain the correct 2-digit, packed BCD result. If a decimal carry is detected, the CF and AF flags are set accordingly. '
  998.  Flags affected
  999. The CF and AF flags are set if the adjustment of the value results in a decimal carry in either digit of the result (see above). The SF, ZF, and PF flags are set according to the result. The OF flag is undefined. C
  1000.  Instruction size and timings
  1001.  bytes   8088    186     286     386     486     Pentium
  1002.   1       4       4       3       4       2       3   NP
  1003.  Example
  1004.  add al, bx     ; Before: AL=79H BL=35H EFLAGS(OSZAPC)=XXXXXX
  1005.                 ; After : AL=AEH BL=35H EFLAGS(0SZAPC)=110000
  1006.  daa            ; Before: AL=AEH BL=35H EFLAGS(OSZAPC)=110000
  1007.                 ; After : AL=14H BL=35H EFLAGS(0SZAPC)=X00111
  1008. contents
  1009. screen
  1010.  DAS - Decimal adjust AL after subtraction
  1011.  Description
  1012. Adjusts the result of the subtraction of two packed BCD values to create a packed BCD result. The AL register is the implied source and destination operand. The DAS instruction is only useful when it follows a SUB instruction that subtracts (binary subtraction) one 2-digit, packed BCD value from another and stores a byte result in the AL register. The DAS instruction then adjusts the contents of the AL register to contain the correct 2-digit, packed BCD result. If a decimal borrow is detected, the CF and AF flags are set accordingly. '
  1013.  Flags affected
  1014. The CF and AF flags are set if the adjustment of the value results in a decimal borrow in either digit of the result (see above). The SF, ZF, and PF flags are set according to the result. The OF flag is undefined. C
  1015.  Instruction size and timings
  1016.  bytes   8088    186     286     386     486     Pentium
  1017.   1       4       4       3       4       2       3   NP
  1018.  Example
  1019.  sub al, bl     ; Before: AL=35H BL=47H EFLAGS(OSZAPC)=XXXXXX
  1020.                 ; After : AL=EEH BL=47H EFLAGS(0SZAPC)=010111
  1021.  das            ; Before: AL=EEH BL=47H EFLAGS(OSZAPC)=010111
  1022.                 ; After : AL=88H BL=47H EFLAGS(0SZAPC)=X10111
  1023. contents
  1024. screen 
  1025.  DEC - Decrement
  1026.  Description
  1027. Subtracts 1 from the destination operand, while preserving the state of the CF flag. The destina-tion operand can be a register or a memory location. This instruction allows a loop counter to be updated without disturbing the CF flag. (To perform a decrement operation that updates the CF flag, use a SUB instruction with an immediate operand of 1.) '
  1028.  Flags affected
  1029. The CF flag is not affected. The OF, SF, ZF, AF, and PF flags are set according to the result. C
  1030.  Instruction size and timings
  1031.  operand     bytes   8088    186     286     386     486     Pentium
  1032.  r8           2       3       3       2       2       1       1   UV
  1033.  r16          1       3       3       2       2       1       1   UV
  1034.  r32          1       3       3       2       2       1       1   UV
  1035.  mem       2+d(0,2)  23+EA   15       7       6       3       3   UV
  1036.  Example
  1037.  dec eax        ; Subtract one from eax (eax = eax - 1)
  1038. contents
  1039. screen
  1040.  DIV - Unsigned divide
  1041.  Description
  1042. Divides (unsigned) the value in the AX register, DX:AX register pair, or EDX:EAX register pair (dividend) by the source operand (divisor) and stores the result in the AX (AH:AL), DX:AX, or EDX:EAX registers. The source operand can be a general-purpose register or a memory location. The action of this instruction depends on the operand size, as shown in the following table: 
  1043.  Operand Size     Dividend    Divisor    Quotient    Remainder    Maximum
  1044.                                                                   Quotient
  1045.  Word/byte        AX          r/m8       AL          AH           255
  1046.  Doubleword/
  1047.  word             DX:AX       r/m16      AX          DX           65,535
  1048.  Quadword/
  1049.  doubleword       EDX:EAX     r/m32      EAX         EDX          2^32 - 1
  1050. Non-integral results are truncated towards 0. The remainder is always less than the divisor in magnitude. '
  1051.  Flags affected
  1052. The CF flag is not affected. The OF, SF, ZF, AF, and PF flags are set according to the result. C
  1053.  Instruction size and timings
  1054.  operand     bytes   8088    186     286     386     486     Pentium
  1055.  r8           2     80-90     29     14      14      16      17   NP
  1056.  r16          2    144-162    38     22      22      24      25   NP
  1057.  r32          2       -       -       -      38      40      41   NP
  1058.  mem8    2+d(0-2)   86-96+EA  35     17      17      16      17   NP
  1059.  mem16   2+d(0-2)  150-168+EA 44     25      25      24      25   NP
  1060.  mem32   2+d(0-2)     -       -       -      41      40      41   NP
  1061.  Example
  1062.  div ebx        ; divide EDX:EAX by EBX
  1063. contents
  1064. screen
  1065.  EMMS - Empty MMX state (MMX)
  1066.  Description
  1067. Sets the values of all the tags in the FPU tag word to empty (all ones). This operation marks the MMX registers as available, so they can subsequently be used by floating-point instructions. All other MMX instructions (other than the EMMS instruction) set all the tags in FPU tag word to valid (all zeros). 
  1068. The EMMS instruction must be used to clear the MMX state at the end of all MMX routines and before calling other procedures or subroutines that may execute floating-point instructions. If a floating-point instruction loads one of the registers in the FPU register stack before the FPU tag word has been reset by the EMMS instruction, a floating-point stack overflow can occur that will result in a floating-point exception or incorrect result. '
  1069.  Flags affected
  1070. None. C
  1071.  Instruction size and timings
  1072. Not available. 
  1073.  Example
  1074.  emms           ; Set the FP tag word to empty
  1075. contents
  1076. screen
  1077.  ENTER - Make stack frame for parameters (186+)
  1078.  Description
  1079. Creates a stack frame for a procedure. The first operand (size operand) specifies the size of the stack frame (that is, the number of bytes of dynamic storage allocated on the stack for the procedure). The second operand (nesting level operand) gives the lexical nesting level (0 to 31) of the procedure. The nesting level determines the number of stack frame pointers that are copied into the "display area" of the new stack frame from the preceding frame. Both of these operands are immediate values. 
  1080. The stack-size attribute determines whether the BP (16 bits) or EBP (32 bits) register specifies the current frame pointer and whether SP (16 bits) or ESP (32 bits) specifies the stack pointer. j
  1081. The ENTER and companion LEAVE instructions are provided to support block structured languages. The ENTER instruction (when used) is typically the first instruction in a procedure and is used to set up a new stack frame for a procedure. The LEAVE instruction is then used at the end of the procedure (just before the RET instruction) to release the stack frame. 
  1082. If the nesting level is 0, the processor pushes the frame pointer from the EBP register onto the stack, copies the current stack pointer from the ESP register into the EBP register, and loads the ESP register with the current stack-pointer value minus the value in the size operand. For nesting levels of 1 or greater, the processor pushes additional frame pointers on the stack before adjusting the stack pointer. These additional frame pointers provide the called procedure with access points to other nested frames on the stack. '
  1083.  Flags affected
  1084. None. C
  1085.  Instruction size and timings
  1086.  operands     bytes   8088    186     286     386     486     Pentium
  1087.  imm16, 0       3      -      15      11      10      14      11   NP
  1088.  imm16, 1       4      -      25      15      12      17      15   NP
  1089.  imm16, imm8    4      -   22+16n    12+4n   15+4n   17+3i  15+2i  NP
  1090.                            n = imm8-1;  i = imm8
  1091.  Example
  1092.  enter 1, 0             ; Create stack frame of 1 byte with 0 nesting levels
  1093. contents
  1094. screen
  1095.  ESC - Escape
  1096.  Description
  1097. Provides access to the data bus for other resident processors. The CPU treats it as a NOP but places memory operand on bus. '
  1098.  Flags affected
  1099. None. C
  1100.  Instruction size and timings
  1101. Not available. 
  1102.  Example
  1103. Not available. 
  1104. contents
  1105. screen
  1106.  HLT - Halt
  1107.  Description
  1108. Stops instruction execution and places the processor in a HALT state. An enabled interrupt, NMI, or a reset will resume execution. If an interrupt (including NMI) is used to resume execution after a HLT instruction, the saved instruction pointer (CS:EIP) points to the instruction following the HLT instruction. 
  1109. The HLT instruction is a privileged instruction. When the processor is running in protected or virtual-8086 mode, the privilege level of a program or procedure must be 0 to execute the HLT instruction. '
  1110.  Flags affected
  1111. None. C
  1112.  Instruction size and timings
  1113.  bytes   8088    186     286     386     486     Pentium
  1114.   1       2       2       2       5       4       4   NP
  1115.  Example
  1116.  hlt            ; Enter halt state
  1117. contents
  1118. screen
  1119.  IDIV - Signed divide
  1120.  Description
  1121. Divides (signed) the value in the AL, AX, or EAX register by the source operand and stores the result in the AX, DX:AX, or EDX:EAX registers. The source operand can be a general-purpose register or a memory location. ^
  1122. The action of this instruction depends on the operand size, as shown in the following table: 
  1123.  Operand      Dividend    Divisor    Quotient  Remainder  Quotient
  1124.  Size                                                     Range
  1125.  Word/
  1126.  byte         AX          r/m8       AL        AH         -128 to +127
  1127.  Doubleword/
  1128.  word         DX:AX       r/m16      AX        DX         -32,768 to +32,767
  1129.  Quadword/
  1130.  doubleword   EDX:EAX     r/m32      EAX       EDX        -2^31 to 2^32 - 1
  1131. Non-integral results are truncated towards 0. The sign of the remainder is always the same as the sign of the dividend. The absolute value of the remainder is always less than the absolute value of the divisor. '
  1132.  Flags affected
  1133. The CF, OF, SF, ZF, AF, and PF flags are undefined. C
  1134.  Instruction size and timings
  1135.  operand    bytes    8088      186    286    386    486     Pentium
  1136.  r8          2     101-112    44-52   17     19     19      22   NP
  1137.  r16         2     165-184    53-61   25     27     27      30   NP
  1138.  r32         2       -          -      -     43     43      46   NP
  1139.  mem8   2+d(0-2)  107-118+EA  50-58   20     22     20      22   NP
  1140.  mem16  2+d(0-2)  171-190+EA  59-67   28     30     28      30   NP
  1141.  mem32  2+d(0-2)     -          -      -     46     44      46   NP
  1142.  Example
  1143.  idiv ebx       ; Signed divide EAX by EBX
  1144. contents
  1145. screen
  1146.  IMUL - Signed multiply
  1147.  Description
  1148. Performs a signed multiplication of two operands. This instruction has three forms, depending on the number of operands. 
  1149.  One-operand form
  1150. This form is identical to that used by the MUL instruction. Here, the source operand (in a general-purpose register or memory location) is multiplied by the value in the AL, AX, or EAX register (depending on the operand size) and the product is stored in the AX, DX:AX, or EDX:EAX registers, respectively. 
  1151.  Two-operand form (286+)
  1152. With this form the destination operand (the first operand) is multiplied by the source operand (second operand). The destination operand is a general-purpose register and the source operand is an immediate value, a general-purpose register (386+), or a memory location (386+). The product is then stored in the destination operand location. 
  1153.  Three-operand form (286+)
  1154. This form requires a destination operand (the first operand) and two source operands (the second and the third operands). Here, the first source operand (which can be a general-purpose register or a memory location) is multiplied by the second source operand (an immediate value). The product is then stored in the destination operand (a general-purpose register). u
  1155. When an immediate value is used as an operand, it is sign-extended to the length of the destination operand format. 
  1156. The CF and OF flags are set when significant bits are carried into the upper half of the result. The CF and OF flags are cleared when the result fits exactly in the lower half of the result. 
  1157. The three forms of the IMUL instruction are similar in that the length of the product is calculated to twice the length of the operands. With the one-operand form, the product is stored exactly in the destination. With the two- and three- operand forms, however, the result is truncated to the length of the destination before it is stored in the destination register. Because of this truncation, the CF or OF flag should be tested to ensure that no significant bits are lost. 
  1158. The two- and three-operand forms may also be used with unsigned operands because the lower half of the product is the same regardless if the operands are signed or unsigned. The CF and OF flags, however, cannot be used to determine if the upper half of the result is non-zero. '
  1159.  Flags affected
  1160. For the one operand form of the instruction, the CF and OF flags are set when significant bits are carried into the upper half of the result and cleared when the result fits exactly in the lower half of the result. For the two- and three-operand forms of the instruction, the CF and OF flags are set when the result must be truncated to fit in the destination operand size and cleared when the result fits exactly in the destination operand size. The SF, ZF, AF, and PF flags are undefined. C
  1161.  Instruction size and timings
  1162.  One-operand form
  1163.  operand    bytes   8088     186    286     386     486     Pentium
  1164.  r8          2      80-98    25-28  13      9-14    13-18   11   NP
  1165.  r16         2     128-154   34-37  21      9-22    13-26   11   NP
  1166.  r32         2       -        -      -      9-38    13-42   10   NP
  1167.  mem8    2+d(0-2)  86-104+EA 32-34  16     12-17    13-18   11   NP
  1168.  mem16   2+d(0-2) 134-160+EA 40-43  24     12-25    13-26   11   NP
  1169.  mem32   2+d(0-2)    -        -      -     12-41    13-42   10   NP
  1170.  Two- and three-operand form
  1171.  operands       bytes     186   286    386         486      Pentium
  1172.  r16, imm      2+i(1,2)    -    21  9-14/9-22  13-18/13-26  10   NP
  1173.  r32, imm      2+i(1,2)    -     -     9-38       13-42     10   NP
  1174.  r16,r16,imm   2+i(1,2)  22/29  21  9-14/9-22  13-18/13-26  10   NP
  1175.  r32,r32,imm   2+i(1,2)    -     -     9-38       13-42     10   NP
  1176.  r16,m16,imm   2+d(0-2)  25/32  24 12-17/12-25 13-18/13-26  10   NP
  1177.                 +i(1,2)
  1178.  r32,m32,imm   2+d(0-2)+i(1,2)   -    12-41       13-42     10   NP
  1179.  r16, r16      2+i(1,2)    -     -     9-22    13-18/13-26  10   NP
  1180.  r32, r32      2+i(1,2)    -     -     9-38       13-42     10   NP
  1181.  r16, m16      2+d(0-2)+i(1,2)   -    12-25    13-18/13-26  10   NP
  1182.  r32, m32      2+d(0-2)+i(1,2)   -    12-41       13-42     10   NP
  1183.  Example
  1184.  imul ebx               ; EDX:EAX = EAX * EBX
  1185.  imul ecx, ebx          ; ECX = ECX * EBX
  1186.  imul ecx, ebx, 10      ; ECX = EBX * 10
  1187. contents
  1188. screen
  1189.  IN - Input from port
  1190.  Description
  1191. Copies the value from the I/O port specified with the second operand (source operand) to the destination operand (first operand). The source operand can be a byte-immediate or the DX register; the destination operand can be register AL, AX, or EAX, depending on the size of the port being accessed (8, 16, or 32 bits, respectively). Using the DX register as a source operand allows I/O port addresses from 0 to 65,535 to be accessed; using a byte immediate allows I/O port addresses 0 to 255 to be accessed. 
  1192. When accessing an 8-bit I/O port, the opcode determines the port size; when accessing a 16- and 32-bit I/O port, the operand-size attribute determines the port size. 
  1193. At the machine code level, I/O instructions are shorter when accessing 8-bit I/O ports. Here, the upper eight bits of the port address will be 0. '
  1194.  Flags affected
  1195. None. C
  1196.  Instruction size and timings
  1197.  operands    bytes   8088    186     286     386     486     Pentium
  1198.  al, imm8     2      14      10       5      12      14       7   NP
  1199.  ax, imm8     2      14      10       5      12      14       7   NP
  1200.  eax, imm8    2       -       -       -      12      14       7   NP
  1201.  al, dx       1      12       8       5      13      14       7   NP
  1202.  ax, dx       1      12       8       5      13      14       7   NP
  1203.  eax, dx      1       -       -       -      13      14       7   NP
  1204.                              Protected mode
  1205.  operands     bytes                           386     486     Pentium
  1206.  acc, imm      2                           6/26/26  9/29/27  4/21/19 NP
  1207.  acc, dx       1                           7/27/27  8/28/27  4/21/19 NP
  1208.  Cycles for: CPL <= IOPL / CPL > IOPL / V86
  1209.  Example
  1210.  in  al, dx     ; AL = the value read from I/O port number DX
  1211. contents
  1212. screen
  1213.  INC - Increment
  1214.  Description
  1215. Adds 1 to the destination operand, while preserving the state of the CF flag. # The destination operand can be a register or a memory location. This instruction allows a loop counter to be updated without disturbing the CF flag. (Use a ADD instruction with an immediate operand of 1 to perform an increment operation that does updates the CF flag.) '
  1216.  Flags affected
  1217. The CF flag is not affected. The OF, SF, ZF, AF, and PF flags are set according to the result. C
  1218.  Instruction size and timings
  1219.  operand     bytes   8088    186     286     386     486     Pentium
  1220.  r8           2       3       3       2       2       1       1   UV
  1221.  r16          1       3       3       2       2       1       1   UV
  1222.  r32          1       3       3       2       2       1       1   UV
  1223.  mem       2+d(0,2)  23+EA   15       7       6       3       3   UV
  1224.  Example
  1225.  inc ebx        ; EBX = EBX + 1
  1226. contents
  1227. screen
  1228.  INS - Input from port to string (186+)
  1229.  Description
  1230. Copies the data from the I/O port specified with the source operand (second operand) to the destination operand (first operand). The source operand is an I/O port address (from 0 to 65,535) that is read from the DX register. The destination operand is a memory location, the address of which is read from either the ES:EDI or the ES:DI registers (depending on the address-size attribute of the instruction, 32 or 16, respectively). (The ES segment cannot be overridden with a segment override prefix.) 
  1231. The size of the I/O port being accessed (that is, the size of the source and destination operands) is determined by the opcode for an 8-bit I/O port or by the operand-size attribute of the instruction for a 16- or 32-bit I/O port. ?
  1232. At the assembly-code level, two forms of this instruction are allowed: the "explicit-operands" form and the "no-operands" form. The explicit-operands form (specified with the INS mnemonic) allows the source and destination operands to be specified explicitly. This version of the instruction is NOT supported by NASM. ]
  1233. The no-operands form provides "short forms" of the byte, word, and doubleword versions of the INS instructions. Here also DX is assumed by the processor to be the source operand and ES:(E)DI is assumed to be the destination operand. The size of the I/O port is specified with the choice of mnemonic: INSB (byte), INSW (word), or INSD (doubleword). 
  1234. After the byte, word, or doubleword is transferred from the I/O port to the memory location, the (E)DI register is incremented or decremented automatically according to the setting of the DF flag in the EFLAGS register. (If the DF flag is 0, the (E)DI register is incremented; if the DF flag is 1, the (E)DI register is decremented.) The (E)DI register is incremented or decremented by 1 for byte operations, by 2 for word operations, or by 4 for doubleword operations. 
  1235. The INSB, INSW, and INSD instructions can be preceded by the REP prefix for block input of ECX bytes, words, or doublewords. See REP/REPE/REPZ/REPNE/REPNZ for a description of the REP prefix. '
  1236.  Flags affected
  1237. None. C
  1238.  Instruction size and timings
  1239.  variations  bytes   8088    186     286     386     486     Pentium
  1240.  insb         1       -      14       5      15      17      9    NP
  1241.  insw         1       -      14       5      15      17      9    NP
  1242.  insd         1       -       -       -      15      17      9    NP
  1243.  Protected Mode
  1244.              bytes                           386     486     Pentium
  1245.               1                           9/29/29 10/32/30 6/24/22 NP
  1246.  Cycles for: CPL <= IOPL / CPL > IOPL / V86
  1247.  Example
  1248.  rep insb       ; Repeatedly input bytes from the port specified by DX
  1249. contents
  1250. screen
  1251.  INT - Call interrupt procedure
  1252.  Description
  1253. The INT n instruction generates a call to the interrupt or exception handler specified with the destination operand. The destination operand specifies an interrupt vector number from 0 to 255, encoded as an 8-bit unsigned intermediate value. Each interrupt vector number provides an index to a gate descriptor in the IDT. The first 32 interrupt vector numbers are reserved by Intel for system use. Some of these interrupts are used for internally generated exceptions. 
  1254. The INT n instruction is the general mnemonic for executing a software-generated call to an interrupt handler. The INTO instruction is a special mnemonic for calling overflow exception interrupt vector number 4. 
  1255. The INT 3 instruction generates a special one byte opcode (CC) that is intended for calling the debug exception handler. (This one byte form is valuable because it can be used to replace the first byte of any instruction with a breakpoint, including other one byte instructions, without overwriting other code). To further support its function as a debug breakpoint, the interrupt generated with the CC opcode also differs from the regular software interrupts as follows: 
  1256. Note that the "normal" 2-byte opcode for INT 3 (CD03) does not have these special features. Intel and Microsoft assemblers will not generate the CD03 opcode from any mnemonic, but this opcode can be created by direct numeric code definition or by self-modifying code. 
  1257. The action of the INT n instruction (including the INTO and INT 3 instructions) is similar to that of a far call made with the CALL instruction. The primary difference is that with the INT n instruction, the EFLAGS register is pushed onto the stack before the return address. (The return address is a far address consisting of the current values of the CS and EIP registers.) Returns from interrupt procedures are handled with the IRET instruction, which pops the EFLAGS information and return address from the stack. 
  1258. The interrupt vector number specifies an interrupt descriptor in the interrupt descriptor table (IDT); that is, it provides index into the IDT. The selected interrupt descriptor in turn contains a pointer to an interrupt or exception handler procedure. In protected mode, the IDT contains an array of 8-byte descriptors, each of which is an interrupt gate, trap gate, or task gate. In real-address mode, the IDT is an array of 4-byte far pointers (2-byte code segment selector and a 2-byte instruction pointer), each of which point directly to a procedure in the selected segment. (Note that in real-address mode, the IDT is called the interrupt vector table, and it's pointers are called interrupt vectors.) '
  1259.  Flags affected
  1260. The EFLAGS register is pushed onto the stack. The IF, TF, NT, AC, RF, and VM flags may be cleared, depending on the mode of operation of the processor when the INT instruction is executed. If the interrupt uses a task gate, any flags may be set or cleared, controlled by the EFLAGS image in the new task's TSS. C
  1261.  Instruction size and timings
  1262.  operands  bytes   8088    186     286     386     486     Pentium
  1263.    3        1      72      45      23+m    33      26      13   NP
  1264.    imm8     2      71      47      23+m    37      30      16   NP
  1265.                              Protected mode
  1266.    bytes   8088    186     286     386     486     Pentium
  1267.     1      -       -     (40-78)+m 59-99   44-71  27-82 NP
  1268.  Example
  1269.  int 21h        ; Call DOS services interrupt vector
  1270. contents
  1271. screen
  1272.  INTO - Call interrupt procedure if overflow
  1273.  Description
  1274.  Flags affected
  1275. If the Overflow Flag is set this instruction generates an INT 4 which causes the code addressed by 0000:0010 to be executed. C
  1276.  Instruction size and timings
  1277.  bytes   8088    186     286     386     486     Pentium
  1278.   1      4/73    4/48    3/24+m  3/35    3/28    4/13 NP
  1279.                              Protected mode
  1280.  bytes                   286     386     486     Pentium
  1281.   1                    (40-78)+m 59-99   44-71  27-56 NP
  1282.  Example
  1283.  into           ; Call interrupt 4 if overflow flag is set
  1284. contents
  1285. screen
  1286.  INVD - Invalidate data cache (486+)
  1287.  Description
  1288. Invalidates (flushes) the processor's internal caches and issues a special-function bus cycle that directs external caches to also flush themselves. Data held in internal caches is not written back to main memory. 
  1289. After executing this instruction, the processor does not wait for the external caches to complete their flushing operation before proceeding with instruction execution. It is the responsibility of hardware to respond to the cache flush signal. 
  1290. The INVD instruction is a privileged instruction. When the processor is running in protected mode, the CPL of a program or procedure must be 0 to execute this instruction. g
  1291. Use this instruction with care. Data cached internally and not written back to main memory will be lost. Unless there is a specific requirement or benefit to flushing caches without writing back modified cache lines (for example, testing or fault recovery where cache coherency with main memory is not a concern), software should use the WBINVD instruction. '
  1292.  Flags affected
  1293. None. C
  1294.  Instruction size and timings
  1295.  bytes   8088    186     286     386     486     Pentium
  1296.   2       -       -       -       -       4      15   NP
  1297.  Example
  1298.  invd      ; Invalidate data cache
  1299. contents
  1300. screen
  1301.  INVLPG - Invalidate TLB entry (486+)
  1302.  Description
  1303. Invalidates (flushes) the translation lookaside buffer (TLB) entry specified with the source operand. The source operand is a memory address. The processor determines the page that contains that address and flushes the TLB entry for that page. 
  1304. The INVLPG instruction is a privileged instruction. When the processor is running in protected mode, the CPL of a program or procedure must be 0 to execute this instruction. 
  1305. The INVLPG instruction normally flushes the TLB entry only for the specified page; however, in some cases, it flushes the entire TLB. '
  1306.  Flags affected
  1307. None. C
  1308.  Instruction size and timings
  1309.   operands  bytes                                   486     Pentium
  1310.   mem32      5                                       12      25   NP
  1311.  Example
  1312.  invlpg [eax]   ; Invalidate TLB entry specified by eax
  1313. contents
  1314. screen
  1315.  IRET/IRETD - Interrupt return
  1316.  Description
  1317. Returns control to point of interruption by popping IP, CS and then the EFLAGS from the stack and continues execution at this location.  CPU exception interrupts will return to the instruction that cause the exception because the CS:IP placed on the stack during the interrupt is the address of the offending instruction. '
  1318.  Flags affected
  1319. All the flags and fields in the EFLAGS register are potentially modified, depending on the mode of operation of the processor. If performing a return from a nested task to a previous task, the EFLAGS register will be modified according to the EFLAGS image stored in the previous task's TSS. C
  1320.  Instruction size and timings
  1321.  IRET
  1322.  bytes   8088    186     286     386     486     Pentium
  1323.   1       44      28      17+m    22      15     8-27  NP
  1324.  IRETD (386+)
  1325.  bytes                           386     486     Pentium
  1326.   1                               22      15     10-27  NP
  1327.  Example
  1328.  iret           ; Return from interrupt
  1329. contents
  1330. screen
  1331.  Jcc - Jump on condition
  1332.  Description
  1333. Checks the state of one or more of the status flags in the EFLAGS register (CF, OF, PF, SF, and ZF) and, if the flags are in the specified state (condition), performs a jump to the target instruction specified by the destination operand. A condition code (cc) is associated with each instruction to indicate the condition being tested for. If the condition is not satisfied, the jump is not performed and execution continues with the instruction following the Jcc instruction. ^
  1334. The target instruction is specified with a relative offset (a signed offset relative to the current value of the instruction pointer in the EIP register). A relative offset (rel8, rel16, or rel32) is generally specified as a label in assembly code, but at the machine code level, it is encoded as a signed, 8-bit or 32-bit immediate value, which is added to the instruction pointer. Instruction coding is most efficient for offsets of -128 to +127. If the operand-size attribute is 16, the upper two bytes of the EIP register are cleared to 0s, resulting in a maximum instruction pointer size of 16 bits. 
  1335. The conditions for each Jcc mnemonic are given in the "Description" column of the table below. The terms "less" and "greater" are used for comparisons of signed integers and the terms "above" and "below" are used for unsigned integers. 
  1336. Because a particular state of the status flags can sometimes be interpreted in two ways, two mnemonics are defined for some opcodes. For example, the JA (jump if above) instruction and the JNBE (jump if not below or equal) instruction are alternate mnemonics for the opcode. 
  1337. The Jcc instruction does not support far jumps (jumps to other code segments). When the target for the conditional jump is in a different segment, use the opposite condition from the condition being tested for the Jcc instruction, and then access the target with an unconditional far jump (JMP instruction) to the other segment. For example, the following conditional far jump is illegal: !
  1338.         jz FARLABEL  ; Far jump
  1339. To accomplish this far jump, use the following two instructions: `
  1340.         jnz BEYOND   ; If not zero skip far jump
  1341.         jmp FARLABEL ; Unconditional far jump
  1342.         BEYOND:      ; Label
  1343. The JECXZ and JCXZ instructions differs from the other Jcc instructions because they do not check the status flags. Instead they check the contents of the ECX and CX registers, respectively, for 0. Either the CX or ECX register is chosen according to the address-size attribute. These instructions are useful at the beginning of a conditional loop that terminates with a conditional loop instruction (such as LOOPNE). They prevent entering the loop when the ECX or CX register is equal to 0, which would cause the loop to execute 2^32 or 64K times, respectively, instead of zero times. |
  1344. All conditional jumps are converted to code fetches of one or two cache lines, regardless of jump address or cacheability. 
  1345.  Jump Instructions Table
  1346.  Mnemonic    Meaning                    Jump Condition
  1347.  JA          Jump if Above                         CF=0 and ZF=0
  1348.  JAE         Jump if Above or Equal                CF=0
  1349.  JB          Jump if Below                         CF=1
  1350.  JBE         Jump if Below or Equal                CF=1 or ZF=1
  1351.  JC          Jump if Carry                         CF=1
  1352.  JCXZ        Jump if CX Zero                       CX=0
  1353.  JE          Jump if Equal                         ZF=1
  1354.  JG          Jump if Greater (signed)              ZF=0 and SF=OF
  1355.  JGE         Jump if Greater or Equal (signed)     SF=OF
  1356.  JL          Jump if Less (signed)                 SF != OF
  1357.  JLE         Jump if Less or Equal (signed)        ZF=1 or SF != OF
  1358.  JMP         Unconditional Jump                    unconditional
  1359.  JNA         Jump if Not Above                     CF=1 or ZF=1
  1360.  JNAE        Jump if Not Above or Equal            CF=1
  1361.  JNB         Jump if Not Below                     CF=0
  1362.  JNBE        Jump if Not Below or Equal            CF=0 and ZF=0
  1363.  JNC         Jump if Not Carry                     CF=0
  1364.  JNE         Jump if Not Equal                     ZF=0
  1365.  JNG         Jump if Not Greater (signed)          ZF=1 or SF != OF
  1366.  JNGE        Jump if Not Greater or Equal (signed) SF != OF
  1367.  JNL         Jump if Not Less (signed)             SF=OF
  1368.  JNLE        Jump if Not Less or Equal (signed)    ZF=0 and SF=OF
  1369.  JNO         Jump if Not Overflow (signed)         OF=0
  1370.  JNP         Jump if No Parity                     PF=0
  1371.  JNS         Jump if Not Signed (signed)           SF=0
  1372.  JNZ         Jump if Not Zero                      ZF=0
  1373.  JO          Jump if Overflow (signed)             OF=1
  1374.  JP          Jump if Parity                        PF=1
  1375.  JPE         Jump if Parity Even                   PF=1
  1376.  JPO         Jump if Parity Odd                    PF=0
  1377.  JS          Jump if Signed (signed)               SF=1
  1378.  JZ          Jump if Zero                          ZF=1
  1379.  Flags affected
  1380. None. C
  1381.  Instruction size and timings
  1382.  operand     bytes   8088    186     286     386     486     Pentium
  1383.  near8        2      4/16    4/13    3/7+m   3/7+m   1/3     1    PV
  1384.  near16       3       -       -       -      3/7+m   1/3     1    PV
  1385.  Note: Cycles shown for no jump/jump
  1386.  JCXZ / JECXZ
  1387.  operand    bytes   8088    186     286     386     486     Pentium
  1388.  dest        2      6/18    5/16    4/8+m   5/9+m   5/8     5/6  NP
  1389.  dest        2       -       -       -      5/9+m   5/8     5/6  NP
  1390.  Example
  1391.  jne not_equal  ; Jump to label 'not_equal' if not equal condition is met
  1392.  jcxz cx_zero   ; Jump to label 'cx_zero' if the CX register is zero
  1393. contents
  1394. screen
  1395.  JMP - Unconditional jump
  1396.  Description
  1397. Transfers program control to a different point in the instruction stream without recording return information. The destination (target) operand specifies the address of the instruction being jumped to. This operand can be an immediate value, a general-purpose register, or a memory location. H
  1398. This instruction can be used to execute four different types of jumps: 
  1399.  Near jump
  1400. A jump to an instruction within the current code segment (the segment currently pointed to by the CS register), sometimes referred to as an intrasegment jump. 
  1401.  Short jump
  1402. A near jump where the jump range is limited to -128 to +127 from the current EIP value. 
  1403.  Far jump
  1404. A jump to an instruction located in a different segment than the current code segment but at the same privilege level, sometimes referred to as an intersegment jump. 
  1405.  Task switch
  1406. A jump to an instruction located in a different task. A task switch can only be executed in protected mode. 
  1407.  Near and Short Jumps
  1408. When executing a near jump, the processor jumps to the address (within the current code segment) that is specified with the target operand. The target operand specifies either an absolute offset (that is an offset from the base of the code segment) or a relative offset (a signed displacement relative to the current value of the instruction pointer in the EIP register). A near jump to a relative offset of 8-bits (rel8) is referred to as a short jump. The CS register is not changed on near and short jumps. 
  1409. An absolute offset is specified indirectly in a general-purpose register or a memory location (r/m16 or r/m32). The operand-size attribute determines the size of the target operand (16 or 32 bits). Absolute offsets are loaded directly into the EIP register. If the operand-size attribute is 16, the upper two bytes of the EIP register are cleared to 0s, resulting in a maximum instruction pointer size of 16 bits. 
  1410. A relative offset (rel8, rel 16, or rel32) is generally specified as a label in assembly code. This value is added to the value in the EIP register. (Here, the EIP register contains the address of the instruction following the JMP instruction). When using relative offsets, the opcode (for short vs. near jumps) and the operand-size attribute (for near relative jumps) determines the size of the target operand (8, 16, or 32 bits). 3
  1411.  Far Jumps in Real-Address or Virtual-8086 Mode
  1412. When executing a far jump in real-address or virtual-8086 mode, the processor jumps to the code segment and offset specified with the target operand. Here the target operand specifies an absolute far address either directly with a pointer (ptr16:16 or ptr16:32) or indirectly with a memory location (m16:16 or m16:32). With the pointer method, the segment and address of the called procedure is encoded in the instruc-tion, using a 4-byte (16-bit operand size) or 6-byte (32-bit operand size) far address immediate. With the indirect method, the target operand specifies a memory location that contains a 4-byte (16-bit operand size) or 6-byte (32-bit operand size) far address. The far address is loaded directly into the CS and EIP registers. If the operand-size attribute is 16, the upper two bytes of the EIP register are cleared to 0s.  
  1413.  Far Jumps in Protected Mode
  1414. When the processor is operating in protected mode, the JMP instruction can be used to perform the following three types of far jumps: w
  1415.   - A far jump to a conforming or non-conforming code segment.
  1416.   - A far jump through a call gate.
  1417.   - A task switch.
  1418. (The JMP instruction cannot be used to perform interprivilege level far jumps.) 
  1419. In protected mode, the processor always uses the segment selector part of the far address to access the corresponding descriptor in the GDT or LDT. The descriptor type (code segment, call gate, task gate, or TSS) and access rights determine the type of jump to be performed. H
  1420. If the selected descriptor is for a code segment, a far jump to a code segment at the same privilege level is performed. (If the selected code segment is at a different privilege level and the code segment is non-conforming, a general-protection exception is generated.) A far jump to the same privilege level in protected mode is very similar to one carried out in real-address or virtual-8086 mode. The target operand specifies an absolute far address either directly with a pointer (ptr16:16 or ptr16:32) or indirectly with a memory location (m16:16 or m16:32). The operand-size attribute determines the size of the offset (16 or 32 bits) in the far address. The new code segment selector and its descriptor are loaded into CS register, and the offset from the instruction is loaded into the EIP register. Note that a call gate (described in the next paragraph) can also be used to perform far call to a code segment at the same privilege level. Using this mechanism provides an extra level of indirection and is the preferred method of making jumps between 16- bit and 32-bit code segments. '
  1421.  Flags affected
  1422. All flags are affected if a task switch occurs; no flags are affected if a task switch does not occur. C
  1423.  Instruction size and timings
  1424.  operand     bytes   8088    186     286     386     486     Pentium
  1425.  short        2      15      13      7+m     7+m      3       1   PV
  1426.  near         3      15      13      7+m     7+m      3       1   PV
  1427.  far          5      15      13     11+m    12+m     17       3   NP
  1428.  r16          2      11      11      7+m     7+m      5       2   NP
  1429.  mem16      2+d(0,2) 18+EA   17     11+m    10+m      5       2   NP
  1430.  mem32      2+d(4)   24+EA   26     15+m    12+m     13       4   NP
  1431.  r32          2       -       -       -      7+m      5       2   NP
  1432.  mem32      2+d(0,2)  -       -       -     10+m      5       2   NP
  1433.  mem48      2+d(6)    -       -       -     12+m     13       4   NP
  1434.  Example
  1435.  jmp target_address     ; Unconditional jump to target_address
  1436. contents
  1437. screen
  1438.  LAHF - Load status flags into AH register
  1439.  Description
  1440. Moves the low byte of the EFLAGS register (which includes status flags SF, ZF, AF, PF, and CF) to the AH register. Reserved bits 1, 3, and 5 of the EFLAGS register are set in the AH register. '
  1441.  Flags affected
  1442. None (that is, the state of the flags in the EFLAGS register are not affected). C
  1443.  Instruction size and timings
  1444.  bytes   8088    186     286     386     486     Pentium
  1445.   1       4       2       2       2       3       2   NP
  1446.  Example
  1447.  lahf      ; Load flags into AH
  1448. contents
  1449. screen
  1450.  LAR - Load access rights byte (286+)
  1451.  Description
  1452. Loads the access rights from the segment descriptor specified by the second operand (source operand) into the first operand (destination operand) and sets the ZF flag in the EFLAGS register. The source operand (which can be a register or a memory location) contains the segment selector for the segment descriptor being accessed. The destination operand is a general-purpose register. 
  1453. The processor performs access checks as part of the loading process. Once loaded in the destination register, software can perform additional checks on the access rights information. M
  1454. When the operand size is 32 bits, the access rights for a segment descriptor include the type and DPL fields and the S, P, AVL, D/B, and G flags, all of which are located in the second double-word (bytes 4 through 7) of the segment descriptor. The doubleword is masked by 00FXFF00H before it is loaded into the destination operand. 
  1455. When the operand size is 16 bits, the access rights include the type and DPL fields. Here, the two lower-order bytes of the doubleword are masked by FF00H before being loaded into the destination operand. o
  1456. This instruction performs the following checks before it loads the access rights in the destination register: 2
  1457.  Checks that the segment selector is not null.
  1458.  Checks that the segment selector points to a descriptor that is within the
  1459.    limits of the GDT or LDT being accessed
  1460.  Checks that the descriptor type is valid for this instruction. All code and
  1461.    data segment descriptors are valid for (can be accessed with) the LAR
  1462.    instruction. The valid system segment and gate descriptor types are given
  1463.    in the following table.
  1464.  If the segment is not a conforming code segment, it checks that the specified
  1465.    segment descriptor is visible at the CPL (that is, if the CPL and the RPL of
  1466.    the segment selector are less than or equal to the DPL of the segment
  1467.    selector).
  1468. If the segment descriptor cannot be accessed or is an invalid type for the instruction, the ZF flag is cleared and no access rights are loaded in the destination operand. The LAR instruction can only be executed in protected mode. +
  1469.  Type               Name                    Valid
  1470.  0                  Reserved                No
  1471.  1                  Available 16-bit TSS    Yes
  1472.  2                  LDT                     Yes
  1473.  3                  Busy 16-bit TSS         Yes
  1474.  4                  16-bit call gate        Yes
  1475.  5                  16-bit/32-bit task gate Yes
  1476.  6                  16-bit interrupt gate   No
  1477.  7                  16-bit trap gate        No
  1478.  8                  Reserved                No
  1479.  9                  Available 32-bit TSS    Yes
  1480.  A                  Reserved                No
  1481.  B                  Busy 32-bit TSS         Yes
  1482.  C                  32-bit call gate        Yes
  1483.  D                  Reserved                No
  1484.  E                  32-bit interrupt gate   No
  1485.  F                  32-bit trap gate        No
  1486.  Flags affected
  1487. The ZF flag is set to 1 if the access rights are loaded successfully; otherwise, it is cleared to 0. C
  1488.  Instruction size and timings
  1489.  operands    bytes                   286     386     486     Pentium
  1490.  r16, r16     3                      14      15      11       8   NP
  1491.  r32, r32     3                       -      15      11       8   NP
  1492.  r16, m16     3                      16      16      11       8   NP
  1493.  r32, m32     3                       -      16      11       8   NP
  1494.  Example
  1495.  lar ebx, eax           ; EBX = access rights descriptor specified by EAX
  1496. contents
  1497. screen
  1498.  LDS/LES/LFS/LGS/LSS - Load far pointer
  1499.  Description
  1500. Loads a far pointer (segment selector and offset) from the second operand (source operand) into a segment register and the first operand (destination operand). The source operand specifies a 48-bit or a 32-bit pointer in memory depending on the current setting of the operand-size attribute (32 bits or 16 bits, respectively). The instruction opcode and the destination operand specify a segment register/general-purpose register pair. The 16-bit segment selector from the source operand is loaded into the segment register specified with the opcode (DS, SS, ES, FS, or GS). The 32-bit or 16-bit offset is loaded into the register specified with the destination operand. 
  1501. If one of these instructions is executed in protected mode, additional information from the segment descriptor pointed to by the segment selector in the source operand is loaded in the hidden part of the selected segment register. ]
  1502. Also in protected mode, a null selector (values 0000 through 0003) can be loaded into DS, ES, FS, or GS registers without causing a protection exception. (Any subsequent reference to a segment whose corresponding segment register is loaded with a null selector, causes a general-protection exception and no memory reference to the segment occurs.) '
  1503.  Flags affected
  1504. None. C
  1505.  Instruction size and timings
  1506.  LDS/LES
  1507.  operands    bytes   8088    186     286     386     486     Pentium
  1508.  reg, mem   2+d(2)   24+EA   18       7       7       6       4   NP
  1509.  LFS/LGS/LSS (386+)
  1510.  operands    bytes                           386     486     Pentium
  1511.  reg, mem   3+d(2,4)                          7       6       4   NP
  1512.  Example
  1513.  lds si, ptr_1          ; DS:DI points to ptr_1
  1514. contents
  1515. screen
  1516.  LEA - Load effective address
  1517.  Description
  1518. Computes the effective address of the second operand (the source operand) and stores it in the first operand (destination operand). The source operand is a memory address (offset part) specified with one of the processors addressing modes; the destination operand is a general-purpose register. The address-size and operand-size attributes affect the action performed by this instruction, as shown in the following table. The operand-size attribute of the instruction is determined by the chosen register; the address-size attribute is determined by the attribute of the code segment. :
  1519.  Operand   Address      Action Performed
  1520.  Size      Size
  1521.  16        16           16-bit effective address is calculated and stored in
  1522.                         requested 16-bit register destination.
  1523.  16        32           32-bit effective address is calculated. The lower 16
  1524.                         bits of the address are stored in the requested 16-bit
  1525.                         register destination.
  1526.  32        16           16-bit effective address is calculated. The 16-bit
  1527.                         address is zero-extended and stored in the requested
  1528.                         32-bit register destination.
  1529.  32        32           32-bit effective address is calculated and stored in
  1530.                         the requested 32-bit register destination.
  1531.  Flags affected
  1532. None. C
  1533.  Instruction size and timings
  1534.  operands    bytes   8088    186     286     386     486     Pentium
  1535.  r16, mem    2+d(2)  2+EA     6       3       2      1-2      1   UV
  1536.  r32, mem    2+d(2)   -       -       -       2      1-2      1   UV
  1537.  Example
  1538.  lea  eax, [eax+ebx*2+3]       ; EAX = effective address of [eax+ebx*2+3]
  1539. contents
  1540. screen
  1541.  LEAVE - High level procedure exit (186+)
  1542.  Description
  1543. Releases the stack frame set up by an earlier ENTER instruction. The LEAVE instruction copies the frame pointer (in the EBP register) into the stack pointer register (ESP), which releases the stack space allocated to the stack frame. The old frame pointer (the frame pointer for the calling procedure that was saved by the ENTER instruction) is then popped from the stack into the EBP register, restoring the calling procedure's stack frame. z
  1544. A RET instruction is commonly executed following a LEAVE instruction to return program control to the calling procedure. '
  1545.  Flags affected
  1546. None. C
  1547.  Instruction size and timings
  1548.   bytes           186     286     386     486     Pentium
  1549.    1               8       5       4       5       3   NP
  1550.  Example
  1551.  leave     ; Exit current procedure
  1552. contents
  1553. screen
  1554.  LGDT/LIDT - Load Global/Interrupt Descriptor Table Register (286+)
  1555.  Description
  1556. Loads the values in the source operand into the global descriptor table register (GDTR) or the interrupt descriptor table register (IDTR). The source operand specifies a 6-byte memory location that contains the base address (a linear address) and the limit (size of table in bytes) of the global descriptor table (GDT) or the interrupt descriptor table (IDT). If operand-size attribute is 32 bits, a 16-bit limit (lower 2 bytes of the 6-byte data operand) and a 32-bit base address (upper 4 bytes of the data operand) are loaded into the register. If the operand-size attribute is 16 bits, a 16-bit limit (lower 2 bytes) and a 24-bit base address (third, fourth, and fifth byte) are loaded. Here, the high-order byte of the operand is not used and the high-order byte of the base address in the GDTR or IDTR is filled with zeros. {
  1557. The LGDT and LIDT instructions are used only in operating-system software; they are not used in application programs. They are the only instructions that directly load a linear address (that is, not a segment-relative address) and a limit in protected mode. They are commonly executed in real-address mode to allow processor initialization prior to switching to protected mode. '
  1558.  Flags affected
  1559. None. C
  1560.  Instruction size and timings
  1561.  operand     bytes                   286     386     486     Pentium
  1562.   mem48       5                      11      11      11       6   NP
  1563.  Example
  1564.  lgdt descriptor[ebx]   ; Load Global Descriptor Table
  1565. contents
  1566. screen
  1567.  LLDT - Load Local Descriptor Table register (286+)
  1568.  Description
  1569. Loads the source operand into the segment selector field of the local descriptor table register (LDTR). The source operand (a general-purpose register or a memory location) contains a segment selector that points to a local descriptor table (LDT). After the segment selector is loaded in the LDTR, the processor uses to segment selector to locate the segment descriptor for the LDT in the global descriptor table (GDT). It then loads the segment limit and base address for the LDT from the segment descriptor into the LDTR. 
  1570. The segment registers DS, ES, SS, FS, GS, and CS are not affected by this instruction, nor is the LDTR field in the task state segment (TSS) for the current task. 
  1571. If the source operand is 0, the LDTR is marked invalid and all references to descriptors in the LDT (except by the LAR, VERR, VERW or LSL instructions) cause a general protection exception. ?
  1572. The operand-size attribute has no effect on this instruction. 
  1573. The LLDT instruction is provided for use in operating-system software; it should not be used in application programs. Also, this instruction can only be executed in protected mode. '
  1574.  Flags affected
  1575. None. C
  1576.  Instruction size and timings
  1577.  operand     bytes                   286     386     486     Pentium
  1578.   r16         3                      17      20      11       9   NP
  1579.   mem16     3+d(0-2)                 19      24      11       9   NP
  1580.  Example
  1581.  lldt ax        ; Load LDT with AX
  1582. contents
  1583. screen
  1584.  LMSW - Load Machine Status Word (286+)
  1585.  Description
  1586. Loads the source operand into the machine status word, bits 0 through 15 of register CR0. The source operand can be a 16-bit general-purpose register or a memory location. Only the low-order 4 bits of the source operand (which contains the PE, MP, EM, and TS flags) are loaded into CR0. The PG, CD, NW, AM, WP, NE, and ET flags of CR0 are not affected. The operand-size attribute has no effect on this instruction. 
  1587. If the PE flag of the source operand (bit 0) is set to 1, the instruction causes the processor to switch to protected mode. While in protected mode, the LMSW instruction cannot be used clear the PE flag and force a switch back to real-address mode. 
  1588. The LMSW instruction is provided for use in operating-system software; it should not be used in application programs. In protected or virtual-8086 mode, it can only be executed at CPL 0. 
  1589. This instruction is provided for compatibility with the Intel 286 processor; programs and procedures intended to run on the Pentium Pro, Pentium, 486, and 386 processors should use the MOV (control registers) instruction to load the whole CR0 register. The MOV CR0 instruction can be used to set and clear the PE flag in CR0, allowing a procedure or program to switch between protected and real-address modes. 0
  1590. This instruction is a serializing instruction. '
  1591.  Flags affected
  1592. None. C
  1593.  Instruction size and timings
  1594.  operand     bytes                   286     386     486     Pentium
  1595.   r16         3                       3      10      13       8   NP
  1596.   mem16     3+d(0-2)                  6      13      13       8   NP
  1597.  Example
  1598.  lmsw ax     ; load machine status word with ax
  1599. contents
  1600. screen
  1601.  LOCK - Lock bus
  1602.  Description
  1603. Causes the processor's LOCK# signal to be asserted during execution of the accompanying instruction (turns the instruction into an atomic instruction). In a multiprocessor environment, the LOCK# signal insures that the processor has exclusive use of any shared memory while the signal is asserted. 
  1604. Note that in later Intel Architecture processors (such as the Pentium Pro processor), locking may occur without the LOCK# signal being asserted. 
  1605. The LOCK prefix can be prepended only to the following instructions and to those forms of the instructions that use a memory operand: ADD, ADC, AND, BTC, BTR, BTS, CMPXCHG, DEC, INC, NEG, NOT, OR, SBB, SUB, XOR, XADD, and XCHG. An undefined opcode exception will be generated if the LOCK prefix is used with any other instruction. The XCHG instruction always asserts the LOCK# signal regardless of the presence or absence of the LOCK prefix. 
  1606. The LOCK prefix is typically used with the BTS instruction to perform a read-modify-write operation on a memory location in shared memory environment. 
  1607. The integrity of the LOCK prefix is not affected by the alignment of the memory field. Memory locking is observed for arbitrarily misaligned fields. "
  1608. Intel Architecture Compatibility 
  1609. Beginning with the Pentium Pro processor, when the LOCK prefix is prefixed to an instruction and the memory area being accessed is cached internally in the processor, the LOCK# signal is generally not asserted. Instead, only the processor's cache is locked. Here, the processor's cache coherency mechanism insures that the operation is carried out atomically with regards to memory. '
  1610.  Flags affected
  1611. None. C
  1612.  Instruction size and timings
  1613.  bytes   8088    186     286     386     486     Pentium
  1614.   1       2       2       0       0       1       1   NP
  1615.  Example
  1616.  lock  mov mem, 1       ; Lock the bus while performing a memory move
  1617. contents
  1618. screen
  1619.  LODS - Load string
  1620.  Description
  1621. Loads a byte, word, or doubleword from the source operand into the AL, AX, or EAX register, respectively. The source operand is a memory location, the address of which is read from the DS:EDI or the DS:SI registers (depending on the address-size attribute of the instruction, 32 or 16, respectively). The DS segment may be overridden with a segment override prefix. 
  1622. At the assembly-code level, two forms of this instruction are allowed: the "explicit-operands" form and the "no-operands" form. The explicit-operands form (specified with the LODS mnemonic) is not supported by NASM. 
  1623. The no-operands form provides "short forms" of the byte, word, and doubleword versions of the LODS instructions. Here also DS:(E)SI is assumed to be the source operand and the AL, AX, or EAX register is assumed to be the destination operand. The size of the source and destination operands is selected with the mnemonic: LODSB (byte loaded into register AL), LODSW (word loaded into AX), or LODSD (doubleword loaded into EAX). 
  1624. After the byte, word, or doubleword is transferred from the memory location into the AL, AX, or EAX register, the (E)SI register is incremented or decremented automatically according to the setting of the DF flag in the EFLAGS register. (If the DF flag is 0, the (E)SI register is incremented; if the DF flag is 1, the ESI register is decremented.) The (E)SI register is incremented or decremented by 1 for byte operations, by 2 for word operations, or by 4 for doubleword operations. 
  1625. The LODSB, LODSW, and LODSD instructions can be preceded by the REP prefix for block loads of ECX bytes, words, or doublewords. More often, however, these instructions are used within a LOOP construct because further processing of the data moved into the register is usually necessary before the next transfer can be made. See REP/REPE/REPZ/REPNE/REPNZ for more information on the repeat prefix. '
  1626.  Flags affected
  1627. None. C
  1628.  Instruction size and timings
  1629.  variations  bytes   8088    186     286     386     486     Pentium
  1630.  lodsb        1      16      10       5       5       5       2   NP
  1631.  lodsw        1      16      10       5       5       5       2   NP
  1632.  lodsd        1       -       -       -       5       5       2   NP
  1633.  Example
  1634.  lodsb     ; Move the byte from DS:SI into AL
  1635. contents
  1636. screen
  1637.  LOOP - Decrement CX and loop if CX not zero
  1638.  Description
  1639. Performs a loop operation using the ECX or CX register as a counter. Each time the LOOP instruction is executed, the count register is decremented, then checked for 0. If the count is 0, the loop is terminated and program execution continues with the instruction following the LOOP instruction. If the count is not zero, a near jump is performed to the destination (target) operand, which is presumably the instruction at the beginning of the loop. If the address-size attribute is 32 bits, the ECX register is used as the count register; otherwise the CX register is used. 
  1640. The target instruction is specified with a relative offset (a signed offset relative to the current value of the instruction pointer in the EIP register). This offset is generally specified as a label in assembly code, but at the machine code level, it is encoded as a signed, 8-bit immediate value, which is added to the instruction pointer. Offsets of -128 to +127 are allowed with this instruction. '
  1641.  Flags affected
  1642. None. C
  1643.  Instruction size and timings
  1644.  operand   bytes   8088    186     286     386     486     Pentium
  1645.  short      2      5/17    5/15    4/8+m   11+m    6/7     5/6  NP
  1646.  Note: timings shown for no jump (CX = 0) / jump (CX <> 0)
  1647.  Example
  1648.  loop loop_start        ; If CX <> 0 then loop to 'loop_start'
  1649. contents
  1650. screen
  1651.  LOOPE/LOOPZ - Loop while equal / loop while zero
  1652.  Description
  1653. Loops in the same way as the LOOP instruction except that the loop occurs only when (E)CX <> 0 and the zero flag (ZF) is set. '
  1654.  Flags affected
  1655. None. C
  1656.  Instruction size and timings
  1657.  operand   bytes   8088    186     286     386     486     Pentium
  1658.  short      2      6/18    5/16    4/8     11+m    6/9     7/8  NP
  1659.  Example
  1660.  loope loop_start             ; Loop if CX <> 0 and ZF = 1
  1661. contents
  1662. screen
  1663.  LOOPNE/LOOPNZ - Loop while not equal / loop while not zero
  1664.  Description
  1665. Loops in the same way as the LOOP instruction except that the loop occurs only when (E)CX <> 0 and the zero flag (ZF) is not set. '
  1666.  Flags affected
  1667. None. C
  1668.  Instruction size and timings
  1669.  operand bytes   8088    186     286     386     486     Pentium
  1670.  short    2      5/19    5/16    4/8     11+m    6/9     7/8  NP
  1671.  Example
  1672.  loopne loop_start      ; Loop if CX <> 0 and ZF = 0
  1673. contents
  1674. screen
  1675.  LSL - Load segment limit (286+)
  1676.  Description
  1677. Loads the unscrambled segment limit from the segment descriptor specified with the second operand (source operand) into the first operand (destination operand) and sets the ZF flag in the EFLAGS register. The source operand (which can be a register or a memory location) contains the segment selector for the segment descriptor being accessed. The destination operand is a general-purpose register. 
  1678. The processor performs access checks as part of the loading process. Once loaded in the destination register, software can compare the segment limit with the offset of a pointer.  
  1679. The segment limit is a 20-bit value contained in bytes 0 and 1 and in the first 4 bits of byte 6 of the segment descriptor. If the descriptor has a byte granular segment limit (the granularity flag is set to 0), the destination operand is loaded with a byte granular value (byte limit). [
  1680. If the descriptor has a page granular segment limit (the granularity flag is set to 1), the LSL instruction will translate the page granular limit (page limit) into a byte limit before loading it into the destination operand. The translation is performed by shifting the 20-bit "raw" limit left 12 bits and filling the low-order 12 bits with 1s. 
  1681. When the operand size is 32 bits, the 32-bit byte limit is stored in the destination operand. When the operand size is 16 bits, a valid 32-bit limit is computed; however, the upper 16 bits are truncated and only the low-order 16 bits are loaded into the destination operand. q
  1682. This instruction performs the following checks before it loads the segment limit into the destination register: X
  1683.  Checks that the segment selector is not null.
  1684.  Checks that the segment selector points to a descriptor that is within
  1685.    the limits of the GDT or LDT being accessed
  1686.  Checks that the descriptor type is valid for this instruction. All code
  1687.    and data segment descriptors are valid for (can be accessed with) the LSL
  1688.    instruction.
  1689.  If the segment is not a conforming code segment, the instruction checks
  1690.    that the specified segment descriptor is visible at the CPL (that is, if
  1691.    the CPL and the RPL of the segment selector are less than or equal to the
  1692.    DPL of the segment selector).
  1693. If the segment descriptor cannot be accessed or is an invalid type for the instruction, the ZF flag is cleared and no value is loaded in the destination operand. '
  1694.  Flags affected
  1695. The ZF flag is set to 1 if the segment limit is loaded successfully; otherwise, it is cleared to 0. C
  1696.  Instruction size and timings
  1697.  operands    bytes                   286     386     486     Pentium
  1698.  r16, r16     3                      14      20/25   10       8   NP
  1699.  r32, r32     3                       -      20/25   10       8
  1700.  r16, m16   3+d(0,2)                 16      21/26   10       8
  1701.  r32, m32   3+d(0,2)                  -      21/26   10       8
  1702.  Example
  1703.  lsl eax, ebx           ; Load segment limit of EBX and store in EAX
  1704. contents
  1705. screen
  1706.  LTR - Load task register (286+)
  1707.  Description
  1708. Loads the source operand into the segment selector field of the task register. The source operand (a general-purpose register or a memory location) contains a segment selector that points to a task state segment (TSS). After the segment selector is loaded in the task register, the processor uses the segment selector to locate the segment descriptor for the TSS in the global descriptor table (GDT). It then loads the segment limit and base address for the TSS from the segment descriptor into the task register. The task pointed to by the task register is marked busy, but a switch to the task does not occur. 
  1709. The LTR instruction is provided for use in operating-system software; it should not be used in application programs. It can only be executed in protected mode when the CPL is 0. It is commonly used in initialization code to establish the first task to be executed. ?
  1710. The operand-size attribute has no effect on this instruction. '
  1711.  Flags affected
  1712. None. C
  1713.  Instruction size and timings
  1714.  operand     bytes                   286     386     486     Pentium
  1715.  r16          3                      17      23      20      10   NP
  1716.  mem16      3+d(0,2)                 19      27      20      10
  1717.  Example
  1718.  ltr ax         ; Load task register from AX
  1719. contents
  1720. screen
  1721.  MOV - Move data
  1722.  Description
  1723. Copies the second operand (source operand) to the first operand (destination operand). The source operand can be an immediate value, general-purpose register, segment register, or memory location; the destination register can be a general-purpose register, segment register, or memory location. Both operands must be the same size, which can be a byte, a word, or a doubleword. 
  1724. The MOV instruction cannot be used to load the CS register. Attempting to do so results in an invalid opcode exception. To load the CS register, use the far JMP, CALL, or RET instruction. 3
  1725. If the destination operand is a segment register (DS, ES, FS, GS, or SS), the source operand must be a valid segment selector. In protected mode, moving a segment selector into a segment register automatically causes the segment descriptor information associated with that segment selector to be loaded into the hidden (shadow) part of the segment register. While loading this information, the segment selector and segment descriptor information is validated. The segment descriptor data is obtained from the GDT or LDT entry for the specified segment selector. F
  1726. A null segment selector (values 0000-0003) can be loaded into the DS, ES, FS, and GS registers without causing a protection exception. However, any subsequent attempt to reference a segment whose corresponding segment register is loaded with a null value causes a general protection exception and no memory reference occurs. q
  1727. Loading the SS register with a MOV instruction inhibits all interrupts until after the execution of the next instruction. This operation allows a stack pointer to be loaded into the ESP register with the next instruction (MOV ESP, stack-pointer value) before an interrupt occurs. The LSS instruction offers a more efficient method of loading the SS and ESP registers. 
  1728. When operating in 32-bit mode and moving data between a segment register and a general-purpose register, the Intel Architecture 32-bit processors do not require the use of the 16-bit operand-size prefix (a byte with the value 66H) with this instruction, but most assemblers will insert it if the standard form of the instruction is used (for example, MOV DS, AX). The processor will execute this instruction correctly, but it will usually require an extra clock. With most assemblers, using the instruction form MOV DS, EAX will avoid this unneeded 66H prefix. When the processor executes the instruction with a 32-bit general-purpose register, it assumes that the 16 least-significant bits of the general-purpose register are the destination or source operand. If the register is a destination operand, the resulting value in the two high-order bytes of the register is implementation dependent. 
  1729. For the PentiumPro processor, the two high-order bytes are filled with zeros; for earlier 32-bit Intel Architecture processors, the two high order bytes are undefined. '
  1730.  Flags affected
  1731. None. C
  1732.  Instruction size and timings
  1733.  operands    bytes   8088    186     286     386     486     Pentium
  1734.  reg, reg     2       2       2       2       2       1       1   UV
  1735.  mem, reg  2+d(0-2)  13+EA    9       3       2       1       1   UV
  1736.  reg, mem  2+d(0-2)  12+EA   12       5       4       1       1   UV
  1737.  mem, imm  2+d(0-2)  14+EA   12-13    3       2       1       1   UV*
  1738.             +i(1,2)
  1739.  reg, imm  2+i(1,2)   4       3-4     2       2       1       1   UV
  1740.  acc, mem     3      14       8       5       4       1       1   UV
  1741.  mem, acc     3      14       9       3       2       1       1   UV
  1742.  * = not pairable if there is a displacement and immediate
  1743.  Segment Register Moves  - Real Mode
  1744.  operands    bytes   8088    186     286     386     486     Pentium
  1745.  seg, r16     2       2       2       2       2       3     2-11   NP
  1746.  seg, m16   2+d(0,2) 12+EA    9       5       5       3     3-12   NP
  1747.  r16, seg     2       2       2       2       2       3       1    NP
  1748.  m16, seg   2+d(0,2) 13+EA   11       3       2       3       1    NP
  1749.  Segment Register Moves - Protected Mode
  1750.  operands    bytes                   286     386     486     Pentium
  1751.  seg, r16     2                      17      18       9     2-11*  NP
  1752.  seg, m16   2+d(0,2)                 19      19       9     3-12*  NP
  1753.  * = add 8 if new descriptor; add 6 if SS
  1754.  Move to/from special registers (386+)
  1755.  operands    bytes                           386     486     Pentium
  1756.  r32, cr32    3                               6       4       4    NP
  1757.  cr32, r32    3                              4/10*   4/16*  12/22* NP
  1758.  r32, dr32    3                              14/22*  10      2/12* NP
  1759.  dr32, r32    3                              16/22*  11     11/12* NP
  1760.  r32, tr32    3                              12      3/4*     -    NP
  1761.  tr32, r32    3                              12      4/6*     -    NP
  1762.  * = cycles depend on which special register
  1763.  Example
  1764.  mov eax, ebx           ; EAX = EBX (General move)
  1765.  mov ds, ax             ; DS = AX   (Segment register move)
  1766.  mov cr0, eax           ; CR0 = EAX (Special register move)
  1767. contents
  1768. screen
  1769.  MOVD - Move 32 bits (MMX)
  1770.  Description
  1771. Copies doubleword from the source operand (second operand) to the destination operand (first operand). Source and destination operands can be MMX registers, memory locations, or 32-bit general-purpose registers; however, data cannot be transferred from an MMX register to an MMX register, from one memory location to another memory location, or from one general-purpose register to another general-purpose register. q
  1772. When the destination operand is an MMX register, the 32-bit source value is written to the low-order 32 bits of the 64-bit MMX register and zero-extended to 64 bits. When the source operand is an MMX register, the low-order 32 bits of the MMX register are written to the 32-bit general-purpose register or 32-bit memory location selected with the destination operand. '
  1773.  Flags affected
  1774. None. C
  1775.  Instruction size and timings
  1776. Not available. 
  1777.  Example
  1778. Not available. 
  1779. contents
  1780. screen
  1781.  MOVQ - Move 64 bits (MMX)
  1782.  Description
  1783. Copies quadword from the source operand (second operand) to the destination operand (first operand). A source or destination operand can be either an MMX register or a memory location; however, data cannot be transferred from one memory location to another memory location. Data can be transferred from one MMX register to another MMX register. '
  1784.  Flags affected
  1785. None. C
  1786.  Instruction size and timings
  1787. Not available. 
  1788.  Example
  1789. Not available. 
  1790. contents
  1791. screen
  1792.  MOVS/MOVSB/MOVSW/MOVSD - Move string
  1793.  Description
  1794. Moves the byte, word, or doubleword specified with the second operand (source operand) to the location specified with the first operand (destination operand). Both the source and destination operands are located in memory. The address of the source operand is read from the DS:ESI or the DS:SI registers (depending on the address-size attribute of the instruction, 32 or 16, respectively). The address of the destination operand is read from the ES:EDI or the ES:DI registers (again depending on the address-size attribute of the instruction). k
  1795. The DS segment may be overridden with a segment override prefix, but the ES segment cannot be overridden. 
  1796. At the assembly-code level, two forms of this instruction are allowed: the "explicit-operands" form and the "no-operands" form. The explicit-operands form (specified with the MOVS mnemonic) is not supported by NASM. h
  1797. The no-operands form provides "short forms" of the byte, word, and doubleword versions of the MOVS instructions. Here also DS:(E)SI and ES:(E)DI are assumed to be the source and destination operands, respectively. The size of the source and destination operands is selected with the mnemonic: MOVSB (byte move), MOVSW (word move), or MOVSD (doubleword move). 
  1798. After the move operation, the (E)SI and (E)DI registers are incremented or decremented automatically according to the setting of the DF flag in the EFLAGS register. (If the DF flag is 0, the (E)SI and (E)DI register are incremented; if the DF flag is 1, the (E)SI and (E)DI registers are decremented.) The registers are incremented or decremented by 1 for byte operations, by 2 for word operations, or by 4 for doubleword operations. 
  1799. The MOVS, MOVSB, MOVSW, and MOVSD instructions can be preceded by the REP prefix for block moves of ECX bytes, words, or doublewords. '
  1800.  Flags affected
  1801. None. C
  1802.  Instruction size and timings
  1803.  variations  bytes   8088    186     286     386     486     Pentium
  1804.  movsb        1      18       9       5       7       7       4   NP
  1805.  movsw        1      26       9       5       7       7       4   NP
  1806.  movsd        1       -       -       -       7       7       4   NP
  1807.  rep movsb    2      9+17n   8+8n    5+4n    7+4n   12+3n*   3+n  NP
  1808.  rep movsw    2      9+25n   8+8n    5+4n    7+4n   12+3n*   3+n  NP
  1809.  rep movsd    2       -       -       -      7+4n   12+3n*   3+n  NP
  1810.  * = 5 if n=0, 13 if n=1 (where n = count of bytes, words or dwords)
  1811.  Example
  1812.  rep movsb              ; Move CX bytes from DS:SI to ES:DI
  1813. contents
  1814. screen
  1815.  MOVSX - Move with sign-extension (386+)
  1816.  Description
  1817. Copies the contents of the source operand (register or memory location) to the destination operand (register) and sign extends the value to 16 or 32 bits. The size of the converted value depends on the operand-size attribute. '
  1818.  Flags affected
  1819. None. C
  1820.  Instruction size and timings
  1821.  operands  bytes                           386     486     Pentium
  1822.  reg, reg   3                               3       3       3   NP
  1823.  reg, mem   3+d(0,1,2,4)                    6       3       3   NP
  1824.  Note: destination register is 16 or 32-bits; source is 8 or 16 bits
  1825.  Example
  1826.  movsx  ebx, ax         ; EBX = sign extended AX
  1827. contents
  1828. screen
  1829.  MOVZX - Move with zero-extend (386+)
  1830.  Description
  1831. Copies the contents of the source operand (register or memory location) to the destination operand (register) and zero extends the value to 16 or 32 bits. The size of the converted value depends on the operand-size attribute. '
  1832.  Flags affected
  1833. None. C
  1834.  Instruction size and timings
  1835.  operands  bytes                           386     486     Pentium
  1836.  reg, reg   3                               3       3       3   NP
  1837.  reg, mem   3+d(0,1,2,4)                    6       3       3   NP
  1838.  Note: destination register is 16 or 32-bits; source is 8 or 16 bits
  1839.  Example
  1840.  movzx ebx, ax          ; EBX = zero extended AX
  1841. contents
  1842. screen
  1843.  MUL - Unsigned multiply
  1844.  Description
  1845. Performs an unsigned multiplication of the first operand (destination operand) and the second operand (source operand) and stores the result in the destination operand. The destination operand is an implied operand located in register AL, AX or EAX (depending on the size of the operand); the source operand is located in a general-purpose register or a memory location. The action of this instruction and the location of the result depends on the opcode and the operand size as shown in the following table. 
  1846.  Operand Size    Source 1     Source 2      Destination
  1847.  Byte            AL           r/m8          AX
  1848.  Word            AX           r/m16         DX:AX
  1849.  Doubleword      EAX          r/m32         EDX:EAX
  1850. The result is stored in register AX, register pair DX:AX, or register pair EDX:EAX (depending on the operand size), with the high-order bits of the product contained in register AH, DX, or EDX, respectively. If the high-order bits of the product are 0, the CF and OF flags are cleared; otherwise, the flags are set. '
  1851.  Flags affected
  1852. The OF and CF flags are cleared to 0 if the upper half of the result is 0; otherwise, they are set to 1. The SF, ZF, AF, and PF flags are undefined. C
  1853.  Instruction size and timings
  1854.  operand     bytes   8088     186    286     386     486     Pentium
  1855.  r8           2     70-77    26-28   13      9-14   13-18    11   NP
  1856.  r16          2    118-133   35-37   21      9-22   13-26    11   NP
  1857.  r32          2       -        -      -      9-38   13-42    10   NP
  1858.  mem8    2+d(0-2)  76-83+EA  32-34   16     12-17   13-18    11   NP
  1859.  mem16   2+d(0-2) 124-139+EA 41-43   24     12-25   13-26    11   NP
  1860.  mem32   2+d(0-2)     -        -      -     12-41   13-42    10   NP
  1861.  Example
  1862.  mul ebx        ; EDX:EAX = EAX * EBX
  1863. contents
  1864. screen
  1865.  NEG - Two's complement negation
  1866.  Description
  1867. Replaces the value of operand (the destination operand) with its two's complement. (This operation is equivalent to subtracting the operand from 0.) The destination operand is located in a general-purpose register or a memory location. '
  1868.  Flags affected
  1869. The CF flag cleared to 0 if the source operand is 0; otherwise it is set to 1. The OF, SF, ZF, AF, and PF flags are set according to the result. C
  1870.  Instruction size and timings
  1871.  operand     bytes   8088    186     286     386     486     Pentium
  1872.  reg          2       3       3       2       2       1       1   NP
  1873.  mem       2+d(0-2)  24+EA   13       7       6       3       3   NP
  1874.  Example
  1875.  neg eax        ; EAX = 0 - EAX
  1876. contents
  1877. screen
  1878.  NOP - No operation
  1879.  Description
  1880. Performs no operation. This instruction is a one-byte instruction that takes up space in the instruction stream but does not affect the machine context, except the EIP register. Q
  1881. The NOP instruction is an alias mnemonic for the XCHG (E)AX, (E)AX instruction. '
  1882.  Flags affected
  1883. None. C
  1884.  Instruction size and timings
  1885.  bytes   8088    186     286     386     486     Pentium
  1886.   1       3       3       3       3       1       1   UV
  1887.  Example
  1888.  nop       ; No operation
  1889. contents
  1890. screen
  1891.  NOT - One's complement negation
  1892.  Description
  1893. Performs a bitwise NOT operation (each 1 is cleared to 0, and each 0 is set to 1) on the destination operand and stores the result in the destination operand location. The destination operand can be a register or a memory location. '
  1894.  Flags affected
  1895. None. C
  1896.  Instruction size and timings
  1897.  operands    bytes   8088    186     286     386     486     Pentium
  1898.  reg          2       3       3       2       2       1       1   NP
  1899.  mem       2+d(0-2)  24+EA   13       7       6       3       3   NP
  1900.  Example
  1901.  not eax        ; Toggle each bit in EAX
  1902. contents
  1903. screen
  1904.  OR - Logical inclusive OR
  1905.  Description
  1906. Performs a bitwise inclusive OR operation between the destination (first) and source (second) operands and stores the result in the destination operand location. The source operand can be an immediate, a register, or a memory location; the destination operand can be a register or a memory location. (However, two memory operands cannot be used in one instruction.) Each bit of the result of the OR instruction is 0 if both corresponding bits of the operands are 0; otherwise, each bit is 1. '
  1907.  Flags affected
  1908. The OF and CF flags are cleared; the SF, ZF, and PF flags are set according to the result. The state of the AF flag is undefined. C
  1909.  Instruction size and timings
  1910.  operands     bytes   8088    186     286     386     486     Pentium
  1911.  reg, reg      2       3       3       2       2       1       1   UV
  1912.  mem, reg   2+d(0,2)  24+EA   10       7       7       3       3   UV
  1913.  reg, mem   2+d(0,2)  13+EA   10       7       6       2       2   UV
  1914.  reg, imm   2+i(1,2)   4       4       3       2       1       1   UV
  1915.  mem, imm   2+d(0,2)  23+EA   16       7       7       3       3   UV*
  1916.              +i(1,2)
  1917.  acc, imm   1+i(1,2)   4       4       3       2       1       1   UV
  1918.  * = not pairable if there is a displacement and immediate
  1919.  Example
  1920.  or eax, ebx    ; Perform logical or storing result in EAX
  1921. contents
  1922. screen
  1923.  OUT - Output to port
  1924.  Description
  1925. Copies the value from the second operand (source operand) to the I/O port specified with the destination operand (first operand). The source operand can be register AL, AX, or EAX, depending on the size of the port being accessed (8, 16, or 32 bits, respectively); the destination operand can be a byte-immediate or the DX register. Using a byte immediate allows I/O port addresses 0 to 255 to be accessed; using the DX register as a source operand allows I/O ports from 0 to 65,535 to be accessed. 
  1926. The size of the I/O port being accessed is determined by the opcode for an 8-bit I/O port or by the operand-size attribute of the instruction for a 16- or 32-bit I/O port. 
  1927. At the machine code level, I/O instructions are shorter when accessing 8-bit I/O ports. Here, the upper eight bits of the port address will be 0. '
  1928.  Flags affected
  1929. None. C
  1930.  Instruction size and timings
  1931.  operands    bytes   8088    186     286     386     486     Pentium
  1932.  imm8, al     2      14       9       3      10      16      12   NP
  1933.  imm8, ax     2      14       9       3      10      16      12   NP
  1934.  imm8, eax    2       -       -       -      10      16      12   NP
  1935.  dx, al       1      12       7       3      11      16      12   NP
  1936.  dx, ax       1      12       7       3      11      16      12   NP
  1937.  dx, eax      1       -       -       -      11      16      12   NP
  1938.  Protected Mode
  1939.  operands    bytes                           386     486     Pentium
  1940.  imm8, acc    2                            4/24/24 11/31/29 9/26/24 NP
  1941.  dx, acc      1                            5/25/25 10/30/29 9/26/24 NP
  1942.  Cycles for: CPL <= IOPL / CPL > IOPL / V86
  1943.  Example
  1944.  out dx, al     ; Send AL to port DX
  1945. contents
  1946. screen
  1947.  OUTS - Output string to port
  1948.  Description
  1949. Copies data from the source operand (second operand) to the I/O port specified with the destination operand (first operand). The source operand is a memory location, the address of which is read from either the DS:EDI or the DS:DI registers (depending on the address-size attribute of the instruction, 32 or 16, respectively). (The DS segment may be overridden with a segment override prefix.) The destination operand is an I/O port address (from 0 to 65,535) that is read from the DX register. The size of the I/O port being accessed (that is, the size of the source and destination operands) is determined by the opcode for an 8-bit I/O port or by the operand-size attribute of the instruction for a 16- or 32-bit I/O port. 
  1950. At the assembly-code level, two forms of this instruction are allowed: the "explicit-operands" form and the "no-operands" form. The explicit-operands form (specified with the OUTS mnemonic) is not supported by NASM. P
  1951. The no-operands form provides "short forms" of the byte, word, and doubleword versions of the OUTS instructions. Here also DS:(E)SI is assumed to be the source operand and DX is assumed to be the destination operand. The size of the I/O port is specified with the choice of mnemonic: OUTSB (byte), OUTSW (word), or OUTSD (doubleword). 
  1952. After the byte, word, or doubleword is transferred from the memory location to the I/O port, the (E)SI register is incremented or decremented automatically according to the setting of the DF flag in the EFLAGS register. (If the DF flag is 0, the (E)SI register is incremented; if the DF flag is 1, the (E)SI register is decremented.) The (E)SI register is incremented or decremented by 1 for byte operations, by 2 for word operations, or by 4 for doubleword operations. 
  1953. The OUTS, OUTSB, OUTSW, and OUTSD instructions can be preceded by the REP prefix for block input of ECX bytes, words, or doublewords. '
  1954.  Flags affected
  1955. None. C
  1956.  Instruction size and timings
  1957.  variations  bytes           186     286     386     486     Pentium
  1958.  outsb        1              14       5      14      17      13   NP
  1959.  outsw        1              14       5      14      17      13   NP
  1960.  outsd        1               -       -      14      17      13   NP
  1961.  Protected Mode
  1962.  bytes                           386     486     Pentium
  1963.   1                           8/28/28 10/32/30 10/27/25 NP
  1964.  Cycles for: CPL <= IOPL / CPL > IOPL / V86
  1965.  Example
  1966.  rep outsb      ; Output CX bytes from DS:DI to port DX
  1967. contents
  1968. screen
  1969.  PACKSSWB/PACKSSDW - Pack with signed saturation (MMX)
  1970.  Description
  1971. Packs and saturates signed words into bytes (PACKSSWB) or signed doublewords into words (PACKSSDW). The PACKSSWB instruction packs 4 signed words from the destination operand (first operand) and 4 signed words from the source operand (second operand) into 8 signed bytes in the destination operand. If the signed value of a word is beyond the range of a signed byte (that is, greater than 7FH or less than 80H), the saturated byte value of 7FH or 80H, respectively, is stored into the destination. 
  1972. The PACKSSDW instruction packs 2 signed doublewords from the destination operand (first operand) and 2 signed doublewords from the source operand (second operand) into 4 signed words in the destination operand. If the signed value of a doubleword is beyond the range of a signed word (that is, greater than 7FFFH or less than 8000H), the saturated word value of 7FFFH or 8000H, respectively, is stored into the destination. 
  1973. The destination operand for either the PACKSSWB or PACKSSDW instruction must be an MMX register; the source operand may be either an MMX register or a quadword memory location. '
  1974.  Flags affected
  1975. None. C
  1976.  Instruction size and timings
  1977. Not available. 
  1978.  Example
  1979. Not available. 
  1980. contents
  1981. screen
  1982.  PACKUSWB - Pack with unsigned saturation (MMX)
  1983.  Description
  1984. Packs and saturates 4 signed words from the destination operand (first operand) and 4 signed words from the source operand (second operand) into 8 unsigned bytes in the destination operand. If the signed value of a word is beyond the range of an unsigned byte (that is, greater than FFH or less than 00H), the saturated byte value of FFH or 00H, respectively, is stored into the destination. 
  1985. The destination operand must be an MMX register; the source operand may be either an MMX register or a quadword memory location. '
  1986.  Flags affected
  1987. None. C
  1988.  Instruction size and timings
  1989. Not available. 
  1990.  Example
  1991. Not available. 
  1992. contents
  1993. screen
  1994.  PADDB/PADDW/PADDD - Packed add (MMX)
  1995.  Description
  1996. Adds the individual data elements (bytes, words, or doublewords) of the source operand (second operand) to the individual data elements of the destination operand (first operand). If the result of an individual addition exceeds the range for the specified data type (overflows), the result is wrapped around, meaning that the result is truncated so that only the lower (least significant) bits of the result are returned (that is, the carry is ignored). 
  1997. The destination operand must be an MMX register; the source operand can be either an MMX register or a quadword memory location. H
  1998. The PADDB instruction adds the bytes of the source operand to the bytes of the destination operand and stores the results to the destination operand. When an individual result is too large to be represented in 8 bits, the lower 8 bits of the result are written to the destination operand and therefore the result wraps around. J
  1999. The PADDW instruction adds the words of the source operand to the words of the destination operand and stores the results to the destination operand. When an individual result is too large to be represented in 16 bits, the lower 16 bits of the result are written to the destination operand and therefore the result wraps around. V
  2000. The PADDD instruction adds the doublewords of the source operand to the doublewords of the destination operand and stores the results to the destination operand. When an individual result is too large to be represented in 32 bits, the lower 32 bits of the result are written to the destination operand and therefore the result wraps around. 
  2001. Note that like the integer ADD instruction, the PADDB, PADDW, and PADDD instructions can operate on either unsigned or signed (two's complement notation) packed integers. Unlike the integer instructions, none of the MMX instructions affect the EFLAGS register. With MMX instructions, there are no carry or overflow flags to indicate when overflow has occurred, so the software must control the range of values or else use the "with saturation" MMX instructions. '
  2002.  Flags affected
  2003. None. C
  2004.  Instruction size and timings
  2005. Not available. 
  2006.  Example
  2007. Not available. 
  2008. contents
  2009. screen
  2010.  PADDSB/PADDSW - Packed add with saturation (MMX)
  2011.  Description
  2012. Adds the individual signed data elements (bytes or words) of the source operand (second operand) to the individual signed data elements of the destination operand (first operand). If the result of an individual addition exceeds the range for the specified data type, the result is saturated. The destination operand must be an MMX register; the source operand can be either an MMX register or a quadword memory location. p
  2013. The PADDSB instruction adds the signed bytes of the source operand to the signed bytes of the destination operand and stores the results to the destination operand. When an individual result is beyond the range of a signed byte (that is, greater than 7FH or less than 80H), the saturated byte value of 7FH or 80H, respectively, is written to the destination operand. x
  2014. The PADDSW instruction adds the signed words of the source operand to the signed words of the destination operand and stores the results to the destination operand. When an individual result is beyond the range of a signed word (that is, greater than 7FFFH or less than 8000H), the saturated word value of 7FFFH or 8000H, respectively, is written to the destination operand. '
  2015.  Flags affected
  2016. None. C
  2017.  Instruction size and timings
  2018. Not available. 
  2019.  Example
  2020. Not available. 
  2021. contents
  2022. screen
  2023.  PADDUSB/PADDUSW - Packed add with unsigned saturation (MMX)
  2024.  Description
  2025. Adds the individual unsigned data elements (bytes or words) of the packed source operand (second operand) to the individual unsigned data elements of the packed destination operand (first operand). If the result of an individual addition exceeds the range for the specified unsigned data type, the result is saturated. The destination operand must be an MMX register; the source operand can be either an MMX register or a quadword memory location. Z
  2026. The PADDUSB instruction adds the unsigned bytes of the source operand to the unsigned bytes of the destination operand and stores the results to the destination operand. When an individual result is beyond the range of an unsigned byte (that is, greater than FFH), the saturated unsigned byte value of FFH is written to the destination operand. ^
  2027. The PADDUSW instruction adds the unsigned words of the source operand to the unsigned words of the destination operand and stores the results to the destination operand. When an individual result is beyond the range of an unsigned word (that is, greater than FFFFH), the saturated unsigned word value of FFFFH is written to the destination operand. '
  2028.  Flags affected
  2029. None. C
  2030.  Instruction size and timings
  2031. Not available. 
  2032.  Example
  2033. Not available. 
  2034. contents
  2035. screen
  2036.  PAND - Logical AND (MMX)
  2037.  Description
  2038. Performs a bitwise logical AND operation on the quadword source (second) and destination (first) operands and stores the result in the destination operand location. The source operand can be an MMX register or a quadword memory location; the destination operand must be an MMX register. Each bit of the result of the PAND instruction is set to 1 if the corresponding bits of the operands are both 1; otherwise it is made zero '
  2039.  Flags affected
  2040. None. C
  2041.  Instruction size and timings
  2042. Not available. 
  2043.  Example
  2044. Not available. 
  2045. contents
  2046. screen
  2047.  PANDN - Logical AND NOT (MMX)
  2048.  Description
  2049. Performs a bitwise logical NOT on the quadword destination operand (first operand). Then, the instruction performs a bitwise logical AND operation on the inverted destination operand and the quadword source operand (second operand). Each bit of the result of the AND operation is set to one if the corresponding bits of the source and inverted destination bits are one; otherwise it is set to zero. The result is stored in the destination operand location. {
  2050. The source operand can be an MMX register or a quadword memory location; the destination operand must be an MMX register. '
  2051.  Flags affected
  2052. None. C
  2053.  Instruction size and timings
  2054. Not available. 
  2055.  Example
  2056. Not available. 
  2057. contents
  2058. screen
  2059.  PCMPEQB/PCMPEQW/PCMPEQD - Packed compare for equal (MMX)
  2060.  Description
  2061. Compares the individual data elements (bytes, words, or doublewords) in the destination operand (first operand) to the corresponding data elements in the source operand (second operand). If a pair of data elements are equal, the corresponding data element in the destination operand is set to all ones; otherwise, it is set to all zeros. The destination operand must be an MMX register; the source operand may be either an MMX register or a 64- bit memory location. 
  2062. The PCMPEQB instruction compares the bytes in the destination operand to the corresponding bytes in the source operand, with the bytes in the destination operand being set according to the results. 
  2063. The PCMPEQW instruction compares the words in the destination operand to the corresponding words in the source operand, with the words in the destination operand being set according to the results. 
  2064. The PCMPEQD instruction compares the doublewords in the destination operand to the corre-sponding doublewords in the source operand, with the doublewords in the destination operand being set according to the results. '
  2065.  Flags affected
  2066. None. C
  2067.  Instruction size and timings
  2068. Not available. 
  2069.  Example
  2070. Not available. 
  2071. contents
  2072. screen
  2073.  PCMPGTB/PCMPGTW/PCMPGTD - Packed compare for greater than (MMX)
  2074.  Description
  2075. Compares the individual signed data elements (bytes, words, or doublewords) in the destination operand (first operand) to the corresponding signed data elements in the source operand (second operand). If a data element in the destination operand is greater than its corresponding data element in the source operand, the data element in the destination operand is set to all ones; otherwise, it is set to all zeros. The destination operand must be an MMX register; the source operand may be either an MMX register or a 64-bit memory location. 
  2076. The PCMPGTB instruction compares the signed bytes in the destination operand to the corresponding signed bytes in the source operand, with the bytes in the destination operand being set according to the results. 
  2077. The PCMPGTW instruction compares the signed words in the destination operand to the corresponding signed words in the source operand, with the words in the destination operand being set according to the results. 
  2078. The PCMPGTD instruction compares the signed doublewords in the destination operand to the corresponding signed doublewords in the source operand, with the doublewords in the destination operand being set according to the results. '
  2079.  Flags affected
  2080. None. C
  2081.  Instruction size and timings
  2082. Not available. 
  2083.  Example
  2084. Not available. 
  2085. contents
  2086. screen
  2087.  PMADDWD - Packed multiply and add (MMX)
  2088.  Description
  2089. Multiplies the individual signed words of the destination operand by the corresponding signed words of the source operand, producing four signed, doubleword results. The two doubleword results from the multiplication of the high-order words are added together and stored in the upper doubleword of the destination operand; the two doubleword results from the multiplication of the low-order words are added together and stored in the lower doubleword of the destination operand. The destination operand must be an MMX register; the source operand may be either an MMX register or a 64-bit memory location. 
  2090. The PMADDWD instruction wraps around to 80000000H only when all four words of both the source and destination operands are 8000H. '
  2091.  Flags affected
  2092. None. C
  2093.  Instruction size and timings
  2094. Not available. 
  2095.  Example
  2096. Not available. 
  2097. contents
  2098. screen
  2099.  PMULHW - Packed multiply high (MMX)
  2100.  Description
  2101. Multiplies the four signed words of the source operand (second operand) by the four signed words of the destination operand (first operand), producing four signed, doubleword, intermediate results. The high-order word of each intermediate result is then written to its corresponding word location in the destination operand. The destination operand must be an MMX register; the source operand may be either an MMX register or a 64-bit memory location. '
  2102.  Flags affected
  2103. None. C
  2104.  Instruction size and timings
  2105. Not available. 
  2106.  Example
  2107. Not available. 
  2108. contents
  2109. screen
  2110.  PMULLW - Packed multiply low (MMX)
  2111.  Description
  2112. Multiplies the four signed or unsigned words of the source operand (second operand) with the four signed or unsigned words of the destination operand (first operand), producing four doubleword, intermediate results. The low-order word of each intermediate result is then written to its corresponding word location in the destination operand. The destination operand must be an MMX register; the source operand may be either an MMX register or a 64- bit memory location. '
  2113.  Flags affected
  2114. None. C
  2115.  Instruction size and timings
  2116. Not available. 
  2117.  Example
  2118. Not available. 
  2119. contents
  2120. screen
  2121.  POP - Pop a value from the stack
  2122.  Description
  2123. Loads the value from the top of the stack to the location specified with the destination operand and then increments the stack pointer. The destination operand can be a general-purpose register, memory location, or segment register. 
  2124. The address-size attribute of the stack segment determines the stack pointer size (16 bits or 32 bits - the source address size), and the operand-size attribute of the current code segment determines the amount the stack pointer is incremented (2 bytes or 4 bytes). For example, if these address- and operand-size attributes are 32, the 32-bit ESP register (stack pointer) is incre-mented by 4 and, if they are 16, the 16-bit SP register is incremented by 2. (The B flag in the stack segment's segment descriptor determines the stack's address-size attribute, and the D flag in the current code segment's segment descriptor, along with prefixes, determines the operand-size attribute and also the address-size attribute of the destination operand.) 
  2125. If the destination operand is one of the segment registers DS, ES, FS, GS, or SS, the value loaded into the register must be a valid segment selector. In protected mode, popping a segment selector into a segment register automatically causes the descriptor information associated with that segment selector to be loaded into the hidden (shadow) part of the segment register and causes the selector and the descriptor information to be validated. z
  2126. A null value (0000-0003) may be popped into the DS, ES, FS, or GS register without causing a general protection fault. However, any subsequent attempt to reference a segment whose corresponding segment register is loaded with a null value causes a general protection exception. In this situation, no memory reference occurs and the saved value of the segment register is null. 
  2127. The POP instruction cannot pop a value into the CS register. To load the CS register from the stack, use the RET instruction. 
  2128. If the ESP register is used as a base register for addressing a destination operand in memory, the POP instruction computes the effective address of the operand after it increments the ESP register. 
  2129. The POP ESP instruction increments the stack pointer (ESP) before data at the old top of stack is written into the destination. o
  2130. A POP SS instruction inhibits all interrupts, including the NMI interrupt, until after execution of the next instruction. This action allows sequential execution of POP SS and MOV ESP, EBP instructions without the danger of having an invalid stack during an interrupt. However, use of the LSS instruction is the preferred method of loading the SS and ESP registers. '
  2131.  Flags affected
  2132. None. C
  2133.  Instruction size and timings
  2134.  operand     bytes   8088    186     286     386     486     Pentium
  2135.  reg          1      12      10       5       4       1       1   UV
  2136.  mem       2+d(0-2)  25+EA   20       5       5       6       3   NP
  2137.  seg          1      12       8       5       7       3       3   NP
  2138.  FS/GS        2       -       -       -       7       3       3   NP
  2139.  Protected Mode
  2140.  operand     bytes                   286     386     486     Pentium
  2141.  CS/DS/ES     1                      20      21       9     3-12  NP
  2142.  SS           1                      20      21       9     8-17  NP
  2143.  FS/GS        2                       -      21       9     3-12  NP
  2144.  Example
  2145.  pop eax        ; Pop dword off stack into EAX
  2146. contents
  2147. screen
  2148.  POPA/POPAD - Pop all general purpose registers (186+/386+)
  2149.  Description
  2150. Pops doublewords (POPAD) or words (POPA) from the stack into the general-purpose registers. The registers are loaded in the following order: EDI, ESI, EBP, EBX, EDX, ECX, and EAX (if the operand-size attribute is 32) and DI, SI, BP, BX, DX, CX, and AX (if the operand-size attribute is 16). (These instructions reverse the operation of the PUSHA/PUSHAD instructions.) The value on the stack for the ESP or SP register is ignored. Instead, the ESP or SP register is incremented after each register is loaded. 
  2151. The POPA (pop all) and POPAD (pop all double) mnemonics reference the same opcode. The POPA instruction is intended for use when the operand-size attribute is 16 and the POPAD instruction for when the operand-size attribute is 32. Some assemblers may force the operand size to 16 when POPA is used and to 32 when POPAD is used (using the operand-size override prefix [66H] if necessary). Others may treat these mnemonics as synonyms (POPA/POPAD) and use the current setting of the operand-size attribute to determine the size of values to be popped from the stack, regardless of the mnemonic used. (The D flag in the current code segment's segment descriptor determines the operand-size attribute.) '
  2152.  Flags affected
  2153. None. C
  2154.  Instruction size and timings
  2155.  variations  bytes           186     286     386     486     Pentium
  2156.  popa         1              51      19      24       9       5   NP
  2157.  popad        1               -       -      24       9       5   NP
  2158.  Example
  2159.  popa           ; Pop all registers
  2160. contents
  2161. screen
  2162.  POPF/POPFD - Pop flags/pop flags double (386+)
  2163.  Description
  2164. Pops a doubleword (POPFD) from the top of the stack (if the current operand-size attribute is 32) and stores the value in the EFLAGS register or pops a word from the top of the stack (if the operand-size attribute is 16) and stores it in the lower 16 bits of the EFLAGS register (that is, the FLAGS register). (These instructions reverse the operation of the PUSHF/PUSHFD instructions.) 
  2165. The POPF (pop flags) and POPFD (pop flags double) mnemonics reference the same opcode. The POPF instruction is intended for use when the operand-size attribute is 16 and the POPFD instruction for when the operand-size attribute is 32. Some assemblers may force the operand size to 16 when POPF is used and to 32 when POPFD is used. Others may treat these mnemonics as synonyms (POPF/POPFD) and use the current setting of the operand-size attribute to determine the size of values to be popped from the stack, regardless of the mnemonic used. 
  2166. The effect of the POPF/POPFD instructions on the EFLAGS register changes slightly, depending on the mode of operation of the processor. When the processor is operating in protected mode at privilege level 0 (or in real-address mode, which is equivalent to privilege level 0), all the non-reserved flags in the EFLAGS register except the VIP, VIF, and VM flags can be modified. The VIP and VIF flags are cleared, and the VM flag is unaffected. 
  2167. When operating in protected mode, with a privilege level greater than 0, but less than or equal to IOPL, all the flags can be modified except the IOPL field and the VIP, VIF, and VM flags. Here, the IOPL flags are unaffected, the VIP and VIF flags are cleared, and the VM flag is unaf-fected. The interrupt flag (IF) is altered only when executing at a level at least as privileged as the IOPL. If a POPF/POPFD instruction is executed with insufficient privilege, an exception does not occur, but the privileged bits do not change. 
  2168. When operating in virtual-8086 mode, the I/O privilege level (IOPL) must be equal to 3 to use POPF/POPFD instructions and the VM, RF, IOPL, VIP, and VIF flags are unaffected. If the IOPL is less than 3, the POPF/POPFD instructions cause a general-protection exception. '
  2169.  Flags affected
  2170. All flags except the reserved bits and the VM bit. C
  2171.  Instruction size and timings
  2172.  variations  bytes   8088    186     286     386     486     Pentium
  2173.  popf         1      12       8       5       5       9       6   NP
  2174.  popfd        1       -       -       -       5       9       6   NP
  2175.  Protected Mode
  2176.              bytes                   286     386     486     Pentium
  2177.  popf         1                       5       5       6       4   NP
  2178.  popfd        1                       -       5       6       4   NP
  2179.  Example
  2180.  popfd          ; Pop EFLAGS off the stack
  2181. contents
  2182. screen
  2183.  POR - Bitwise logical OR (MMX)
  2184.  Description
  2185. Performs a bitwise logical OR operation on the quadword source (second) and destination (first) operands and stores the result in the destination operand location. The source operand can be an MMX register or a quadword memory location; the destination operand must be an MMX register. Each bit of the result is made 0 if the corresponding bits of both operands are 0; otherwise the bit is set to 1. '
  2186.  Flags affected
  2187. None. C
  2188.  Instruction size and timings
  2189. Not available. 
  2190.  Example
  2191. Not available. 
  2192. contents
  2193. screen
  2194.  PSLLW/PSLLD/PSLLQ - Packed shift left logical (MMX)
  2195.  Description
  2196. Shifts the bits in the data elements (words, doublewords, or quadword) in the destination operand (first operand) to the left by the number of bits specified in the unsigned count operand (second operand). The result of the shift operation is written to the destination operand. As the bits in the data elements are shifted left, the empty low-order bits are cleared (set to zero). If the value specified by the count operand is greater than 15 (for words), 31 (for doublewords), or 63 (for a quadword), then the destination operand is set to all zeros. 
  2197. The destination operand must be an MMX register; the count operand can be either an MMX register, a 64-bit memory location, or an 8-bit immediate. 
  2198. The PSLLW instruction shifts each of the four words of the destination operand to the left by the number of bits specified in the count operand; the PSLLD instruction shifts each of the two doublewords of the destination operand; and the PSLLQ instruction shifts the 64-bit quadword in the destination operand. As the individual data elements are shifted left, the empty low-order bit positions are filled with zeros. '
  2199.  Flags affected
  2200. None. C
  2201.  Instruction size and timings
  2202. Not available. 
  2203.  Example
  2204. Not available. 
  2205. contents
  2206. screen
  2207.  PSRAW/PSRAD - Packed shift right arithmetic (MMX)
  2208.  Description
  2209. Shifts the bits in the data elements (words or doublewords) in the destination operand (first operand) to the right by the amount of bits specified in the unsigned count operand (second operand). The result of the shift operation is written to the destination operand. The empty high-order bits of each element are filled with the initial value of the sign bit of the data element. If the value specified by the count operand is greater than 15 (for words) or 31 (for doublewords), each destination data element is filled with the initial value of the sign bit of the element. 
  2210. The destination operand must be an MMX register; the count operand (source operand) can be either an MMX register, a 64-bit memory location, or an 8-bit immediate. ^
  2211. The PSRAW instruction shifts each of the four words in the destination operand to the right by the number of bits specified in the count operand; the PSRAD instruction shifts each of the two doublewords in the destination operand. As the individual data elements are shifted right, the empty high-order bit positions are filled with the sign value. '
  2212.  Flags affected
  2213. None. C
  2214.  Instruction size and timings
  2215. Not available. 
  2216.  Example
  2217. Not available. 
  2218. contents
  2219. screen
  2220.  PSRLW/PSRLD/PSRLQ - Packed shift right logical (MMX)
  2221.  Description
  2222. Shifts the bits in the data elements (words, doublewords, or quadword) in the destination operand (first operand) to the right by the number of bits specified in the unsigned count operand (second operand). The result of the shift operation is written to the destination operand. As the bits in the data elements are shifted right, the empty high-order bits are cleared (set to zero). If the value specified by the count operand is greater than 15 (for words), 31 (for doublewords), or 63 (for a quadword), then the destination operand is set to all zeros. 
  2223. The destination operand must be an MMX register; the count operand can be either an MMX register, a 64-bit memory location, or an 8-bit immediate. 
  2224. The PSRLW instruction shifts each of the four words of the destination operand to the right by the number of bits specified in the count operand; the PSRLD instruction shifts each of the two doublewords of the destination operand; and the PSRLQ instruction shifts the 64-bit quadword in the destination operand. As the individual data elements are shifted right, the empty high-order bit positions are filled with zeros. '
  2225.  Flags affected
  2226. None. C
  2227.  Instruction size and timings
  2228. Not available. 
  2229.  Example
  2230. Not available. 
  2231. contents
  2232. screen
  2233.  PSUBB/PSUBW/PSUBD - Packed subtract (MMX)
  2234.  Description
  2235. Subtracts the individual data elements (bytes, words, or doublewords) of the source operand (second operand) from the individual data elements of the destination operand (first operand). If the result of a subtraction exceeds the range for the specified data type (overflows), the result is wrapped around, meaning that the result is truncated so that only the lower (least significant) bits of the result are returned (that is, the carry is ignored). 
  2236. The destination operand must be an MMX register; the source operand can be either an MMX register or a quadword memory location. O
  2237. The PSUBB instruction subtracts the bytes of the source operand from the bytes of the destination operand and stores the results to the destination operand. When an individual result is too large to be represented in 8 bits, the lower 8 bits of the result are written to the destination operand and therefore the result wraps around. R
  2238. The PSUBW instruction subtracts the words of the source operand from the words of the desti-nation operand and stores the results to the destination operand. When an individual result is too large to be represented in 16 bits, the lower 16 bits of the result are written to the destination operand and therefore the result wraps around. ]
  2239. The PSUBD instruction subtracts the doublewords of the source operand from the doublewords of the destination operand and stores the results to the destination operand. When an individual result is too large to be represented in 32 bits, the lower 32 bits of the result are written to the destination operand and therefore the result wraps around. 
  2240. Note that like the integer SUB instruction, the PSUBB, PSUBW, and PSUBD instructions can operate on either unsigned or signed (two's complement notation) packed integers. Unlike the integer instructions, none of the MMX instructions affect the EFLAGS register. With MMX instructions, there are no carry or overflow flags to indicate when overflow has occurred, so the software must control the range of values or else use the "with saturation" MMX instructions. '
  2241.  Flags affected
  2242. None. C
  2243.  Instruction size and timings
  2244. Not available. 
  2245.  Example
  2246. Not available. 
  2247. contents
  2248. screen
  2249.  PSUBSB/PSUBSW - Packed subtract with saturation (MMX)
  2250.  Description
  2251. Subtracts the individual signed data elements (bytes or words) of the source operand (second operand) from the individual signed data elements of the destination operand (first operand). (See Figure 3-23.) If the result of a subtraction exceeds the range for the specified data type, the result is saturated. The destination operand must be an MMX register; the source operand can be either an MMX register or a quadword memory location. w
  2252. The PSUBSB instruction subtracts the signed bytes of the source operand from the signed bytes of the destination operand and stores the results to the destination operand. When an individual result is beyond the range of a signed byte (that is, greater than 7FH or less than 80H), the saturated byte value of 7FH or 80H, respectively, is written to the destination operand. 
  2253. The PSUBSW instruction subtracts the signed words of the source operand from the signed words of the destination operand and stores the results to the destination operand. When an individual result is beyond the range of a signed word (that is, greater than 7FFFH or less than 8000H), the saturated word value of 7FFFH or 8000H, respectively, is written to the destination operand. '
  2254.  Flags affected
  2255. None. C
  2256.  Instruction size and timings
  2257. Not available. 
  2258.  Example
  2259. Not available. 
  2260. contents
  2261. screen
  2262.  PSUBUSB/PSUBUSW - Packed subtract with unsigned saturation (MMX)
  2263.  Description
  2264. Subtracts the individual unsigned data elements (bytes or words) of the source operand (second operand) from the individual unsigned data elements of the destination operand (first operand). If the result of an individual subtraction exceeds the range for the specified unsigned data type, the result is saturated. The destination operand musts be an MMX register; the source operand can be either an MMX register or a quadword memory location. C
  2265. The PSUBUSB instruction subtracts the unsigned bytes of the source operand from the unsigned bytes of the destination operand and stores the results to the destination operand. When an indi-vidual result is less than zero (a negative value), the saturated unsigned byte value of 00H is written to the destination operand. D
  2266. The PSUBUSW instruction subtracts the unsigned words of the source operand from the unsigned words of the destination operand and stores the results to the destination operand. When an individual result is less than zero (a negative value), the saturated unsigned word value of 0000H is written to the destination operand. '
  2267.  Flags affected
  2268. None. C
  2269.  Instruction size and timings
  2270. Not available. 
  2271.  Example
  2272. Not available. 
  2273. contents
  2274. screen
  2275.  PUNPCKHBW/PUNPCKHWD/PUNPCKHDQ - Unpack high packed data (MMX)
  2276.  Description
  2277. Unpacks and interleaves the high-order data elements (bytes, words, or doublewords) of the destination operand (first operand) and source operand (second operand) into the destination operand. The low-order data elements are ignored. The destination operand must be an MMX register; the source operand may be either an MMX register or a 64-bit memory location. When the source data comes from a memory operand, the full 64-bit operand is accessed from memory, but the instruction uses only the high-order 32 bits. 
  2278. The PUNPCKHBW instruction interleaves the four high-order bytes of the source operand and the four high-order bytes of the destination operand and writes them to the destination operand. 
  2279. The PUNPCKHWD instruction interleaves the two high-order words of the source operand and the two high-order words of the destination operand and writes them to the destination operand. 
  2280. The PUNPCKHDQ instruction interleaves the high-order doubleword of the source operand and the high-order doubleword of the destination operand and writes them to the destination operand. 
  2281. If the source operand is all zeros, the result (stored in the destination operand) contains zero extensions of the high-order data elements from the original value in the destination operand. With the PUNPCKHBW instruction the high-order bytes are zero extended (that is, unpacked into unsigned words), and with the PUNPCKHWD instruction, the high-order words are zero extended (unpacked into unsigned doublewords). '
  2282.  Flags affected
  2283. None. C
  2284.  Instruction size and timings
  2285. Not available. 
  2286.  Example
  2287. Not available. 
  2288. contents
  2289. screen
  2290.  PUNPCKLBW/PUNPCKLWD/PUNPCKLDQ - Unpack low packed data (MMX)
  2291.  Description
  2292. Unpacks and interleaves the low-order data elements (bytes, words, or doublewords) of the destination and source operands into the destination operand (see Figure 3-26). The destination operand must be an MMX register; the source operand may be either an MMX register or a memory location. When source data comes from an MMX register, the upper 32 bits of the register are ignored. When the source data comes from a memory, only 32-bits are accessed from memory. 
  2293. The PUNPCKLBW instruction interleaves the four low-order bytes of the source operand and the four low-order bytes of the destination operand and writes them to the destination operand. 
  2294. The PUNPCKLWD instruction interleaves the two low-order words of the source operand and the two low-order words of the destination operand and writes them to the destination operand. 
  2295. The PUNPCKLDQ instruction interleaves the low-order doubleword of the source operand and the low-order doubleword of the destination operand and writes them to the destination operand. 
  2296. If the source operand is all zeros, the result (stored in the destination operand) contains zero extensions of the high-order data elements from the original value in the destination operand. With the PUNPCKLBW instruction the low-order bytes are zero extended (that is, unpacked into unsigned words), and with the PUNPCKLWD instruction, the low-order words are zero extended (unpacked into unsigned doublewords). '
  2297.  Flags affected
  2298. None. C
  2299.  Instruction size and timings
  2300. Not available. 
  2301.  Example
  2302. Not available. 
  2303. contents
  2304. screen
  2305.  PUSH - Push word/dword onto the stack
  2306.  Description
  2307. Decrements the stack pointer and then stores the source operand on the top of the stack. The address-size attribute of the stack segment determines the stack pointer size (16 bits or 32 bits), and the operand-size attribute of the current code segment determines the amount the stack pointer is decremented (2 bytes or 4 bytes). For example, if these address- and operand-size attributes are 32, the 32-bit ESP register (stack pointer) is decremented by 4 and, if they are 16, the 16-bit SP register is decremented by 2.(The B flag in the stack segment's segment descriptor determines the stack's address-size attribute, and the D flag in the current code segment's segment descriptor, along with prefixes, determines the operand-size attribute and also the address-size attribute of the source operand.) 
  2308. Pushing a 16-bit operand when the stack address-size attribute is 32 can result in a misaligned the stack pointer (that is, the stack pointer is not aligned on a doubleword boundary). U
  2309. The PUSH ESP instruction pushes the value of the ESP register as it existed before the instruction was executed. Thus, if a PUSH instruction uses a memory operand in which the ESP register is used as a base register for computing the operand address, the effective address of the operand is computed before the ESP register is decremented. 
  2310. In the real-address mode, if the ESP or SP register is 1 when the PUSH instruction is executed, the processor shuts down due to a lack of stack space. No exception is generated to indicate this condition. b
  2311. For processors from the 286 on, the PUSH ESP instruction pushes the value of the ESP register as it existed before the instruction was executed. (This is also true in the real-address and virtual-8086 modes.) For the 8086 processor, the PUSH SP instruction pushes the new value of the SP register (that is the value after it has been decremented by 2). '
  2312.  Flags affected
  2313. None. C
  2314.  Instruction size and timings
  2315.  operand    bytes   8088    186     286     386     486     Pentium
  2316.  reg         1      15      10       3       2       1       1   UV
  2317.  mem      2+d(0-2)  24+EA   16       5       5       4       2   NP
  2318.  seg         1      14       9       3       2       3       1   NP
  2319.  imm     1+i(1,2)    -       -       3       2       1       1   NP
  2320.  FS/GS       2       -       -       -       2       3       1   NP
  2321.  Example
  2322.  push eax       ; Push EAX onto the stack
  2323. contents
  2324. screen
  2325.  PUSHA/PUSHAD - Push all general purpose registers (186+/386+)
  2326.  Description
  2327. Pushes the contents of the general-purpose registers onto the stack. The registers are stored on the stack in the following order: EAX, ECX, EDX, EBX, EBP, ESP (original value), EBP, ESI, and EDI (if the current operand-size attribute is 32) and AX, CX, DX, BX, SP (original value), BP, SI, and DI (if the operand-size attribute is 16). (These instructions perform the reverse operation of the POPA/POPAD instructions.) The value pushed for the ESP or SP register is its value before prior to pushing the first register. %
  2328. The PUSHA (push all) and PUSHAD (push all double) mnemonics reference the same opcode. The PUSHA instruction is intended for use when the operand-size attribute is 16 and the PUSHAD instruction for when the operand-size attribute is 32. Some assemblers may force the operand size to 16 when PUSHA is used and to 32 when PUSHAD is used. Others may treat these mnemonics as synonyms (PUSHA/PUSHAD) and use the current setting of the operand-size attribute to determine the size of values to be pushed from the stack, regardless of the mnemonic used. 
  2329. In the real-address mode, if the ESP or SP register is 1, 3, or 5 when the PUSHA/PUSHAD instruction is executed, the processor shuts down due to a lack of stack space. No exception is generated to indicate this condition. '
  2330.  Flags affected
  2331. None. C
  2332.  Instruction size and timings
  2333.  variations  bytes           186     286     386     486     Pentium
  2334.  pusha        1              36      17      18      11       5   NP
  2335.  pushad       1               -       -      18      11       5   NP
  2336.  Example
  2337.  pusha          ; Push all general-purpose registers onto the stack
  2338. contents
  2339. screen
  2340.  PUSHF/PUSHFD - Push flags register onto the stack
  2341.  Description
  2342. Decrements the stack pointer by 4 (if the current operand-size attribute is 32) and pushes the entire contents of the EFLAGS register onto the stack, or decrements the stack pointer by 2 (if the operand-size attribute is 16) and pushes the lower 16 bits of the EFLAGS register (that is, the FLAGS register) onto the stack. (These instructions reverse the operation of the POPF/POPFD instructions.) When copying the entire EFLAGS register to the stack, the VM and RF flags (bits 16 and 17) are not copied; instead, the values for these flags are cleared in the EFLAGS image stored on the stack. )
  2343. The PUSHF (push flags) and PUSHFD (push flags double) mnemonics reference the same opcode. The PUSHF instruction is intended for use when the operand-size attribute is 16 and the PUSHFD instruction for when the operand-size attribute is 32. Some assemblers may force the operand size to 16 when PUSHF is used and to 32 when PUSHFD is used. Others may treat these mnemonics as synonyms (PUSHF/PUSHFD) and use the current setting of the operand-size attribute to determine the size of values to be pushed from the stack, regardless of the mnemonic used. 
  2344. When in virtual-8086 mode and the I/O privilege level (IOPL) is less than 3, the PUSHF/PUSHFD instruction causes a general protection exception. 
  2345. In the real-address mode, if the ESP or SP register is 1, 3, or 5 when the PUSHA/PUSHAD instruction is executed, the processor shuts down due to a lack of stack space. No exception is generated to indicate this condition. '
  2346.  Flags affected
  2347. None. C
  2348.  Instruction size and timings
  2349.  variations  bytes   8088    186     286     386     486     Pentium
  2350.  pushf        1      14       9       3       4       4       9   NP
  2351.  pushfd       1       -       -       -       4       4       9   NP
  2352.  Protected Mode
  2353.              bytes                   286     386     486     Pentium
  2354.  pushf        1                       3       4       3       3   NP
  2355.  pushfd       1                       -       4       3       3   NP
  2356.  Example
  2357.  pushf          ; Push EFLAGS onto the stack
  2358. contents
  2359. screen
  2360.  PXOR - Logical exclusive OR (MMX)
  2361.  Description
  2362. Performs a bitwise logical exclusive-OR (XOR) operation on the quadword source (second) and destination (first) operands and stores the result in the destination operand location. The source operand can be an MMX register or a quadword memory location; the destination operand must be an MMX register. Each bit of the result is 1 if the corresponding bits of the two operands are different; each bit is 0 if the corresponding bits of the operands are the same. '
  2363.  Flags affected
  2364. None. C
  2365.  Instruction size and timings
  2366. Not available. 
  2367.  Example
  2368. Not available. 
  2369. contents
  2370. screen
  2371.  RCL/RCR/ROL/ROR - Rotate
  2372.  Description
  2373. Shifts (rotates) the bits of the first operand (destination operand) the number of bit positions specified in the second operand (count operand) and stores the result in the destination operand. The destination operand can be a register or a memory location; the count operand is an unsigned integer that can be an immediate or a value in the CL register. The processor restricts the count to a number between 0 and 31 by masking all the bits in the count operand except the 5 least-significant bits. 
  2374. The rotate left (ROL) and rotate through carry left (RCL) instructions shift all the bits toward more-significant bit positions, except for the most-significant bit, which is rotated to the least-significant bit location. 
  2375.  ROL operation
  2376.         
  2377.      
  2378.         
  2379.         
  2380.              
  2381.  RCL operation
  2382.            
  2383.      
  2384.         
  2385.         
  2386.      
  2387.         
  2388. The rotate right (ROR) and rotate through carry right (RCR) instructions shift all the bits toward less significant bit positions, except for the least-significant bit, which is rotated to the most-significant bit location. 
  2389.  ROR operation
  2390.            
  2391.      
  2392.         
  2393.         
  2394.         
  2395.  RCR operation
  2396.            
  2397.      
  2398.         
  2399.         
  2400.      
  2401.         
  2402. The RCL and RCR instructions include the CF flag in the rotation. The RCL instruction shifts the CF flag into the least-significant bit and shifts the most-significant bit into the CF flag. The RCR instruction shifts the CF flag into the most-significant bit and shifts the least-significant bit into the CF flag. For the ROL and ROR instructions, the original value of the CF flag is not a part of the result, but the CF flag receives a copy of the bit that was shifted from one end to the other. 
  2403. The OF flag is defined only for the 1-bit rotates; it is undefined in all other cases (except that a zero-bit rotate does nothing, that is affects no flags). For left rotates, the OF flag is set to the exclusive OR of the CF bit (after the rotate) and the most-significant bit of the result. For right rotates, the OF flag is set to the exclusive OR of the two most-significant bits of the result. >
  2404. The 8086 does not mask the rotation count. However, all other processors (starting with the 286 processor) do mask the rotation count to 5 bits, resulting in a maximum count of 31. This masking is done in all operating modes (including the virtual-8086 mode) to reduce the maximum execution time of the instructions. '
  2405.  Flags affected
  2406. The CF flag contains the value of the bit shifted into it. The OF flag is affected only for single-bit rotates (see above); it is undefined for multi-bit rotates. The SF, ZF, AF, and PF flags are not affected. C
  2407.  Instruction size and timings
  2408.  RCL and RCR
  2409.  operands    bytes   8088    186     286     386     486     Pentium
  2410.  reg, 1       2       2       2       2       9       3       1   PU
  2411.  mem, 1    2+d(0,2)  23+EA   15       7      10       4       3   PU
  2412.  reg, cl      2       8+4n    5+n    5+n      9      8-30    7-24 NP
  2413.  mem, cl   2+d(0,2) 28+EA+4n 17+n    8+n     10      9-31    9-26 NP
  2414.  reg, imm     3       -       5+n    5+n      9      8-30    8-25 NP
  2415.  mem, imm  3+d(0,2)   -      17+n    8+n     10      9-31   10-27 NP
  2416.  ROL and ROR
  2417.  operands    bytes   8088    186     286     386     486     Pentium
  2418.  reg, 1       2       2       2       2       3       3       1   PU
  2419.  mem, 1    2+d(0,2)  23+EA   15       7       7       4       3   PU
  2420.  reg, cl      2       8+4n    5+n    5+n      3       3       4   NP
  2421.  mem, cl   2+d(0,2) 28+EA+4n 17+n    8+n      7       4       4   NP
  2422.  reg, imm     3       -       5+n    5+n      3       2       1   PU
  2423.  mem, imm  3+d(0,2)   -      17+n    8+n      7       4       3   PU*
  2424.  * = not pairable if there is a displacement and immediate
  2425.  Example
  2426.  ror eax, 16    ; Rotate EAX by 16 bits
  2427. contents
  2428. screen
  2429.  RDMSR - Read from Model Specific Register (Pentium+)
  2430.  Description
  2431. Loads the contents of a 64-bit model specific register (MSR) specified in the ECX register into registers EDX:EAX. The EDX register is loaded with the high-order 32 bits of the MSR and the EAX register is loaded with the low-order 32 bits. If less than 64 bits are implemented in the MSR being read, the values returned to EDX:EAX in unimplemented bit locations are undefined. 
  2432. This instruction must be executed at privilege level 0 or in real-address mode; otherwise, a general protection exception will be generated. Specifying a reserved or unimplemented MSR address in ECX will also cause a general protection exception. q
  2433. The MSRs control functions for testability, execution tracing, performance-monitoring and machine check errors. x
  2434. The CPUID instruction should be used to determine whether MSRs are supported (EDX[5]=1) before using this instruction. 
  2435. The MSRs and the ability to read them with the RDMSR instruction were introduced into the Intel Architecture with the Pentium processor. Execution of this instruction by an Intel Architecture processor earlier than the Pentium processor results in an invalid opcode exception. '
  2436.  Flags affected
  2437. None. C
  2438.  Instruction size and timings
  2439.  bytes                                           Pentium
  2440.   2                                              20-24 NP
  2441.  Example
  2442.  rdmsr          ; Read MSR addressed by ECX
  2443. contents
  2444. screen
  2445.  RDPMC - Read Performance-Monitoring Countersion (MMX/Pentium Pro+)
  2446.  Description
  2447. Loads the contents of the 40-bit performance-monitoring counter specified in the ECX register into registers EDX:EAX. The EDX register is loaded with the high-order 8 bits of the counter and the EAX register is loaded with the low-order 32 bits. The Pentium Pro processor has two performance-monitoring counters (0 and 1), which are specified by placing 0000H or 0001H, respectively, in the ECX register. N
  2448. The RDPMC instruction allows application code running at a privilege level of 1, 2, or 3 to read the performance-monitoring counters if the PCE flag in the CR4 register is set. This instruction is provided to allow performance monitoring by application code without incurring the overhead of a call to an operating-system procedure. 
  2449. The performance-monitoring counters are event counters that can be programmed to count events such as the number of instructions decoded, number of interrupts received, or number of cache loads. 
  2450. The RDPMC instruction does not serialize instruction execution. That is, it does not imply that all the events caused by the preceding instructions have been completed or that events caused by subsequent instructions have not begun. If an exact event count is desired, software must use a serializing instruction (such as the CPUID instruction) before and/or after the execution of the RDPMC instruction. .
  2451. The RDPMC instruction can execute in 16-bit addressing mode or virtual-8086 mode; however, the full contents of the ECX register are used to determine the counter to access and a full 40-bit result is returned (the low-order 32 bits in the EAX register and the high-order 9 bits in the EDX register). 
  2452. The RDPMC instruction was introduced into the Intel Architecture in the Pentium Pro processor and the Pentium processor with MMX technology. The other Pentium processors have performance-monitoring counters, but they must be read with the RDMSR instruction. '
  2453.  Flags affected
  2454. None. C
  2455.  Instruction size and timings
  2456. Not available. 
  2457.  Example
  2458.  rdpmc     ; Read performance-monitoring counter addressed by ECX
  2459. contents
  2460. screen
  2461.  RDTSC - Read Time-Stamp Counter (Pentium+)
  2462.  Description
  2463. Loads the current value of the processor's time-stamp counter into the EDX:EAX registers. The time-stamp counter is contained in a 64-bit MSR. The high-order 32 bits of the MSR are loaded into the EDX register, and the low-order 32 bits are loaded into the EAX register. The processor increments the time-stamp counter MSR every clock cycle and resets it to 0 whenever the processor is reset. s
  2464. The time stamp disable (TSD) flag in register CR4 restricts the use of the RDTSC instruction. When the TSD flag is clear, the RDTSC instruction can be executed at any privilege level; when the flag is set, the instruction can only be executed at privilege level 0. The time-stamp counter can also be read with the RDMSR instruction, when executing at privilege level 0. 
  2465. The RDTSC instruction is not a serializing instruction. Thus, it does not necessarily wait until all previous instructions have been executed before reading the counter. Similarly, subsequent instructions may begin execution before the read operation is performed. '
  2466.  Flags affected
  2467. None. C
  2468.  Instruction size and timings
  2469. Not available. 
  2470.  Example
  2471.  rdtsc          ; EDX:EAX = Time-Stamp Counter value
  2472. contents
  2473. screen
  2474.  REP/REPE/REPZ/REPNE/REPNZ - Repeat string operation prefix
  2475.  Description
  2476. Repeats a string instruction the number of times specified in the count register ((E)CX) or until the indicated condition of the ZF flag is no longer met. The REP (repeat), REPE (repeat while equal), REPNE (repeat while not equal), REPZ (repeat while zero), and REPNZ (repeat while not zero) mnemonics are prefixes that can be added to one of the string instructions. The REP prefix can be added to the INS, OUTS, MOVS, LODS, and STOS instructions, and the REPE, REPNE, REPZ, and REPNZ prefixes can be added to the CMPS and SCAS instructions. (The REPZ and REPNZ prefixes are synonymous forms of the REPE and REPNE prefixes, respectively.) The behavior of the REP prefix is undefined when used with non-string instructions. 
  2477. The REP prefixes apply only to one string instruction at a time. To repeat a block of instructions, use the LOOP instruction or another looping construct. 
  2478. All of these repeat prefixes cause the associated instruction to be repeated until the count in register (E)CX is decremented to 0 (see the following table). (If the current address-size attribute is 32, register ECX is used as a counter, and if the address-size attribute is 16, the CX register is used.) The REPE, REPNE, REPZ, and REPNZ prefixes also check the state of the ZF flag after each iteration and terminate the repeat loop if the ZF flag is not in the specified state. When both termination conditions are tested, the cause of a repeat termination can be determined either by testing the (E)CX register with a JECXZ instruction or by testing the ZF flag with a JZ, JNZ, and JNE instruction. 
  2479.  Repeat Conditions
  2480.  Repeat Prefix      Termination Condition 1      Termination Condition 2
  2481.  REP                ECX=0                        None
  2482.  REPE/REPZ          ECX=0                        ZF=0
  2483.  REPNE/REPNZ        ECX=0                        ZF=1
  2484. When the REPE/REPZ and REPNE/REPNZ prefixes are used, the ZF flag does not require initialization because both the CMPS and SCAS instructions affect the ZF flag according to the results of the comparisons they make. T
  2485. A repeating string operation can be suspended by an exception or interrupt. When this happens, the state of the registers is preserved to allow the string operation to be resumed upon a return from the exception or interrupt handler. The source and destination registers point to the next string elements to be operated on, the EIP register points to the string instruction, and the ECX register has the value it held following the last successful iteration of the instruction. This mechanism allows long string operations to proceed without affecting the interrupt response time of the system. M
  2486. When a fault occurs during the execution of a CMPS or SCAS instruction that is prefixed with REPE or REPNE, the EFLAGS value is restored to the state prior to the execution of the instruction. Since the SCAS and CMPS instructions do not use EFLAGS as an input, the processor can resume the instruction after the page fault handler. 
  2487. Use the REP INS and REP OUTS instructions with caution. Not all I/O ports can handle the rate at which these instructions execute. R
  2488. A REP STOS instruction is the fastest way to initialize a large block of memory. '
  2489.  Flags affected
  2490. None; however, the CMPS and SCAS instructions do set the status flags in the EFLAGS register. C
  2491.  Instruction size and timings
  2492. See MOVS and STOS. 
  2493.  REPE/REPZ/REPNE/REPNZ
  2494. See CMPS and SCAS. 
  2495.  Example
  2496.  rep movsb      ; Repeatedly move bytes
  2497. contents
  2498. screen
  2499.  RET/RETN/RETF - Return from procedure
  2500.  Description
  2501. Transfers program control to a return address located on the top of the stack. The address is usually placed on the stack by a CALL instruction, and the return is made to the instruction that follows the CALL instruction. 0
  2502. The optional source operand specifies the number of stack bytes to be released after the return address is popped; the default is none. This operand can be used to release parameters from the stack that were passed to the called procedure and are no longer needed. It must be used when the CALL instruction used to switch to a new procedure uses a call gate with a non-zero word count to access the new procedure. Here, the source operand for the RET instruction must specify the same number of bytes as is specified in the word count field of the call gate. N
  2503. The RET instruction can be used to execute three different types of returns:     
  2504.  Near return (RETN) - a return to a calling procedure within the current
  2505.                         code segment (the segment currently pointed to by the
  2506.                         CS register), sometimes referred to as an
  2507.                         intrasegment return.
  2508.  Far return (RETF)  - a return to a calling procedure located in a different
  2509.                         segment than the current code segment, sometimes
  2510.                         referred to as an intersegment return.
  2511.  Inter-privilege-level far return - a far return to a different privilege
  2512.                                       level than that of the currently
  2513.                                       executing program or procedure.
  2514. The inter-privilege-level return type can only be executed in protected mode. 
  2515. When executing a near return, the processor pops the return instruction pointer (offset) from the top of the stack into the EIP register and begins program execution at the new instruction pointer. The CS register is unchanged. 4
  2516. When executing a far return, the processor pops the return instruction pointer from the top of the stack into the EIP register, then pops the segment selector from the top of the stack into the CS register. The processor then begins program execution in the new code segment at the new instruction pointer. W
  2517. The mechanics of an inter-privilege-level far return are similar to an intersegment return, except that the processor examines the privilege levels and access rights of the code and stack segments being returned to determine if the control transfer is allowed to be made. The DS, ES, FS, and GS segment registers are cleared by the RET instruction during an inter-privilege-level return if they refer to segments that are not allowed to be accessed at the new privilege level. Since a stack switch also occurs on an inter-privilege level return, the ESP and SS registers are loaded from the stack. V
  2518. If parameters are passed to the called procedure during an inter-privilege level call, the optional source operand must be used with the RET instruction to release the parameters on the return. Here, the parameters are released both from the called procedure's stack and the calling procedure's stack (that is, the stack being returned to). '
  2519.  Flags affected
  2520. None. C
  2521.  Instruction size and timings
  2522.  variations/
  2523.  operands     bytes   8088    186     286     386     486     Pentium
  2524.  retn         1       20      16      11+m    10+m     5       2   NP
  2525.  retn imm16   1+d(2)  24      18      11+m    10+m     5       3   NP
  2526.  retf         1       34      22      15+m    18+m    13       4   NP
  2527.  retf imm16   1+d(2)  33      25      15+m    18+m    14       4   NP
  2528.  Example
  2529.  ret            ; Return to calling code
  2530. contents
  2531. screen
  2532.  RSM - Resume from System Management Mode (Pentium+)
  2533.  Description
  2534. Returns program control from system management mode (SMM) to the application program or operating-system procedure that was interrupted when the processor received an SSM interrupt. The processor's state is restored from the dump created upon entering SMM. If the processor detects invalid state information during state restoration, it enters the shutdown state. The following invalid information can cause a shutdown: 
  2535.  Any reserved bit of CR4 is set to 1.
  2536.  Any illegal combination of bits in CR0, such as (PG=1 and PE=0) or
  2537.    (NW=1 and CD=0).
  2538.  (Intel Pentium 
  2539.  and 486 processors only.) The value stored in the state
  2540.    dump base field is not a 32-KByte aligned address.
  2541. The contents of the model-specific registers are not affected by a return from SMM. '
  2542.  Flags affected
  2543. All. C
  2544.  Instruction size and timings
  2545.  bytes                                           Pentium
  2546.   2                                              83   NP
  2547.  Example
  2548.  rsm            ; Resume from System Management Mode
  2549. contents
  2550. screen
  2551.  SAHF - Store AH into flags
  2552.  Description
  2553. Loads the SF, ZF, AF, PF, and CF flags of the EFLAGS register with values from the corresponding bits in the AH register (bits 7, 6, 4, 2, and 0, respectively). Bits 1, 3, and 5 of register AH are ignored; the corresponding reserved bits (1, 3, and 5) in the EFLAGS register remain unchanged. '
  2554.  Flags affected
  2555. The SF, ZF, AF, PF, and CF flags are loaded with values from the AH register. Bits 1, 3, and 5 of the EFLAGS register are unaffected, with the values remaining 1, 0, and 0, respectively. C
  2556.  Instruction size and timings
  2557.  bytes   8088    186     286     386     486     Pentium
  2558.   1       4       3       2       3       2       2   NP
  2559.  Example
  2560.  sahf      ; Store AH in EFLAGS
  2561. contents
  2562. screen
  2563.  SAL/SAR/SHL/SHR - Shift bits
  2564.  Description
  2565. Shifts the bits in the first operand (destination operand) to the left or right by the number of bits specified in the second operand (count operand). Bits shifted beyond the destination operand boundary are first shifted into the CF flag, then discarded. At the end of the shift operation, the CF flag contains the last bit shifted out of the destination operand. 
  2566. The destination operand can be a register or a memory location. The count operand can be an immediate value or register CL. The count is masked to 5 bits, which limits the count range to 0 to 31. A special opcode encoding is provided for a count of 1. \
  2567. The shift arithmetic left (SAL) and shift logical left (SHL) instructions perform the same operation; they shift the bits in the destination operand to the left (toward more significant bit locations). For each shift count, the most significant bit of the destination operand is shifted into the CF flag, and the least significant bit is cleared. 
  2568.  SAL/SHL operation
  2569.         
  2570.      
  2571.      
  2572.         
  2573.         
  2574.      
  2575.      
  2576. The shift arithmetic right (SAR) and shift logical right (SHR) instructions shift the bits of the destination operand to the right (toward less significant bit locations). For each shift count, the least significant bit of the destination operand is shifted into the CF flag, and the most significant bit is either set or cleared depending on the instruction type. The SHR instruction clears the most significant bit. 
  2577.  SAR operation
  2578.            
  2579.      
  2580.         
  2581.         
  2582.      
  2583.         
  2584.  SHR operation
  2585.         
  2586.      
  2587.      
  2588.         
  2589.         
  2590.      
  2591.      
  2592. The SAR and SHR instructions can be used to perform signed or unsigned division, respectively, of the destination operand by powers of 2. For example, using the SAR instruction to shift a signed integer 1 bit to the right divides the value by 2. x
  2593. Using the SAR instruction to perform a division operation does not produce the same result as the IDIV instruction. The quotient from the IDIV instruction is rounded toward zero, whereas the "quotient" of the SAR instruction is rounded toward negative infinity. This difference is apparent only for negative numbers. For example, when the IDIV instruction is used to divide -9 by 4, the result is -2 with a remainder of -1. If the SAR instruction is used to shift -9 right by two bits, the result is -3 and the "remainder" is +3; however, the SAR instruction stores only the most significant bit of the remainder (in the CF flag). 
  2594. The OF flag is affected only on 1-bit shifts. For left shifts, the OF flag is cleared to 0 if the most-significant bit of the result is the same as the CF flag (that is, the top two bits of the original operand were the same); otherwise, it is set to 1. For the SAR instruction, the OF flag is cleared for all 1-bit shifts. For the SHR instruction, the OF flag is set to the most-significant bit of the original operand. K
  2595. The 8086 does not mask the shift count. However, all other Intel Architecture processors (starting with the 286 processor) do mask the shift count to 5 bits, resulting in a maximum count of 31. This masking is done in all operating modes (including the virtual-8086 mode) to reduce the maximum execution time of the instructions. '
  2596.  Flags affected
  2597. The CF flag contains the value of the last bit shifted out of the destination operand; it is undefined for SHL and SHR instructions where the count is greater than or equal to the size (in bits) of the destination operand. The OF flag is affected only for 1-bit shifts (see above); otherwise, it is undefined. The SF, ZF, and PF flags are set according to the result. If the count is 0, the flags are not affected. For a non-zero count, the AF flag is undefined. C
  2598.  Instruction size and timings
  2599.  operands     bytes   8088    186     286     386     486     Pentium
  2600.  reg, 1        2       2       2       2       3       3       1   PU
  2601.  mem, 1     2+d(0,2)  23+EA   15       7       7       4       3   PU
  2602.  reg, cl       2       8+4n    5+n    5+n      3       3       4   NP
  2603.  mem, cl    2+d(0,2) 28+EA+4n 17+n    8+n      7       4       4   NP
  2604.  reg, imm      3       -       5+n    5+n      3       2       1   PU
  2605.  mem, imm   3+d(0,2)   -      17+n    8+n      7       4       3   PU*
  2606.  * = not pairable if there is a displacement and immediate
  2607.  Example
  2608.  shl eax, 1     ; EAX = EAX * 2
  2609. contents
  2610. screen
  2611.  SBB - Integer subtraction with borrow
  2612.  Description
  2613. Adds the source operand (second operand) and the carry (CF) flag, and subtracts the result from the destination operand (first operand). The result of the subtraction is stored in the destination operand. The destination operand can be a register or a memory location; the source operand can be an immediate, a register, or a memory location. (However, two memory operands cannot be used in one instruction.) The state of the CF flag represents a borrow from a previous subtraction. u
  2614. When an immediate value is used as an operand, it is sign-extended to the length of the destination operand format. &
  2615. The SBB instruction does not distinguish between signed or unsigned operands. Instead, the processor evaluates the result for both data types and sets the OF and CF flags to indicate a borrow in the signed or unsigned result, respectively. The SF flag indicates the sign of the signed result. 
  2616. The SBB instruction is usually executed as part of a multibyte or multiword subtraction in which a SUB instruction is followed by a SBB instruction. '
  2617.  Flags affected
  2618. The OF, SF, ZF, AF, PF, and CF flags are set according to the result. C
  2619.  Instruction size and timings
  2620.  operands    bytes   8088    186     286     386     486     Pentium
  2621.  reg, reg     2       3       3       2       2       1       1   PU
  2622.  mem, reg  2+d(0,2)  24+EA   10       7       7       3       3   PU
  2623.  reg, mem  2+d(0,2)  13+EA   10       7       6       2       2   PU
  2624.  reg, imm  2+i(1,2)   4       4       3       2       1       1   PU
  2625.  mem, imm  2+d(0,2)  23+EA   16       7       7       3       3   PU*
  2626.             +i(1,2)
  2627.  acc, imm  1+i(1,2)   4       4       3       2       1       1   PU
  2628.  * = not pairable if there is a displacement and immediate
  2629.  Example
  2630.  sbb eax, ebx   ; EAX = EAX - (EBX + CF)
  2631. contents
  2632. screen
  2633.  SCAS - Scan string
  2634.  Description
  2635. Compares the byte, word, or double word specified with the memory operand with the value in the AL, AX, or EAX register, and sets the status flags in the EFLAGS register according to the results. The memory operand address is read from either the ES:EDI or the ES:DI registers (depending on the address-size attribute of the instruction, 32 or 16, respectively). The ES segment cannot be overridden with a segment override prefix. 
  2636. At the assembly-code level, two forms of this instruction are allowed: the "explicit-operands" form and the "no-operands" form. The explicit-operand form (specified with the SCAS mnemonic) is not supported by NASM. 
  2637. The no-operands form provides "short forms" of the byte, word, and doubleword versions of the SCAS instructions. Here also ES:(E)DI is assumed to be the memory operand and the AL, AX, or EAX register is assumed to be the register operand. The size of the two operands is selected with the mnemonic: SCASB (byte comparison), SCASW (word comparison), or SCASD (doubleword comparison). 
  2638. After the comparison, the (E)DI register is incremented or decremented automatically according to the setting of the DF flag in the EFLAGS register. (If the DF flag is 0, the (E)DI register is incremented; if the DF flag is 1, the (E)DI register is decremented.) The (E)DI register is incremented or decremented by 1 for byte operations, by 2 for word operations, or by 4 for double-word operations. :
  2639. The SCAS, SCASB, SCASW, and SCASD instructions can be preceded by the REP prefix for block comparisons of ECX bytes, words, or doublewords. More often, however, these instructions will be used in a LOOP construct that takes some action based on the setting of the status flags before the next comparison is made. '
  2640.  Flags affected
  2641. The OF, SF, ZF, AF, PF, and CF flags are set according to the temporary result of the comparison. C
  2642.  Instruction size and timings
  2643.  variations  bytes   8088    186     286     386     486     Pentium
  2644.  scasb        1      19      15       7       7       6       4   NP
  2645.  scasw        1      19      15       7       7       6       4   NP
  2646.  scasd        1       -       -       -       7       6       4   NP
  2647.  repX scasb   2      9+15n   5+15n   5+8n    5+8n    7+5n*   8+4n NP
  2648.  repX scasw   2      9+19n   5+15n   5+8n    5+8n    7+5n*   8+4n NP
  2649.  repX scasd   2       -       -       -      5+8n    7+5n*   8+4n NP
  2650.  repX = repe or repz or repne or repnz
  2651.  * = 5 if n=0 (where n = count of bytes, words or dwords)
  2652.  Example
  2653.  repne scasb    ; Repeat comparison
  2654. contents
  2655. screen
  2656.  SETcc - Set byte on condition (386+)
  2657.  Description
  2658. Set the destination operand to 0 or 1 depending on the settings of the status flags (CF, SF, OF, ZF, and PF) in the EFLAGS register. The destination operand points to a byte register or a byte in memory. The condition code suffix (cc) indicates the condition being tested for. 
  2659. 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. 3
  2660. Many of the SETcc instruction opcodes have alternate mnemonics. For example, the SETG (set byte if greater) and SETNLE (set if not less or equal) both 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. ,
  2661. Some languages represent a logical one as an integer with all bits set. This representation can be obtained by choosing the logically opposite condition for the SETcc instruction, then decrementing the result. For example, to test for overflow, use the SETNO instruction, then decrement the result. 
  2662.  Instruction  Description
  2663.  SETA         Set byte if above (CF=0 and ZF=0)
  2664.  SETAE        Set byte if above or equal (CF=0)
  2665.  SETB         Set byte if below (CF=1)
  2666.  SETBE        Set byte if below or equal (CF=1 or ZF=1)
  2667.  SETC         Set if carry (CF=1)
  2668.  SETE         Set byte if equal (ZF=1)
  2669.  SETG         Set byte if greater (ZF=0 and SF=OF)
  2670.  SETGE        Set byte if greater or equal (SF=OF)
  2671.  SETL         Set byte if less (SF<>OF)
  2672.  SETLE        Set byte if less or equal (ZF=1 or SF<>OF)
  2673.  SETNA        Set byte if not above (CF=1 or ZF=1)
  2674.  SETNAE       Set byte if not above or equal (CF=1)
  2675.  SETNB        Set byte if not below (CF=0)
  2676.  SETNBE       Set byte if not below or equal (CF=0 and ZF=0)
  2677.  SETNC        Set byte if not carry (CF=0)
  2678.  SETNE        Set byte if not equal (ZF=0)
  2679.  SETNG        Set byte if not greater (ZF=1 or SF<>OF)
  2680.  SETNGE       Set if not greater or equal (SF<>OF)
  2681.  SETNL        Set byte if not less (SF=OF)
  2682.  SETNLE       Set byte if not less or equal (ZF=0 and SF=OF)
  2683.  SETNO        Set byte if not overflow (OF=0)
  2684.  SETNP        Set byte if not parity (PF=0)
  2685.  SETNS        Set byte if not sign (SF=0)
  2686.  SETNZ        Set byte if not zero (ZF=0)
  2687.  SETO         Set byte if overflow (OF=1)
  2688.  SETP         Set byte if parity (PF=1)
  2689.  SETPE        Set byte if parity even (PF=1)
  2690.  SETPO        Set byte if parity odd (PF=0)
  2691.  SETS         Set byte if sign (SF=1)
  2692.  SETZ         Set byte if zero (ZF=1)
  2693.  Flags affected
  2694. None. C
  2695.  Instruction size and timings
  2696.  operand   bytes                           386     486     Pentium
  2697.  r8         3                               4      4/3     1/2  NP
  2698.  mem8     3+d(0-2)                          5      3/4     1/2  NP
  2699.  Example
  2700.  setne al       ; AL = 1 if ZF = 0
  2701. contents
  2702. screen
  2703.  SGDT/SIDT - Store Global/Interrupt Descriptor Table (286+)
  2704.  Description
  2705. Stores the contents of the global descriptor table register (GDTR) or the interrupt descriptor table register (IDTR) in the destination operand. The destination operand specifies a 6-byte memory location. If the operand-size attribute is 32 bits, the 16-bit limit field of the register is stored in the lower 2 bytes of the memory location and the 32-bit base address is stored in the upper 4 bytes. If the operand-size attribute is 16 bits, the limit is stored in the lower 2 bytes and the 24-bit base address is stored in the third, fourth, and fifth byte, with the sixth byte filled with 0s. 
  2706. The SGDT and SIDT instructions are only useful in operating-system software; however, they can be used in application programs without causing an exception to be generated. =
  2707. See LGDT/LIDT for information on loading the GDTR and IDTR. 
  2708. The 16-bit forms of the SGDT and SIDT instructions are compatible with the 286 processor, if the upper 8 bits are not referenced. The 286 processor fills these bits with 1s; the Pentium Pro, Pentium, 486, and 386 processors fill these bits with 0s. '
  2709.  Flags affected
  2710. None. C
  2711.  Instruction size and timings
  2712.  SGDT
  2713.  operand    bytes                   286     386     486     Pentium
  2714.  mem48       5                      11       9      10       4   NP
  2715.  SIDT
  2716.  operand    bytes                   286     386     486     Pentium
  2717.  mem48       5                      12       9      10       4   NP
  2718.  Example
  2719.  sgdt descriptor[ebx]           ; Store given descriptor
  2720. contents
  2721. screen
  2722.  SHLD - Double precision shift left (386+)
  2723.  Description
  2724. Shifts the first operand (destination operand) to the left the number of bits specified by the third operand (count operand). The second operand (source operand) provides bits to shift in from the right (starting with bit 0 of the destination operand). The destination operand can be a register or a memory location; the source operand is a register. The count operand is an unsigned integer that can be an immediate byte or the contents of the CL register. Only bits 0 through 4 of the count are used, which masks the count to a value between 0 and 31. If the count is greater than the operand size, the result in the destination operand is undefined. 
  2725. If the count is 1 or greater, the CF flag is filled with the last bit shifted out of the destination operand. For a 1-bit shift, the OF flag is set if a sign change occurred; otherwise, it is cleared. If the count operand is 0, the flags are not affected. N
  2726. The SHLD instruction is useful for multiprecision shifts of 64 bits or more. '
  2727.  Flags affected
  2728. If the count is 1 or greater, the CF flag is filled with the last bit shifted out of the destination operand and the SF, ZF, and PF flags are set according to the value of the result. For a 1-bit shift, the OF flag is set if a sign change occurred; otherwise, it is cleared. For shifts greater than 1 bit, the OF flag is undefined. If a shift occurs, the AF flag is undefined. If the count operand is 0, the flags are not affected. If the count is greater than the operand size, the flags are undefined. C
  2729.  Instruction size and timings
  2730.  operands        bytes                      386     486     Pentium
  2731.  reg, reg, imm    4                          3       2       4   NP
  2732.  mem, reg, imm   4+d(0-2)                    7       3       4   NP
  2733.  reg, reg, cl     4                          3       3       4   NP
  2734.  mem, reg, cl    4+d(0-2)                    7       4       5   NP
  2735.  Example
  2736.  shld eax, ebx, 16      ; Shift EAX 16 bits to the left with new bits coming
  2737.                         ; in from the right from EBX
  2738. contents
  2739. screen
  2740.  SHRD - Double precision shift right (386+)
  2741.  Description
  2742. Shifts the first operand (destination operand) to the right the number of bits specified by the third operand (count operand). The second operand (source operand) provides bits to shift in from the left (starting with the most significant bit of the destination operand). The destination operand can be a register or a memory location; the source operand is a register. The count operand is an unsigned integer that can be an immediate byte or the contents of the CL register. Only bits 0 through 4 of the count are used, which masks the count to a value between 0 and 31. If the count is greater than the operand size, the result in the destination operand is undefined. 
  2743. If the count is 1 or greater, the CF flag is filled with the last bit shifted out of the destination operand. For a 1-bit shift, the OF flag is set if a sign change occurred; otherwise, it is cleared. If the count operand is 0, the flags are not affected. N
  2744. The SHRD instruction is useful for multiprecision shifts of 64 bits or more. '
  2745.  Flags affected
  2746. If the count is 1 or greater, the CF flag is filled with the last bit shifted out of the destination operand and the SF, ZF, and PF flags are set according to the value of the result. For a 1-bit shift, the OF flag is set if a sign change occurred; otherwise, it is cleared. For shifts greater than 1 bit, the OF flag is undefined. If a shift occurs, the AF flag is undefined. If the count operand is 0, the flags are not affected. If the count is greater than the operand size, the flags are undefined. C
  2747.  Instruction size and timings
  2748.  operands        bytes                      386     486     Pentium
  2749.  reg, reg, imm    4                          3       2       4   NP
  2750.  mem, reg, imm   4+d(0-2)                    7       3       4   NP
  2751.  reg, reg, cl     4                          3       3       4   NP
  2752.  mem, reg, cl    4+d(0-2)                    7       4       5   NP
  2753.  Example
  2754.  shrd eax, ebx, 16      ; Shift EAX 16 bits to the right with new bits coming
  2755.                         ; in from the left from EBX
  2756. contents
  2757. screen
  2758.  SLDT - Store Local Descriptor Table register (286+)
  2759.  Description
  2760. Stores the segment selector from the local descriptor table register (LDTR) in the destination operand. The destination operand can be a general-purpose register or a memory location. The segment selector stored with this instruction points to the segment descriptor (located in the GDT) for the current LDT. This instruction can only be executed in protected mode. 
  2761. When the destination operand is a 32-bit register, the 16-bit segment selector is copied into the lower-order 16 bits of the register. The high-order 16 bits of the register are cleared to 0s for the Pentium Pro processor and are undefined for Pentium, 486, and 386 processors. When the destination operand is a memory location, the segment selector is written to memory as a 16-bit quantity, regardless of the operand size. t
  2762. The SLDT instruction is only useful in operating-system software; however, it can be used in application programs. '
  2763.  Flags affected
  2764. None. C
  2765.  Instruction size and timings
  2766.  operands   bytes                   286     386     486     Pentium
  2767.  r16         3                       2       2       2       2   NP
  2768.  mem16     3+d(0-2)                  3       2       3       2   NP
  2769.  Example
  2770.  sldt ax        ; Store LDT from AX
  2771. contents
  2772. screen
  2773.  SMSW - Store Machine Status Word (286+)
  2774.  Description
  2775. Stores the machine status word (bits 0 through 15 of control register CR0) into the destination operand. The destination operand can be a 16-bit general-purpose register or a memory location. k
  2776. When the destination operand is a 32-bit register, the low-order 16 bits of register CR0 are copied into the low-order 16 bits of the register and the upper 16 bits of the register are unde-fined. When the destination operand is a memory location, the low-order 16 bits of register CR0 are written to memory as a 16-bit quantity, regardless of the operand size. 
  2777. The SMSW instruction is only useful in operating-system software; however, it is not a privileged instruction and can be used in application programs. 
  2778. This instruction is provided for compatibility with the 286 processor. Programs and procedures intended to run on the Pentium Pro, Pentium, 486, and 386 processors should use the MOV (control registers) instruction to load the machine status word. '
  2779.  Flags affected
  2780. None. C
  2781.  Instruction size and timings
  2782.  operands   bytes                   286     386     486     Pentium
  2783.  r16         3                       2       2       2       4   NP
  2784.  mem16     3+d(0-2)                  3       3       3       4   NP
  2785.  Example
  2786.  smsw ax        ; Store Machine Status Word from AX
  2787. contents
  2788. screen
  2789.  STC - Set carry flag
  2790.  Description
  2791. Set the CF flag in the EFLAGS register. '
  2792.  Flags affected
  2793. The CF flag is set. The OF, ZF, SF, AF, and PF flags are unaffected. C
  2794.  Instruction size and timings
  2795.  bytes   8088    186     286     386     486     Pentium
  2796.   1       2       2       2       2       2       2   NP
  2797.  Example
  2798.  stc       ; Set carry flag
  2799. contents
  2800. screen
  2801.  STD - Set direction flag
  2802.  Description
  2803. Sets the DF flag in the EFLAGS register. When the DF flag is set to 1, string operations decrement the index registers (ESI and/or EDI). '
  2804.  Flags affected
  2805. The DF flag is set. The CF, OF, ZF, SF, AF, and PF flags are unaffected. C
  2806.  Instruction size and timings
  2807.  bytes   8088    186     286     386     486     Pentium
  2808.   1       2       2       2       2       2       2   NP
  2809.  Example
  2810.  std       ; Set direction flag
  2811. contents
  2812. screen
  2813.  STI - Set interrupt flag
  2814.  Description
  2815. Sets the interrupt flag (IF) in the EFLAGS register. After the IF flag is set, the processor begins responding to external, maskable interrupts after the next instruction is executed. The delayed effect of this instruction is provided to allow interrupts to be enabled just before returning from a procedure (or subroutine). For instance, if an STI instruction is followed by an RET instruction, the RET instruction is allowed to execute before external interrupts are recognized. This behavior allows external interrupts to be disabled at the beginning of a procedure and enabled again at the end of the procedure. If the STI instruction is followed by a CLI instruction (which clears the IF flag), the effect of the STI instruction is negated. q
  2816. The IF flag and the STI and CLI instructions have no affect on the generation of exceptions and NMI interrupts. '
  2817.  Flags affected
  2818. The IF flag is set to 1. C
  2819.  Instruction size and timings
  2820.  bytes   8088    186     286     386     486     Pentium
  2821.   1       2       2       2       3       5       7   NP
  2822.  Example
  2823.  sti       ; Set interrupt flag
  2824. contents
  2825. screen
  2826.  STOS - Store string data
  2827.  Description
  2828. Stores a byte, word, or doubleword from the AL, AX, or EAX register, respectively, into the destination operand. The destination operand is a memory location, the address of which is read from either the ES:EDI or the ES:DI registers (depending on the address-size attribute of the instruction, 32 or 16, respectively). The ES segment cannot be overridden with a segment over-ride prefix. 
  2829. At the assembly-code level, two forms of this instruction are allowed: the "explicit-operands" form and the "no-operands" form. The explicit-operands form (specified with the STOS mnemonic) is not supported by NASM. 
  2830. The no-operands form provides "short forms" of the byte, word, and doubleword versions of the STOS instructions. Here also ES:(E)DI is assumed to be the destination operand and the AL, AX, or EAX register is assumed to be the source operand. The size of the destination and source operands is selected with the mnemonic: STOSB (byte read from register AL), STOSW (word from AX), or STOSD (doubleword from EAX). 
  2831. After the byte, word, or doubleword is transferred from the AL, AX, or EAX register to the memory location, the (E)DI register is incremented or decremented automatically according to the setting of the DF flag in the EFLAGS register. (If the DF flag is 0, the (E)DI register is incremented; if the DF flag is 1, the (E)DI register is decremented.) The (E)DI register is incremented or decremented by 1 for byte operations, by 2 for word operations, or by 4 for doubleword operations. #
  2832. The STOSB, STOSW, and STOSD instructions can be preceded by the REP prefix for block loads of ECX bytes, words, or doublewords. More often, however, these instructions are used within a LOOP construct because data needs to be moved into the AL, AX, or EAX register before it can be stored. '
  2833.  Flags affected
  2834. None. C
  2835.  Instruction size and timings
  2836.  variations  bytes   8088    186     286     386     486     Pentium
  2837.  stosb        1      11      10       3       4       5       3   NP
  2838.  stosw        1      15      10       3       4       5       3   NP
  2839.  stosd        1       -       -       -       4       5       3   NP
  2840.  rep stosb    2      9+10n   6+9n    4+3n    5+5n    7+4n*   3+n  NP
  2841.  rep stosw    2      9+14n   6+9n    4+3n    5+5n    7+4n*   3+n  NP
  2842.  rep stosd    2       -       -       -      5+5n    7+4n*   3+n  NP
  2843.  * = 5 if n=0, 13 if n=1 (where n = count of bytes, words or dwords)
  2844.  Example
  2845.  rep stosb      ; Store ECX bytes from ax ax in ES:DI
  2846. contents
  2847. screen
  2848.  STR - Store task register (286+)
  2849.  Description
  2850. Stores the segment selector from the task register (TR) in the destination operand. The destination operand can be a general-purpose register or a memory location. The segment selector stored with this instruction points to the task state segment (TSS) for the currently running task. I
  2851. When the destination operand is a 32-bit register, the 16-bit segment selector is copied into the lower 16 bits of the register and the upper 16 bits of the register are cleared to 0s. When the destination operand is a memory location, the segment selector is written to memory as a 16-bit quantity, regardless of operand size. m
  2852. The STR instruction is useful only in operating-system software. It can only be executed in protected mode. '
  2853.  Flags affected
  2854. None. C
  2855.  Instruction size and timings
  2856.  operand     bytes                   286     386     486     Pentium
  2857.  r16          3                       2       2       2       2   NP
  2858.  mem16     3+d(0-2)                   3       2       3       2   NP
  2859.  Example
  2860.  str bx    ; Store task register to BX
  2861. contents
  2862. screen
  2863.  SUB - Integer subtraction
  2864.  Description
  2865. Subtracts the second operand (source operand) from the first operand (destination operand) and stores the result in the destination operand. The destination operand can be a register or a memory location; the source operand can be an immediate, register, or memory location. (However, two memory operands cannot be used in one instruction.) When an immediate value is used as an operand, it is sign-extended to the length of the destination operand format. &
  2866. The SUB instruction does not distinguish between signed or unsigned operands. Instead, the processor evaluates the result for both data types and sets the OF and CF flags to indicate a borrow in the signed or unsigned result, respectively. The SF flag indicates the sign of the signed result. '
  2867.  Flags affected
  2868. The OF, SF, ZF, AF, PF, and CF flags are set according to the result. C
  2869.  Instruction size and timings
  2870.  operands    bytes   8088    186     286     386     486     Pentium
  2871.  reg, reg     2       3       3       2       2       1       1   UV
  2872.  mem, reg  2+d(0,2)  24+EA   10       7       7       3       3   UV
  2873.  reg, mem  2+d(0,2)  13+EA   10       7       6       2       2   UV
  2874.  reg, imm  2+i(1,2)   4       4       3       2       1       1   UV
  2875.  mem, imm  2+d(0,2)  23+EA   16       7       7       3       3   UV*
  2876.             +i(1,2)
  2877.  acc, imm  1+i(1,2)   4       4       3       2       1       1   UV
  2878.  * = not pairable if there is a displacement and immediate
  2879.  Example
  2880.  sub eax, ebx           ; EAX = EAX - EBX
  2881. contents
  2882. screen
  2883.  TEST - Logical compare
  2884.  Description
  2885. Computes the bit-wise logical AND of first operand (source 1 operand) and the second operand (source 2 operand) and sets the SF, ZF, and PF status flags according to the result. The result is then discarded. '
  2886.  Flags affected
  2887. The OF and CF flags are cleared to 0. The SF, ZF, and PF flags are set according to the result. The state of the AF flag is undefined. C
  2888.  Instruction size and timings
  2889.  operands   bytes   8088    186     286     386     486     Pentium
  2890.  reg, reg    2       3       3       2       2       1       1   UV
  2891.  mem, reg 2+d(0,2)  13+EA   10       6       5       2       2   UV
  2892.  reg, mem 2+d(0,2)  13+EA   10       6       5       2       2   UV
  2893.  reg, imm 2+i(1,2)   5       4       3       2       1       1   UV
  2894.  mem, imm 2+d(0,2)  11+EA   10       6       5       2       2   UV*
  2895.            +i(1,2)
  2896.  acc, imm 1+i(1,2)   4       4       3       2       1       1   UV
  2897.  * = not pairable if there is a displacement and immediate
  2898.  Example
  2899.  test eax, ebx          ; Test values in EAX and EBX and set flags accordingly
  2900. contents
  2901. screen
  2902.  UD2 - Undefined instruction
  2903.  Description
  2904. Generates an invalid opcode. This instruction is provided for software testing to explicitly generate an invalid opcode. The opcode for this instruction is reserved for this purpose. g
  2905. Other than raising the invalid opcode exception, this instruction is the same as the NOP instruction. '
  2906.  Flags affected
  2907. None. C
  2908.  Instruction size and timings
  2909. Not available. 
  2910.  Example
  2911.  UD2       ; Raise invalid opcode exception
  2912. contents
  2913. screen
  2914.  VERR/VERW - Verify a segment for reading/writing (286+)
  2915.  Description
  2916. Verifies whether the code or data segment specified with the source operand is readable (VERR) or writable (VERW) from the current privilege level (CPL). The source operand is a 16-bit register or a memory location that contains the segment selector for the segment to be verified. If the segment is accessible and readable (VERR) or writable (VERW), the ZF flag is set; otherwise, the ZF flag is cleared. Code segments are never verified as writable. This check cannot be performed on system segments. ;
  2917. To set the ZF flag, the following conditions must be met: >
  2918.  The segment selector is not null.
  2919.  The selector must denote a descriptor within the bounds of the descriptor
  2920.    table (GDT or LDT).
  2921.  The selector must denote the descriptor of a code or data segment (not
  2922.    that of a system segment or gate).
  2923.  For the VERR instruction, the segment must be readable.
  2924.  For the VERW instruction, the segment must be a writable data segment.
  2925.  If the segment is not a conforming code segment, the segment's DPL must be
  2926.    greater than or equal to (have less or the same privilege as) both the CPL
  2927.    and the segment selector's RPL.
  2928. The validation performed is the same as is performed when a segment selector is loaded into the DS, ES, FS, or GS register, and the indicated access (read or write) is performed. The segment selector's value cannot result in a protection exception, enabling the software to anticipate possible segment access problems. '
  2929.  Flags affected
  2930. The ZF flag is set to 1 if the segment is accessible and readable (VERR) or writable (VERW); otherwise, it is cleared to 0. C
  2931.  Instruction size and timings
  2932.  VERR
  2933.  operand    bytes                   286     386     486     Pentium
  2934.  r16         3                      14      10      11       7   NP
  2935.  mem16    3+d(0,2)                  16      11      11       7   NP
  2936.  VERW
  2937.  operand    bytes                   286     386     486     Pentium
  2938.  r16         3                      14      15      11       7   NP
  2939.  mem16    3+d(0,2)                  16      16      11       7   NP
  2940.  Example
  2941.  verr ax        ; Verify segment given in AX is readable
  2942.  verw ax        ; Verify segment given in AX is writeable
  2943. contents
  2944. screen
  2945.  WAIT - Wait for coprocessor
  2946.  Description
  2947. Causes the processor to check for and handle pending, unmasked, floating-point exceptions before proceeding. )
  2948. This instruction is useful for synchronizing exceptions in critical sections of code. Coding a WAIT instruction after a floating-point instruction insures that any unmasked floating-point exceptions the instruction may raise are handled before the processor can modify the instruction's results. '
  2949.  Flags affected
  2950. The C0, C1, C2, and C3 FPU flags are undefined. C
  2951.  Instruction size and timings
  2952.   bytes   8088    186     286     386     486     Pentium
  2953.    1       4       6       3       6      1-3      1   NP
  2954.  Example
  2955.  wait           ; Wait for coprocessor
  2956. contents
  2957. screen
  2958.  WBINVD -  Write back and invalidate cache (486+)
  2959.  Description
  2960. Writes back all modified cache lines in the processor's internal cache to main memory and inval-idates (flushes) the internal caches. The instruction then issues a special-function bus cycle that directs external caches to also write back modified data and another bus cycle to indicate that the external caches should be invalidated. 
  2961. After executing this instruction, the processor does not wait for the external caches to complete their write-back and flushing operations before proceeding with instruction execution. It is the responsibility of hardware to respond to the cache write-back and flush signals. 
  2962. The WDINVD instruction is a privileged instruction. When the processor is running in protected mode, the CPL of a program or procedure must be 0 to execute this instruction. This instruction is also a serializing instruction. o
  2963. In situations where cache coherency with main memory is not a concern, software can use the INVD instruction. '
  2964.  Flags affected
  2965. None. C
  2966.  Instruction size and timings
  2967.  bytes                                   486     Pentium
  2968.   2                                       5    2000+  NP
  2969.  Example
  2970.  wbinvd          ; Write back and invalidate cache
  2971. contents
  2972. screen
  2973.  WRMSR - Write to Model Specific Register (Pentium+)
  2974.  Description
  2975. Writes the contents of registers EDX:EAX into the 64-bit model specific register (MSR) specified in the ECX register. The high-order 32 bits are copied from EDX and the low-order 32 bits are copied from EAX. Always set the undefined or reserved bits in an MSR to the values previously read. 
  2976. This instruction must be executed at privilege level 0 or in real-address mode; otherwise, a general protection exception will be generated. Specifying a reserved or unimplemented MSR address in ECX will also cause a general protection exception. 
  2977. When the WRMSR instruction is used to write to an MTRR, the TLBs are invalidated, including the global entries. (MTRRs are an implementation-specific feature of the Pentium Pro processor.) 
  2978. The MSRs control functions for testability, execution tracing, performance monitoring and machine check errors. The WRMSR instruction is a serializing instruction. x
  2979. The CPUID instruction should be used to determine whether MSRs are supported (EDX[5]=1) before using this instruction. 
  2980. The MSRs and the ability to read them with the WRMSR instruction were introduced into the Intel Architecture with the Pentium processor. Execution of this instruction by an Intel Architecture processor earlier than the Pentium processor results in an invalid opcode exception. '
  2981.  Flags affected
  2982. None. C
  2983.  Instruction size and timings
  2984.  bytes                                           Pentium
  2985.   2                                             30-45 NP
  2986.  Example
  2987.  wrmsr          ; Write EDX:EAX to MSR specified by ECX
  2988. contents
  2989. screen
  2990.  XADD - Exchange and add (486+)
  2991.  Description
  2992. Exchanges the first operand (destination operand) with the second operand (source operand), then loads the sum of the two values into the destination operand. The destination operand can be a register or a memory location; the source operand is a register. 2
  2993. This instruction can be used with a LOCK prefix. 
  2994. Intel Architecture processors earlier than the 486 processor do not recognize this instruction. If this instruction is used, you should provide an equivalent code sequence that runs on earlier processors. '
  2995.  Flags affected
  2996. The CF, PF, AF, SF, ZF, and OF flags are set according to the result of the addition, which is stored in the destination operand. C
  2997.  Instruction size and timings
  2998.  operands   bytes                                   486     Pentium
  2999.  reg, reg    3                                       3       3   NP
  3000.  mem, reg   3+d(0-2)                                 4       4   NP
  3001.  Example
  3002.  xadd eax, ebx          ; Exchange and add EAX and EBX
  3003. contents
  3004. screen
  3005.  XCHG - Exchange register/memory with register
  3006.  Description
  3007. Exchanges the contents of the destination (first) and source (second) operands. The operands can be two general-purpose registers or a register and a memory location. If a memory operand is referenced, the processor's locking protocol is automatically implemented for the duration of the exchange operation, regardless of the presence or absence of the LOCK prefix or of the value of the IOPL. p
  3008. This instruction is useful for implementing semaphores or similar data structures for process synchronization. ]
  3009. The XCHG instruction can also be used instead of the BSWAP instruction for 16-bit operands. '
  3010.  Flags affected
  3011. None. C
  3012.  Instruction size and timings
  3013.  operands   bytes   8088    186     286     386     486     Pentium
  3014.  reg, reg    2       4       4       3       3       3       3   NP
  3015.  reg, mem  2+d(0-2)  25+EA  17       5       5       5       3   NP
  3016.  mem, reg  2+d(0-2)  25+EA  17       5       5       5       3   NP
  3017.  acc, reg    1       3       3       3       3       3       2   NP
  3018.  reg, acc    1       3       3       3       3       3       2   NP
  3019.  Note: in this case acc = AX or EAX only
  3020.  Example
  3021.  xchg ax, dx    ; AX = DX and DX = original AX
  3022. contents
  3023. screen
  3024.  XLAT/XLATB - Table look-up translation
  3025.  Description
  3026. Locates a byte entry in a table in memory, using the contents of the AL register as a table index, then copies the contents of the table entry back into the AL register. The index in the AL register is treated as an unsigned integer. The XLAT and XLATB instructions get the base address of the table in memory from either the DS:EBX or the DS:BX registers (depending on the address-size attribute of the instruction, 32 or 16, respectively). (The DS segment may be overridden with a segment override prefix.) h
  3027. At the assembly-code level, two forms of this instruction are allowed: the "explicit-operand" form and the "no-operand" form. The explicit-operand form (specified with the XLAT mnemonic) allows the base address of the table to be specified explicitly with a symbol. This explicit-operands form is provided to allow documentation; however, note that the documentation provided by this form can be misleading. That is, the symbol does not have to specify the correct base address. The base address is always specified by the DS:(E)BX registers, which must be loaded correctly before the XLAT instruction is executed. 
  3028. The no-operands form (XLATB) provides a "short form" of the XLAT instructions. Here also the processor assumes that the DS:(E)BX registers contain the base address of the table. '
  3029.  Flags affected
  3030. None. C
  3031.  Instruction size and timings
  3032.  bytes   8088    186     286     386     486     Pentium
  3033.   1      11      11       5       5       4       4   NP
  3034.  Example
  3035.  xlat      ; Equivalent to MOV AL, [BX + AL]
  3036. contents
  3037. screen
  3038.  XOR - Logical exclusive OR
  3039.  Description
  3040. Performs a bitwise exclusive OR (XOR) operation on the destination (first) and source (second) operands and stores the result in the destination operand location. The source operand can be an immediate, a register, or a memory location; the destination operand can be a register or a memory location. (However, two memory operands cannot be used in one instruction.) Each bit of the result is 1 if the corresponding bits of the operands are different; each bit is 0 if the corresponding bits are the same. '
  3041.  Flags affected
  3042. The OF and CF flags are cleared; the SF, ZF, and PF flags are set according to the result. The state of the AF flag is undefined. C
  3043.  Instruction size and timings
  3044.  operands    bytes   8088    186     286     386     486     Pentium
  3045.  reg, reg     2       3       3       2       2       1       1   UV
  3046.  mem, reg  2+d(0,2)  24+EA   10       7       7       3       3   UV
  3047.  reg, mem  2+d(0,2)  13+EA   10       7       6       2       2   UV
  3048.  reg, imm  2+i(1,2)   4       4       3       2       1       1   UV
  3049.  mem, imm  2+d(0,2)  23+EA   16       7       7       3       3   UV*
  3050.             +i(1,2)
  3051.  acc, imm  1+i(1,2)   4       4       3       2       1       1   UV
  3052.  * = not pairable if there is a displacement and immediate
  3053.  Example
  3054.  xor eax, ebx           ; EAX = EAX xor EBX
  3055. contents
  3056. screen
  3057.  N!N"N#N$N%N&N'N(N)N*N+N,N-N.N/N0N1N2N3N4N5N6N7N8N9N:N;N<N=N>N?N@NANBNCNDNENFNGNHNINJNKNLNMNNNONPNQNRNSNTNUNVNWNXNYNZN[N\N]N^N_N`NaNbNcNdNeNfNgNhNiNjNkNlNmNnNoNpNqNrNsNtNuNvNwNxNyNzN{N|N}N~N
  3058.