Upload
asawari-dudwadkar
View
214
Download
0
Embed Size (px)
Citation preview
7/29/2019 Instruction 86
1/7
INSTRUCTION SET [8086]
* Following are the Data Transfer Types:
1. Move contents of a register, or contents of a memory location, or immediate data toregister or memory location.
2. Data transfer between a segment register and a register.
3. PUSH & POP instructions
4. Exchange instructions.
5. Data transfer with I/O ports
General Purpose Instructions:
Instruction/Syntax Explanations/Example
1 MOVMOV [Dest.], [Source] Copy a byte or a wordBoth source and destination should be of same type (byte
or word)
Ex. MOV AX,BX, MOV CL,0F2H,
MOV AX,25H;
MOV WORD PTR 0F2H[BP],34H
MOV DS,BX
2 PUSH
PUSH [source]
Push the contents of register onto stack top
Ex. PUSH SI, PUSH DS,
PUSH AX
3 POP
POP Destination
Pop to a register from stack top
Ex. POP SI, POP DS,POP AX
4 PUSHF Push the contents of FLAG register onto the stack top
5 POPF Pop the stack top to the FLAG register
6 XCHG
XCHG [Dest.], [Source]
Exchange
Interchange the contents of two registers
Ex. ECHG AX,SI, XCHG BX,43h[SI]
7 XLAT OR XLATB
XLAT
Translate
Translate byte from one code to another code
Ex. MOV BX,ASCII_TABLE
XLAT B
This will require data in AL with ASCII from the
lookup table.
Input / Output Instructions:
8 IN
IN Acc., [port add.]
Copy a data from port to accumulator
Ex. IN AL,OAH,IN AX,22H
9 OUT
OUT [port add.], Acc.
Output a byte or word to a port
Ex. OUT 44H,AL,OUT 22H,AX
7/29/2019 Instruction 86
2/7
Address Object Instructions:
Instruction/Syntax Explanations/Example10 LEA
LEA [Dest.], [Source]
Load effective Address
Loads effective address of a memory location into aregister
Ex. LEA BX,83H[SI],LEA DX,MSG1
11 LDS
LDS [Dest.], [Source]
Load register and DS with words from memory.
(REG) Source
(DS) Source + 2
Ex. LDS SI,[200]
LDS BX,82H[SI]
12 LES
LES [Dest.], [Source]
Load registers and ES with words from memory.
(REG) source
(ES)source + 2
Ex. LES AX, [12345]
LES BX,42H[SI]
13 LAHF
LAHF
Load AH with LS byte of FLAG Register
LS of FLAG register.
(AH)
14 SAHF
SAHF
Store AH contents in the LS byte of FLAG register.
(AH)
Arithmetic Group15 AAA
AAA
ASCII adjust for addition.
Ex. ADD AL, BL; if AL+BL=67H, then
AAA; AL contains 07H
16 DAA
DAA
Decimal adjust AL after BCD addition.
DAA operates only on [AL] register
Ex. ADD AL, BL; 59+34=>8DH
DAA; Adds O6 to AL as lower nibble value is greater
than 9
17 NEG
NEG destination
Negate (Forms 2's complement).
Ex. NEG BX; Replaces word in BX with its 2'scomplement
18 AAS
AAS
ASCII adjust for subtraction.
Ex. SUB AL, DL;
34H-38H=>FCH in AL
AAS;
As lower nibble C is greater than 9 it subtracts
6 from AL and CF is set.
S Z U A U P U C
S Z U A U P U C
7/29/2019 Instruction 86
3/7
Instruction/Syntax Explanations/Example19 DAS
DAS
Decimal adjust AL after BCD subtraction.
If lower nibble after subtraction is greater than 9, then
subtract 6
from AL (OR if CF is set)Ex. SUB AL, BL;
78H-93H=>E5 with
DAS;
borrow, CF is set
20 AAM
AAM
BCD adjust after multiplication.
Ex. MUL BL;
AL*BL=AX (Say 0020H)
AAM;
AX=0302H
21 CBW
CBW
Convert signed byte to signed word CBW produces a
double length dividend from a byte prior to performing
division.
22 CWD
CWD
Convert signed byte to signed double word.
CWD produces a double length dividend from a word
prior to performing division.
23 AAD
AAD
BCD to binary convert before division.
AAD converts two unpacked BCD digits in AH & AL to
the equivalent binary number
Logical Instructions
24 TEST
TEST [Dest.], [Source]
AND operands to update flags.
TEST instruction performs logical AND of two operands,
updates flag, but does not return result i.e. neither operand
is changed.
Ex. TEST SI, DI
TEST AL, 0100 0100b
25 RCL
RCL [Dest.], [Source]
Rotate operand around to the left through carry.
By default CL register is used.
Ex: RCL AL, CL
26 RCR
RCR [Dest.], [Source]
Rotate operand around to the right through carry.
By default CL register is used.
Ex: RCR AL, CL
Cy MSB
LSB
Cy MSB
LSB
7/29/2019 Instruction 86
4/7
Instruction/Syntax Explanations/Example27 SHL / SAL
SHL/SAL [Opr], [Cnt]
Shift logical left / shift Arithmetic left.
28 SHR
SHR [Opr], [Cnt]
Shift logical right.
29 SAR
SAR [Opr], [Cnt]
Shift arithmetic right.
Here new MSB = old MSB
Branch Instructions
30 CALL Call procedure
31 RET Return from procedure
32 JMP Jump to specified location
Conditional Transfer Instructions
33 JA / JNBE Jump if above / not below or equal
34 JAE / JNB Jump if above or equal / not below
35 JG / JNLE Jump if greater / not less or equal
36 JLE / JNG Jump if less or equal / not greater
37 JNP / JPO Jump if no parity / odd parity
38 LOOPE / LOOPZ Jump if equal / zero
39 LOOPNE / LOOPNZ Loop if not equal / not zero
40 JCXZJCXZ [location]
Jump if CX is equal to zero.If CX contents are zero, then transfer control to specified
location.
Ex: JCXZ skip_label
* All the BRANCH instructions must have a single operand specifying the location where to
branch. Generally we use LABELS to jump to that particular location depending on the
condition instead of specifying the exact memory location.
Cy MSB LSB
0
CyMSB LSB
0
Cy
MSB
LSB
7/29/2019 Instruction 86
5/7
Instruction/Syntax Explanations/Example41 INT
INT [Interrupt type]
Interrupt program execution.
Int. type number should be 00H to FFH
Ex: INT 01H, INT 21H
42 IRET Interrupt ReturnIRET transfers control back to the point of interruption
by popping IP, CS & flags from the stack.
Process Control Instructions
43 CLC Clear the Carry flag
44 CMC Complement the Carry flag
45 STC Set the Carry flag
46 CLA Clear Direction flagUsed for string instructions to auto-increment SI & DI
47 STD Set Direction flag
Used for string instructions to auto-decrement SI & DI
48 CLI Clear Interrupt flag
49 STI Set Interrupt flag
50 NOP No Operation
Used for software delays
51 WAIT Wait for test signal at Interrupt signal.
When WAIT is executed 8086 goes into idle condition. It
keeps checking TEST, INTR & NMI52 ESC
ESC [ExtOp],[Source]
Escape
Escape provides a means for an external processor to
obtain an Opcode & possibly a memory operand from
8086
Ex: ESC 6, ARRAY[SI]
ESC 20, AL
53 LOCK Assert bus lock signal.
It is not an instruction but a prefix to be used with
instructions.
Ex: LOCK XCHG FLAG, AL
String Instructions
Register SI & DI must be initialized to point to the source & destination strings before
executing the string instructions.
54 MOVS
MOVS [Dest.],[Source]
OrMOVSB / MOVSW
Move string byte or string word.
Transfers a byte or word from source string to destination
string.
Ex: MOVSB ;Move (DI) (SI)
7/29/2019 Instruction 86
6/7
Instruction/Syntax Explanations/Example55 CMPS
CMPS [Dest.],[Source]
OrCMPSB / CMPSW
Compare string byte or string word.
It compares byte/word of one string with byte/word of
another string.
Flags affected CF, SF, IF
Ex: CMPS Str1, Str256 SCAS
SCAS [Dest_Str]
OR SCASB,SCASW
Scan a string byte or string word.
SCAS compares byte AL or word in AX with a byte or
word pointed by DI in ES.Destination has to be in
ES.SCAS updates FLAGS but doesnot alter destination
string or accumulator.
EX. SCAS Input_str,
LEA DI,BOFF1
MOV AL,ODH
SCASB
57 LODS
LODS Source_string
OR LODSB,LODSW
Load string byte in AL or load string word in AX.LODS
transfers the byte or word string element addressed by SI
to register AL or AX.
EX. MOV SI,Offset source_str
CLD
LODSB
58 STOS
STOS [Dest_str.]
OR STOSB,STOSW
Store byte or word in string STOS transfers a byte or
word from register AL or AX to the string element
addressed by DI.
EX. MOV DI,Offset atr1
CLD
MOV AX,00HSTOSW
59 LODS
LODS [Src_str.]
OR LODSB,LODSW
Load string byte in AL or load string word in AX.LODS
transfers the byte or word string element addressed by SI
to register AL or AX.
EX.MOV SI,Offset source_str
CLD
LODSB
60 STOS
STOS [Dest_str.]
OR STOSB,STOSW
Store byte or word in string STOS transfers a byte or
word from register AL or AX to the string element
addressed by DI.
EX. MOV DI,Offset atr1CLD
MOV AX,00H
STOSW
61 REP
REP
Repeat string instruction until specified condition exists.
EX. LEA SI,Service_str
LEA DI,Dest_str
MOV CX,20H
CLD
REP MOVSW
7/29/2019 Instruction 86
7/7
Instruction/Syntax Explanations/Example62 REPE / REPZ Repeat while equal/Repeat while not zero.
This will cause string instructions to be repeated as long
as ZF = 0 & CX != 0.
EX. LEA DI,Str1MOV AL,ODH
CLD
MOV CX,25H
REPE SCASB
63 REPNE / REPNZ Repeat while not equal/Repeat while not zero.
This will cause string instructions to be repeated as long
as ZF = 0 & CX != 0
EX. MOV DI,Offset Str1
MOV CX,100H
CLD
RPNE SCASW
By Asawari D
Dept. of Electronics VESIT ,Mumbai