Instruction Set of 8086: Data Transfer Instructions Arithmetic Instructions

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 6

Lecturer in Polytechnic Computer Engineering/Asst Professor/Programmer/Inst Grade 1

• LDS − Used to load DS register and other


Instruction Set of 8086 provided register from the memory
The 8086 microprocessor supports 8 types of • LES − Used to load ES register and other provided
instructions – register from the memory.

• Data Transfer Instructions Instructions to transfer flag registers


• Arithmetic Instructions
• LAHF − Used to load AH with the low byte of the
• Bit Manipulation Instructions
flag register.
• String Instructions
• SAHF − Used to store AH register to low byte of
• Program Execution Transfer Instructions (Branch
the flag register.
& Loop Instructions)
• PUSHF − Used to copy the flag register at the top
• Processor Control Instructions
of the stack.
• Iteration Control Instructions
• POPF − Used to copy a word at the top of the
• Interrupt Instructions stack to the flag register.
Data Transfer Instructions Arithmetic Instructions
These instructions are used to transfer the data from the These instructions are used to perform arithmetic
source operand to the destination operand. Instruction operations like addition, subtraction, multiplication,
to transfer a word. division, etc.
• MOV − Used to copy the byte or word from the Following is the list of instructions under this group −
provided source to the provided destination.
Instructions to perform addition
• PPUSH − Used to put a word at the top of the
stack. • ADD − Used to add the provided byte to
• POP − Used to get a word from the top of the byte/word to word.
stack to the provided location.
• ADC − Used to add with carry.
• PUSHA − Used to put all the registers into the
stack. • INC − Used to increment the provided
• POPA − Used to get words from the stack to all byte/word by 1.
registers. • AAA − Used to adjust ASCII after addition.
• XCHG − Used to exchange the data from two
locations. • DAA − Used to adjust the decimal after the
addition/subtraction operation.
• XLAT − Used to translate a byte in AL using a
table in the memory. Instructions to perform subtraction
Instructions for input and output port transfer • SUB − Used to subtract the byte from byte/word
from word.
• IN − Used to read a byte or word from the
provided port to the accumulator. • SBB − Used to perform subtraction with borrow.
• OUT − Used to send out a byte or word from the • DEC − Used to decrement the provided
accumulator to the provided port. byte/word by 1.

Instructions to transfer the address • NPG − Used to negate each bit of the provided
byte/word and add 1/2’s complement.
• LEA − Used to load the address of operand into
• CMP − Used to compare 2 provided byte/word.
the provided register.

GINeX Technical Exam Campus 1


Coaching available for all PSC Technical Examinations. Conatct : 9995214715
Lecturer in Polytechnic Computer Engineering/Asst Professor/Programmer/Inst Grade 1
• AAS − Used to adjust ASCII codes after • TEST − Used to add operands to update flags,
subtraction. without affecting operands.
• DAS − Used to adjust decimal after subtraction. Instructions to perform shift operations
Instruction to perform multiplication • SHL/SAL − Used to shift bits of a byte/word
towards left and put zero(S) in LSBs.
• MUL − Used to multiply unsigned byte by
byte/word by word. • SHR − Used to shift bits of a byte/word towards
the right and put zero(S) in MSBs.
• IMUL − Used to multiply signed byte by
byte/word by word. • SAR − Used to shift bits of a byte/word towards
the right and copy the old MSB into the new
• AAM − Used to adjust ASCII codes after
MSB.
multiplication.
Instructions to perform rotate operations
Instructions to perform division
• ROL − Used to rotate bits of byte/word towards
• DIV − Used to divide the unsigned word by byte
the left, i.e. MSB to LSB and to Carry Flag [CF].
or unsigned double word by word.
• ROR − Used to rotate bits of byte/word towards
• IDIV − Used to divide the signed word by byte or
the right, i.e. LSB to MSB and to Carry Flag [CF].
signed double word by word.
• RCR − Used to rotate bits of byte/word towards
• AAD − Used to adjust ASCII codes after division.
the right, i.e. LSB to CF and CF to MSB.
• CBW − Used to fill the upper byte of the word
• RCL − Used to rotate bits of byte/word towards
with the copies of sign bit of the lower byte.
the left, i.e. MSB to CF and CF to LSB.
• CWD − Used to fill the upper word of the double
word with the sign bit of the lower word. String Instructions
Bit Manipulation Instructions String is a group of bytes/words and their memory is
always allocated in a sequential order.
These instructions are used to perform operations
Following is the list of instructions under this group −
where data bits are involved, i.e. operations like logical,
shift, etc. • REP − Used to repeat the given instruction till CX
≠ 0.
Following is the list of instructions under this group −
• REPE/REPZ − Used to repeat the given
Instructions to perform logical operation instruction until CX = 0 or zero flag ZF = 1.
• NOT − Used to invert each bit of a byte or word. • REPNE/REPNZ − Used to repeat the given
• AND − Used for adding each bit in a byte/word instruction until CX = 0 or zero flag ZF = 1.
with the corresponding bit in another • MOVS/MOVSB/MOVSW − Used to move the
byte/word. byte/word from one string to another.
• OR − Used to multiply each bit in a byte/word • COMS/COMPSB/COMPSW − Used to compare
with the corresponding bit in another two string bytes/words.
byte/word.
• INS/INSB/INSW − Used as an input
• XOR − Used to perform Exclusive-OR operation string/byte/word from the I/O port to the
over each bit in a byte/word with the provided memory location.
corresponding bit in another byte/word.

