Professional Documents
Culture Documents
6 6
One byte instruction one byte long using implied data or registers- all 8 bits form an opcode, sometimes LS 3 bits are used for specifying registers.
2. Register to register Two bytes length first byte for opcode, second byte for register and R/M field.
D7 D0 D1 D7 D6 D0 D5 D4 D3 REG D2 D1 R/M W
11
3. Register to/from Memory with no displacement Two bytes length similar to register to register except for the MOD field
D7 D0 D1 W D7 D6 D0 MO D D5 D4 D3 REG D2 D1 R/M
OPCODE
D7 D6 D0 MO D
D5 D4 D3 REG
D2 D1
R/M
Three/four bytes length additional bytes for the displacement first byte as well as 3 bits from second byte used for opcode
D7 D0
D7 D6 D0 D5 D4 D3 OPCODE D2 D1 R/M D7 D0 Lower byte DATA
OPCODE
11
OPCODE
Instruction Set
The instructions in 8086, can be classified into 13 groups based on their functions. Instructions 1. Data Transfer Instructions 3. Logic Instructions 5. Jump Instructions 2. Arithmetic 4. Compare
Instruction
Instructions
Instructions Instructions
Move data between its Internal registers or between an internal register and a storage location in memory. All the STORE, MOVE, LOAD, EXCHANGE, INPUT and OUTPUT instructions belong to this category. MOV REG, memory ; MOV memory, REG
MOV
The instruction MOV transfers a byte or word of data from the source to the destination. (transfer data from source operand to destination operand). The source can be a register or a memory location or an immediate number. The destination can be a register or a memory location. Both the source and destination cannot refer to memory locations in the same instruction.
The MOV instruction Direct loading of one segment register to another segment register is not permitted. (should copy to general register first). Direct loading of segment register with immediate data is not permitted. (should copy to general register first).
Operation: (D)<--->(S)
This instruction exchanges the contents of the specified source and destination operands, which may be registers or one of them may be a memory location. Exchange of contents of two memory locations is not permitted. Immediate data is not allowed in this instructions.
The instruction LEA loads the EA formed by source operand into the specified destination register. determines offset of a variable or memory location indicated as a source (address) and places the offset in the specified 16-bit register. The source operand must be a memory variable and the destination must be a 16-bit general register. Eg: LEA AX, [BX] LEA BX, AMOUNT
10103h
10102h 10101h 10100h
56 78 12 34 m
Example:
LDS AX, m Memory contains data are 1234h 5678h AX is set to 1234h, DS is set to 5678h.
The instruction LDS copies the contents of first two memory locations to a specified 16-bit register and the next consecutive two memory locations into the DS register.
The instruction LES copies the contents of first two memory locations to a specified 16-bit register and the next consecutive two memory locations into the ES register.
Flags
flag
flag
enable
Trap
flag
Eg: PUSH AX Current stack top is already occupied so decrement SP by one then store AH into the address pointed to by SP. Further decrement SP by one and store AL into the location pointed to by SP. Thus SP is decremented by 2 and AH-AL contents are stored in stack memory. 1000 1001 1002 1003
Example:
C,Z,S,O,P,A unchanged
Example:
eg:
Contents
POP AX
1.
IN AL, 03
AX, DX DX, 0800H
2.IN
3.MOV
IN AX,DX
Eg:
1. 2.
3.
XLAT (Translate)
Syntax: XLAT
Operation:
((AL)+(BX)+(DS)0) -----> (AL) Execution of the XLAT instructiThe most common application of this instruction is for software code conversions.
Execution of the XLAT instruction replaces the contents of AL by the contents of the accessed lookup-table location. the physical address of this element in the table is derived as PA = (DS) 0 + (BX) + (AL). The most common application of this instruction is for software code conversions. Mnemoni c XLAT Meaning Format Operation ((AL)+(BX)+(DS)0() Flags affected None
Translate XLAT
The translate instruction is used for finding out the codes in case of code conversion problems, using look up table technique. The translation from the code of the key pressed to the corresponding code is performed using XLAT instruction. Before execution of the XLAT instruction, BX should be loaded with the offset address of lookup table in the data segment (DS) and AL with the code to be converted.
When XLAT is executed , the byte pointed to by (BX + AL) is transformed to the AL register. Eg: MOV AL,code MOV BX,2400 XLAT Operation ( (AL) + (BX) + (DS)0 ) -> (AL)
Assume (DS) = 0300H, (BX)=0100H, and (AL)=0DH. Execution of XLAT replaces the contents of AL by the contents of memory location with physical address. PA=(DS)0 +(BX) +(AL) = 03000H + 0100H + 0DH = 0310DH (0310DH) (AL) , Assuming this memory locations contains 52H ,this value is placed in AL. That is (AL)=52h.