CS320 x86 Instruction Summary Sheet

Version 1.2


x86 Flags Register: Bit: 15 14 13 12 11 10 09 08 07 06 05 04 03 02 01 00 OF DF IF TF SF ZF AF PF CF

x86 Instruction Set

  1. MOV <destination>,<source>
  2. MOVZX <destination>,<source>
  3. MOVSX <destination>,<source>
  4. LAHF ; load the low byte of EFLAGS into AH
  5. SAHF ; store the value of AH into low byte of EFLAGS
  6. XCHG <destination>,<source>
  7. INC <destination>
  8. DEC <destination>
  9. ADD <destination>,<source>
  10. SUB <destination>,<source>
  11. LOOP <short-label>
  12. NEG <destination>
  13. JMP <target>
  14. PUSH <source> [<comment>]
  15. POP <destination> [<comment>]
  16. PUSHA [<comment>]
  17. POPA [<comment>]
  18. PUSHAD [<comment>]
  19. POPAD [<comment>]
  20. PUSHF
  21. POPF
  22. CALL <target>
  23. RET [<popvalue>]
  24. AND <destination>,<source>
  25. OR <destination>,<source>
  26. XOR <destination>,<source>
  27. NOT <destination>
  28. TEST <destination>,<source>
    <op-code> <short-label>
  29. JA/JNBE (unsigned)
  30. JAE/JNB
  31. JB/JNAE
  32. JBE/JNA
  33. JE/JZ
  34. JNE/JNZ
  35. JG/JNLE (signed)
  36. JGE/JNL
  37. JL/JNGE
  38. JLE/JNG
  39. JC (flags register)
  40. JNC
  41. JO
  42. JNO
  43. JS
  44. JNS
  45. JP/JPE
  46. JNP/JPO
  47. CMP <destination>,<source>
  48. LOOPE <short-label> LOOPZ <short-label>
  49. LOOPNE <short-label> LOOPNZ <short-label>
  50. MUL <destination> (unsigned)
  51. IMUL <destination> (signed)
  52. DIV <destination> (unsigned) AX-quotient, DX-remainder
  53. IDIV <destination> (signed)
  54. SAR <destination>,<shiftcount> - Arithmetic right-shift (signed)
  55. SAL <destination>,<shiftcount>- Arithmetic left-shift (signed)
  56. SHR <destination>,<shiftcount>- Logical right-shift (unsigned)
  57. SHL <destination>,<shiftcount>- Logical left-shift (unsigned)
  58. ROR <destination>,<shiftcount>- right rotate
  59. ROL <destination>,<shiftcount>- left rotate
  60. RCR <destination>,<shiftcount>- right rotate-through carry
  61. RCL <destination>,<shiftcount>- left rotate-through carry
  62. CALL <target>
  63. RET
  64. CLD ; increment
  65. STD ; decrement
  66. MOVSB ; ds:si -> es:di
  67. MOVSW ; ds:si -> es:di
  68. LODSB ; al <- ds:si
  69. LODSW ; ax <- ds:si
  70. STOSB ; al -> es:di
  71. STOSW ; ax -> es:di
  72. CMPSB ; ds:si - es:di
  73. CMPSW ; ds:si - es:di
  74. SCASB ; al - es:di
  75. SCASW ; ax - es:di
  76. REP <string-op>
  77. REPE <string-op> REPZ <string-op>
  78. REPNE <string-op> REPNZ <string-op>
  79. IRET
  80. INT <int-type>

Library Routines

Clrscr - clears console Crlf - outputs carriage return / line feed Delay - set eax to the number of milliseconds to delay DumpRegs - dumps the registers to the screen GetMseconds - number of milliseconds elapsing since midnight in eax Gotoxy - dh = row (0 - 24) dl = column (0 - 79) Random32 - 32-bit pseudorandom integer in eax Randomize - sets the random seed based on the time of day RandomRange - produces random number between 0 to (n - 1) where n is eax ReadChar - returns character in al ReadHex - returns up to 8 HEX digits in eax ReadInt - returns 32-bit signed int in eax ReadString - edx points to the beginning of the string ecx is the maximum number of characters that can be input eax is the number of characters actually read WaitMsg - outputs Press [Enter] to continue... and waits for the user to hit return WriteBin - ouputs the value in eax in binary form WriteChar - outputs character represented in al register WriteDec - outputs 32-bit unsigned integer in eax in decimal with no leading zeros WriteHex - outputs 32-bit unsigned integer in eax in hex with leading zeros added if necessary to make 8 hex digits WriteInt - outputs 32-bit signed integer in eax with a leading sign and no leading zeros WriteString - point edx to beginning of null terminated string

Note1: I do not show the flags for the jump instructions. You should know when to use what jump and if I have a test question involving the flags registers, I'll tell you what the flags are.