CS320 x86 Instruction Summary Sheet

Version 1.1


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. CALL <target>
  21. RET [<popvalue>]
  22. AND <destination>,<source>
  23. OR <destination>,<source>
  24. XOR <destination>,<source>
  25. NOT <destination>
  26. TEST <destination>,<source>
    <op-code> <short-label>
  27. JA/JNBE (unsigned)
  28. JAE/JNB
  29. JB/JNAE
  30. JBE/JNA
  31. JE/JZ
  32. JNE/JNZ
  33. JG/JNLE (signed)
  34. JGE/JNL
  35. JL/JNGE
  36. JLE/JNG
  37. JC (flags register)
  38. JNC
  39. JO
  40. JNO
  41. JS
  42. JNS
  43. JP/JPE
  44. JNP/JPO
  45. CMP <destination>,<source>
  46. LOOPE <short-label> LOOPZ <short-label>
  47. LOOPNE <short-label> LOOPNZ <short-label>
  48. MUL <destination> (unsigned)
  49. IMUL <destination> (signed)
  50. DIV <destination> (unsigned) AX-quotient, DX-remainder
  51. IDIV <destination> (signed)
  52. SAR <destination>,<shiftcount> - Arithmetic right-shift (signed)
  53. SAL <destination>,<shiftcount>- Arithmetic left-shift (signed)
  54. SHR <destination>,<shiftcount>- Logical right-shift (unsigned)
  55. SHL <destination>,<shiftcount>- Logical left-shift (unsigned)
  56. ROR <destination>,<shiftcount>- right rotate
  57. ROL <destination>,<shiftcount>- left rotate
  58. RCR <destination>,<shiftcount>- right rotate-through carry
  59. RCL <destination>,<shiftcount>- left rotate-through carry
  60. CALL <target>
  61. RET
  62. CLD ; increment
  63. STD ; decrement
  64. MOVSB ; ds:si -> es:di
  65. MOVSW ; ds:si -> es:di
  66. LODSB ; al <- ds:si
  67. LODSW ; ax <- ds:si
  68. STOSB ; al -> es:di
  69. STOSW ; ax -> es:di
  70. CMPSB ; ds:si - es:di
  71. CMPSW ; ds:si - es:di
  72. SCASB ; al - es:di
  73. SCASW ; ax - es:di
  74. REP <string-op>
  75. REPE <string-op> REPZ <string-op>
  76. REPNE <string-op> REPNZ <string-op>
  77. IRET
  78. 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.