1 / 29

80x86 Instruction Set

80x86 Instruction Set. Dr. Qiang Lin. Most of assembler instructions presented are supported by all of the following Intel processors: 80186, 80286, 80386, 80486, Pentium (80586) Five major instruction categories: Transfer and Set Arithmetic Logic Jump Miscellaneous. Overview.

issac
Download Presentation

80x86 Instruction Set

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. 80x86 Instruction Set Dr. Qiang Lin

  2. Most of assembler instructions presented are supported by all of the following Intel processors: 80186, 80286, 80386, 80486, Pentium (80586) Five major instruction categories: Transfer and Set Arithmetic Logic Jump Miscellaneous Overview

  3. 80x86 Transfer & Set Instructions 1

  4. Example 1: MOV AX,0006h ; Move immediate data to AX register MOV BX,AX ; Move AX register data to BX register This small program moves the value of 0006H to the AX register, then it moves the content of AX (0006h) to the BX register Example 2: MOV AX,2000h ; Move immediate data to AX register MOV DS,AX ; Load DS segment register MOV SI, 100h ; Load immediate data to SI index register MOV DI, 120h ; Load immediate data to DI index register MOV CX, 10h ; Load immediate data to CX register MOV AH, [SI], ; Move memory data pointed by [SI] to AH register MOV [DI], AH ; Move AH register to memory located at [DI] Transfer Instructions Examples 1

  5. Set Instructions That Test Flags

  6. Set Instructions for Unsigned Comparisons

  7. Set Instructions for Signed Comparisons

  8. Bool := ((A <= B) and (D = E)) or (F <> G) MOV AX, A CMP AX, B SETLE BL MOV AX, D CMP AX, E SETE BH AND BL, BH MOV AX, F CMP AX, G SETNE BH OR BL, BH MOV Bool, BH Set Instructions Example

  9. 80x86 Transfer Instructions 2

  10. Example 1: PUSH DS ; Push current DS content to stack MOV AX,0 ; Move immediate data to AX register PUSH AX ; Push 0 to stack MOV AL, 0A1H CBW CWD Example 2: IN AL, 60h ; Read keyboard port MOV DX,378h ; Point at LPT1: data port IN AL, DX ; Read data from printer port INC AX ; Bump ASCII code by one OUT DX, AL ; Write data in AL to printer port Transfer Instructions Examples 2

  11. 80x86 String (Transfer) Instructions 3

  12. 80x86 Arithmetic Instructions 1

  13. Example 1: J = K + M MOV AX, K ADD AX,M MOV J, AX Example 2: J = K + M + N + P MOV AX, K ADD AX,M ADD AX,N ADD AX,P MOV J, AX Arithmetic Instructions Examples 1

  14. Example 1: J = K - J MOV AX, K SUB J, AX MOV J, AX Example 1: J = J - (K + M) MOV AX, J SUB AX, K SUB AX, M MOV J, AX or MOV AX, K ADD AX, M SUB J, AX Arithmetic Instructions Examples 2

  15. 80x86 Arithmetic Instructions 2

  16. Example 1: ((J*7 + K) * 6 + M) * 2 MOV BX, J IMUL BX, 7 ADD BX, K IMUL BX, 6 ADD BX, M ADD BX, BX Example 2: J = K/ M (unsigned) MOV AX, K MOV DX, 0 ; Zero extend unsigned value in AX to DX DIV M MOV J, AX Arithmetic Instructions Examples 3

  17. 80x86 Arithmetic Instructions 3

  18. SHL/SAL Move each bit in destination operand one bit to left by No. of times specified by count operand Zeros fill vacated positions at L.O. bit; H.O. bit shifts into carry flag SHL AH, 4 ; Move L.O. bits to H.O. position SAR Move each bit in destination operand one bit to right by No. of times specified by count operand H.O. bit fills vacated position at H.O. bit; L.O. bit shifts into carry flag SAR AH, 4 SHL\SAL\SAR Instructions

  19. RCL RCR ROL ROR RCL\RCR\ROL\ROR Instructions

  20. 80x86 Logic Instructions 1

  21. Except NOT, AND, OR and XOR instructions affect flags as follows: Clear carry flag Clear overflow flag Set zero flag if result is zero and clear it otherwise Copy H.O. bit of result into sign flag Set parity flag according to parity (number of one bits) in result Scramble auxiliary carry flag NOT instruction does not affect any flags 80x86 Logic Instructions 2

  22. SHR\SHLD\SHRD Instructions • SHR • SHLD/SHRD • Provide double precision shift left and right operations, respectively • Available only on 80386 and later processors with forms of SHLD operand1, operand2, immediate SHLD operand1, operand2, CL SHRD operand1, operand2, immediate SHRD operand1, operand2, CL

  23. SHRD Instruction Example • Let • ax contains a value in range 0..99 representing a year (1900..1999) • bx contains a value in the range 1..31 representing a day, and • cx contains a value in the range 1..12 representing a month • Pack these data into dx as follows: SHRD DX, AX, 7 SHRD DX, BX, 5 SHRD DX, CX, 4

  24. 80x86 Miscellaneous Instructions • LEA - Loads specified 16 or 32 bit general purpose register with effective • address of the specified memory location using formats of: • LEA reg16, mem or LEA reg32, mem(only for 80386 or later processors) • Examples: • LEA AX, [BX] • LEA BX, 3[BX] • LEA AX, 3[BX] • LEA BX, 4[BP+SI] • LEA AX, -123[DI]

  25. 80x86 General Jump Instructions 1

  26. 80x86 General Jump Instructions 2

  27. 80x86 Unsigned Jump (Cardinal) Instructions

  28. 80x86 Signed Jump (Integer) Instructions

  29. Example POP AX JMP AX Example CALL SUB CALL DwordTbl[BX] Example SUB: PUSH AX PUSH BX …. POP BX POP AX RET Jump Instructions Examples 1

More Related