GINeX Technical Exam Campus 2


Coaching available for all PSC Technical Examinations. Conatct : 9995214715
Lecturer in Polytechnic Computer Engineering/Asst Professor/Programmer/Inst Grade 1
• OUTS/OUTSB/OUTSW − Used as an output • JNC − Used to jump if no carry flag (CF = 0)
string/byte/word from the provided memory
• JNE/JNZ − Used to jump if not equal/zero flag ZF
location to the I/O port.
=0
• SCAS/SCASB/SCASW − Used to scan a string and
• JNO − Used to jump if no overflow flag OF = 0
compare its byte with a byte in AL or string
word with a word in AX. • JNP/JPO − Used to jump if not parity/parity odd
PF = 0
• LODS/LODSB/LODSW − Used to store the string
byte into AL or string word into AX. • JNS − Used to jump if not sign SF = 0

Program Execution Transfer Instructions • JO − Used to jump if overflow flag OF = 1


(Branch and Loop Instructions) • JP/JPE − Used to jump if parity/parity even PF =
1
These instructions are used to transfer/branch the
instructions during an execution. It includes the • JS − Used to jump if sign flag SF = 1
following instructions −
Processor Control Instructions
Instructions to transfer the instruction during an
execution without any condition − These instructions are used to control the processor
action by setting/resetting the flag values.
• CALL − Used to call a procedure and save their
return address to the stack. Following are the instructions under this group −

• RET − Used to return from the procedure to the • STC − Used to set carry flag CF to 1
main program. • CLC − Used to clear/reset carry flag CF to 0
• JMP − Used to jump to the provided address to • CMC − Used to put complement at the state of
proceed to the next instruction. carry flag CF.
Instructions to transfer the instruction during an • STD − Used to set the direction flag DF to 1
execution with some conditions −
• CLD − Used to clear/reset the direction flag DF
• JA/JNBE − Used to jump if above/not to 0
below/equal instruction satisfies.
• STI − Used to set the interrupt enable flag to 1,
• JAE/JNB − Used to jump if above/not below i.e., enable INTR input.
instruction satisfies.
• CLI − Used to clear the interrupt enable flag to 0,
• JBE/JNA − Used to jump if below/equal/ not i.e., disable INTR input.
above instruction satisfies.
• JC − Used to jump if carry flag CF = 1
Iteration Control Instructions
• JE/JZ − Used to jump if equal/zero flag ZF = 1 These instructions are used to execute the given
instructions for number of times. Following is the list of
• JG/JNLE − Used to jump if greater/not less instructions under this group −
than/equal instruction satisfies.
• LOOP − Used to loop a group of instructions
• JGE/JNL − Used to jump if greater until the condition satisfies, i.e., CX = 0
than/equal/not less than instruction satisfies.
• LOOPE/LOOPZ − Used to loop a group of
• JL/JNGE − Used to jump if less than/not greater instructions till it satisfies ZF = 1 & CX = 0
than/equal instruction satisfies.
• LOOPNE/LOOPNZ − Used to loop a group of
• JLE/JNG − Used to jump if less than/equal/if not instructions till it satisfies ZF = 0 & CX = 0
greater than instruction satisfies.

GINeX Technical Exam Campus 3


Coaching available for all PSC Technical Examinations. Conatct : 9995214715
Lecturer in Polytechnic Computer Engineering/Asst Professor/Programmer/Inst Grade 1
• JCXZ − Used to jump to the provided address if MOV AX, [0500]
CX = 0 4. Register indirect addressing mode – In this
addressing mode the effective address is held in
Interrupt Instructions
the registers SI, DI or BX.
These instructions are used to call the interrupt during Example:
program execution. MOV AX, [DI]
• INT − Used to interrupt the program during ADD AL, [BX]
execution and calling service specified. MOV AX, [SI]
• INTO − Used to interrupt the program during 5. Based indexed addressing mode – In this the
execution if OF = 1 effective address is sum of base register and
index register.
• IRET − Used to return from interrupt service to
Base register: BX, BP
the main program
Index register: SI, DI
Addressing modes in 8086 The physical memory address is calculated
according to the base register.
The way of specifying data to be operated by an
Example:
instruction is known as addressing modes. This
MOV AL, [BP+SI]
specifies that the given data is an immediate data or an
MOV AX, [BX+DI]
address. It also specifies whether the given operand is
6. Indexed addressing mode – In this type of
register or register pair.
addressing mode the effective address is sum of
Types of addressing modes:
index register and displacement.
1. Register addressing mode – In this type of
Example:
addressing mode both the operands are
MOV AX, [SI+2000]
registers.
MOV AL, [DI+3000]
Example:
7. Based addressing mode – In this the effective
MOV AX, BX
address is the sum of base register and
XOR AX, DX
displacement.
ADD AL, BL
Example:
2. Immediate addressing mode – In this type of
MOV AL, [BP+ 0100]
addressing mode the source operand is a 8 bit
8. Based indexed displacement mode – In this
or 16 bit data. Destination operand can never
type of addressing mode the effective address
be immediate data.
is the sum of index register, base register and
Example:
displacement.
MOV AX, 2000
Example:
MOV CL, 0A
MOV AL, [SI+BP+2000]
ADD AL, 45
9. String mode – This addressing mode is related
AND AX, 0000
to string instructions. In this the value of SI and
3. Displacement or direct addressing mode – In
DI are auto incremented and decremented
this type of addressing mode the effective
depending upon the value of directional flag.
address is directly given in the instruction as
Example:
displacement.
MOVS B
Example:
MOVS W
MOV AX, [DISP]

