Вы находитесь на странице: 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 to register 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
1 MOV MOV [Dest.], [Source]

Explanations/Example
Copy a byte or a word Both 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 Push the contents of register onto stack top Ex. PUSH SI, PUSH DS, PUSH AX Pop to a register from stack top Ex. POP SI, POP DS, POP AX Push the contents of FLAG register onto the stack top Pop the stack top to the FLAG register Exchange Interchange the contents of two registers Ex. ECHG AX,SI, XCHG BX,43h[SI] 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.

2 3 4 5 6 7

PUSH PUSH [source] POP POP Destination PUSHF POPF XCHG XCHG [Dest.], [Source] XLAT OR XLATB XLAT

Input / Output Instructions:


8 9 IN IN Acc., [port add.] OUT OUT [port add.], Acc. Copy a data from port to accumulator Ex. IN AL,OAH,IN AX,22H Output a byte or word to a port Ex. OUT 44H,AL,OUT 22H,AX

Address Object Instructions:


Instruction/Syntax
10 LEA LEA [Dest.], [Source] LDS LDS [Dest.], [Source]

Explanations/Example
Load effective Address Loads effective address of a memory location into a register Ex. LEA BX,83H[SI],LEA DX,MSG1 Load register and DS with words from memory. (REG) Source (DS) Source + 2 Ex. LDS SI,[200] LDS BX,82H[SI] Load registers and ES with words from memory. (REG) source (ES) source + 2 Ex. LES AX, [12345] LES BX,42H[SI] Load AH with LS byte of FLAG Register LS of FLAG register. S Z U A U P U C (AH) Store AH contents in the LS byte of FLAG register. S Z U A U P U C (AH)

11

12

LES LES [Dest.], [Source]

13

LAHF LAHF SAHF SAHF

14

Arithmetic Group
15 16 AAA AAA DAA DAA ASCII adjust for addition. Ex. ADD AL, BL; if AL+BL=67H, then AAA; AL contains 07H 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 Negate (Forms 2's complement). Ex. NEG BX; Replaces word in BX with its 2's complement 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.

17 18

NEG NEG destination AAS AAS

Instruction/Syntax
19 DAS DAS

Explanations/Example
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 BCD adjust after multiplication. Ex. MUL BL; AL*BL=AX (Say 0020H) AAM; AX=0302H Convert signed byte to signed word CBW produces a double length dividend from a byte prior to performing division. Convert signed byte to signed double word. CWD produces a double length dividend from a word prior to performing division. BCD to binary convert before division. AAD converts two unpacked BCD digits in AH & AL to the equivalent binary number

20

AAM AAM

21 22 23

CBW CBW CWD CWD AAD AAD

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 Rotate operand around to the left through carry.
LSB Cy MSB

25

RCL RCL [Dest.], [Source]

26

RCR RCR [Dest.], [Source]

By default CL register is used. Ex: RCL AL, CL Rotate operand around to the right through carry.
LSB Cy MSB

By default CL register is used. Ex: RCR AL, CL

Instruction/Syntax
27 SHL / SAL SHL/SAL [Opr], [Cnt]

Explanations/Example
Shift logical left / shift Arithmetic left. 0
Cy MSB LSB

28

SHR SHR [Opr], [Cnt]

Shift logical right. 0


MSB LSB Cy

29

SAR SAR [Opr], [Cnt]

Shift arithmetic right.


MSB LSB Cy

Here new MSB = old MSB

Branch Instructions
30 31 32 CALL RET JMP Call procedure Return from procedure Jump to specified location

Conditional Transfer Instructions


33 34 35 36 37 38 39 40 JA / JNBE JAE / JNB JG / JNLE JLE / JNG JNP / JPO LOOPE / LOOPZ LOOPNE / LOOPNZ JCXZ JCXZ [location] Jump if above / not below or equal Jump if above or equal / not below Jump if greater / not less or equal Jump if less or equal / not greater Jump if no parity / odd parity Jump if equal / zero Loop if not equal / not zero 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.

Instruction/Syntax
41 42 INT INT [Interrupt type] IRET

Explanations/Example
Interrupt program execution. Int. type number should be 00H to FFH Ex: INT 01H, INT 21H Interrupt Return IRET transfers control back to the point of interruption by popping IP, CS & flags from the stack.

Process Control Instructions


43 44 45 46 47 48 49 50 51 52 CLC CMC STC CLA STD CLI STI NOP WAIT ESC ESC [ExtOp],[Source] Clear the Carry flag Complement the Carry flag Set the Carry flag Clear Direction flag Used for string instructions to auto-increment SI & DI Set Direction flag Used for string instructions to auto-decrement SI & DI Clear Interrupt flag Set Interrupt flag No Operation Used for software delays Wait for test signal at Interrupt signal. When WAIT is executed 8086 goes into idle condition. It keeps checking TEST, INTR & NMI 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 Assert bus lock signal. It is not an instruction but a prefix to be used with instructions. Ex: LOCK XCHG FLAG, AL

53

LOCK

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] Or MOVSB / MOVSW Move string byte or string word. Transfers a byte or word from source string to destination string. Ex: MOVSB ;Move (DI) (SI)

Instruction/Syntax
55 CMPS CMPS [Dest.],[Source] Or CMPSB / CMPSW SCAS SCAS [Dest_Str] OR SCASB,SCASW

Explanations/Example
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, Str2 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 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 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,00H STOSW 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 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,00H STOSW Repeat string instruction until specified condition exists. EX. LEA SI,Service_str LEA DI,Dest_str MOV CX,20H CLD REP MOVSW

56

57

LODS LODS Source_string OR LODSB,LODSW

58

STOS STOS [Dest_str.] OR STOSB,STOSW

59

LODS LODS [Src_str.] OR LODSB,LODSW

60

STOS STOS [Dest_str.] OR STOSB,STOSW

61

REP REP

Instruction/Syntax
62 REPE / REPZ

Explanations/Example
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,Str1 MOV AL,ODH CLD MOV CX,25H REPE SCASB 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

63

REPNE / REPNZ

By Asawari D Dept. of Electronics VESIT ,Mumbai

Вам также может понравиться