Download presentation

1
80x86 Instruction Set Dr. Qiang Lin

2
Overview 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

3
**80x86 Transfer & Set Instructions 1**

4
**Transfer Instructions Examples 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]

5
**Set Instructions That Test Flags**

6
**Set Instructions for Unsigned Comparisons**

7
**Set Instructions for Signed Comparisons**

8
**Set Instructions Example**

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

9
**80x86 Transfer Instructions 2**

10
**Transfer Instructions Examples 2**

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

11
**80x86 String (Transfer) Instructions 3**

12
**80x86 Arithmetic Instructions 1**

13
**Arithmetic Instructions Examples 1**

Example 1: J = K + M MOV AX, K ADD AX,M MOV J, AX Example 2: J = K + M + N + P ADD AX,N ADD AX,P

14
**Arithmetic Instructions Examples 2**

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 or ADD AX, M

15
**80x86 Arithmetic Instructions 2**

16
**Arithmetic Instructions Examples 3**

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

17
**80x86 Arithmetic Instructions 3**

18
**SHL\SAL\SAR Instructions**

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

19
**RCL\RCR\ROL\ROR Instructions**

20
80x86 Logic Instructions 1

21
80x86 Logic Instructions 2 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

22
**SHR\SHLD\SHRD Instructions**

Provide double precision shift left and right operations, respectively Available only on 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 representing a year ( ) bx contains a value in the range representing a day, and cx contains a value in the range 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 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
**Jump Instructions Examples 1**

POP AX JMP AX CALL SUB CALL DwordTbl[BX] SUB: PUSH AX PUSH BX …. POP BX RET

Similar presentations

© 2019 SlidePlayer.com Inc.

All rights reserved.

To make this website work, we log user data and share it with processors. To use this website, you must agree to our Privacy Policy, including cookie policy.

Ads by Google