GINeX Technical Exam Campus 4


Coaching available for all PSC Technical Examinations. Conatct : 9995214715
Lecturer in Polytechnic Computer Engineering/Asst Professor/Programmer/Inst Grade 1
10. Input/Output mode – This addressing mode is microprocessor. There are two hardware
related with input output operations. interrupts in 8086. They are:
Example: (A) NMI (Non Maskable Interrupt) – It is a
IN A, 45 single pin non maskable hardware interrupt
OUT A, 50 which cannot be disabled. It is the highest
11. Relative addressing mode – priority interrupt in 8086 microprocessor. After
In this the effective address is calculated with its execution, this interrupt generates a TYPE 2
reference to instruction pointer. interrupt. IP is loaded from word location 00008
Example: H and CS is loaded from the word location
JNZ 8 bit address 0000A H.
IP=IP+8 bit address
When this interrupt is activated, these actions take
place −
Interrupts in 8086
• Completes the current instruction that is in
• An interrupt is a condition that halts the progress.
microprocessor temporarily to work on a • Pushes the Flag register values on to the stack.
different task and then return to its previous
• Pushes the CS (code segment) value and IP
task. Interrupt is an event or signal that request
(instruction pointer) value of the return address
to attention of CPU. This halt allows peripheral on to the stack.
devices to access the microprocessor.
• IP is loaded from the contents of the word
• Whenever an interrupt occurs the processor
location 00008H.
completes the execution of the current
instruction and starts the execution of an • CS is loaded from the contents of the next word
Interrupt Service Routine (ISR) or Interrupt location 0000AH.
Handler. ISR is a program that tells the • Interrupt flag and trap flag are reset to 0.
processor what to do when the interrupt
(B) INTR (Interrupt Request) – It provides a
occurs. After the execution of ISR, control
single interrupt request and is activated by I/O
returns back to the main routine where it was
port. This interrupt can be masked or delayed.
interrupted.
It is a level triggered interrupt. It can receive
any interrupt type, so the value of IP and CS will
change on the interrupt type received.
These actions are taken by the microprocessor −
• First completes the current instruction.
• Activates INTA output and receives the interrupt
type, say X.
• Flag register value, CS value of the return
The different types of interrupts present in 8086 address and IP value of the return address are
microprocessor are given by: pushed on to the stack.
• Hardware Interrupts – • IP value is loaded from the contents of word
Hardware interrupts are those interrupts which location X × 4
are caused by any peripheral device by sending
a signal through a specified pin to the
GINeX Technical Exam Campus 5
Coaching available for all PSC Technical Examinations. Conatct : 9995214715
Lecturer in Polytechnic Computer Engineering/Asst Professor/Programmer/Inst Grade 1
• CS is loaded from the contents of the next word
location.
• Interrupt flag and trap flag is reset to 0
• Software Interrupts – These are instructions
that are inserted within the program to
generate interrupts. There are 256 software
interrupts in 8086. The instructions are of the
format INT type where type ranges from 00 to
FF. The starting address ranges from 00000 H to
003FF H. These are 2 byte instructions. IP is
loaded from type * 04 H and CS is loaded from
the next address give by (type * 04) + 02 H.
Some important software interrupts are:
(A) TYPE 0 corresponds to division by
zero(0).
(B) TYPE 1 is used for single step
execution for debugging of program.
(C) TYPE 2 represents NMI and is used
in power failure conditions.
(D) TYPE 3 represents a break-point
interrupt.
(E) TYPE 4 is the overflow interrupt.
• The interrupts from Type 5 to Type 31 are
reserved for other advanced microprocessors,
and interrupts from 32 to Type 255 are available
for hardware and software interrupts.

GINeX Technical Exam Campus 6


Coaching available for all PSC Technical Examinations. Conatct : 9995214715

You might also like