COA UNIT 2 Notes
COA UNIT 2 Notes
What is instruction?: A group of bits which instructs computer to perform specific operation.
Instruction contains two information (Syntax of Instruction):
Opcode Operand Information
Register: Register is small storage used to store n-bit of information. Registers are represented
in different ways as shown below.
Fig: a) Represents register R1 b) Represents content of register c) Represents bits numbering
of 16-bit PC register d) Represents register PC divided into 2-parts lower bits (0-7) and
higher bits (8-15)
Register Transfer: Transferring content of one register to another register is called as register
transfer.
Register transfer takes place only when register receives a transfer control signals, which is
indicated as follows.
If (p=1) R1R2: When P=1 there is control signal and hence register transfer takes place from
R2 to R1), which can also be written as, P: R1R2
Register Transfer Language (RTL): Refers to symbolic notations which specifies register
transfer micro-operations.
Notations used in RTL:
1. MARin, Read
2. MDRin
3. MDRout, R0in
Addressing Mode: Every instructions contains two information first one is OPCODE and
second one is OPERAND INFORMATION. Addressing mode refers to how operand
information is specified in the instruction.
Based on how the operand information is specified in the instructions, we have following types
of addressing modes (In 8086 Machine Architecture).
1. Immediate addressing mode: Here, the source operand contains the required data
itself.
Eg: MOV AX, 0010H
Here, 0010H is the required data in HEX format.
2. Direct addressing mode: Here, the source operand contains address of the required
data.
Eg: MOV AX, [4896H]
Here, [4896H] is the offset address. Using offset address we can calculate Physical
address. Content from that physical address is moved to AX register.
3. Register addressing mode: Here, the source operand is a register and contains the
required data.
Eg: MOV AX, BX
4. Register-indirect addressing mode: Here, the offset address of the data is in either of
one of the BP, BX, SI and DI register.
Eg: 1. MOV AX, [BX]
2. MOV AX, [SI]
5. Indexed Addressing mode: Here, the offset address of the data is specified by the sum
of contents of the SI/DI registers and 8bit/16bit displacement.
Eg: MOV DX, 08H [SI]
8086 machine architecture contains more than 20000 instructions in it. These instructions are
broadly classified into 9-types as follows.
1. Data Transfer/Data Copy Instructions: The data transfer instructions move data between
memory and the general-purpose and segment registers, and perform operations such as
conditional moves, stack access, and data conversion. Data transfer instructions does not affect
carry flag or overflow flag. Few data transfer instructions are listed as below
MOV instructions move data from source operand to the destination operand.
Eg: 1) MOV AX, BX 2) MOV AX, [4895H]
XCHG: Syntax of XCHG instruction is,
XCHG instructions exchange the content of destination operand and source operand
Eg: 1) XCHG AX, BX 2) XCHG AX, [4895H]
LEA instruction loads effective address mentioned in the source operand into the register
(Destination Operand).
Eg: LEA AX, [4895H]
LDS instructions loads starting address of data segment/ address of the first word in data
segment into the register (Destination operand).
Eg: LDS AX, [4896H]
LES instructions loads starting address of extra segment/ address of the first word in extra
segment into the register (Destination operand).
Eg: LES BX, [6000H]
PUSH Register
PUSH instruction pushes the content of the register (Destination operand) into the top of the
stack in stack segment.
Eg: PUSH AX
POP Register
POP instructions loads the content of top of the stack into the register (Destination Operand)
2. Arithmetic instructions: Arithmetic Instructions are the instructions which perform basic
arithmetic operations such as addition, subtraction and a few more. Unlike in 8085
microprocessor, in 8086 microprocessor the destination operand need not be the accumulator.
Arithmetic instructions does not affect carry flag or overflow flag. Few of the arithmetic
instructions are,
ADD (Addition)
ADC (Addition with carry)
SUB (Subtraction)
SBB (Subtraction with borrow)
MUL (Multiplication)
INC (Increment)
DEC (Decrement)
ADD instruction adds the content of destination operand and source operand and stores the
result in the destination operand only.
Eg: 1) ADD AX, BX 2) ADD AX, [5609H]
ADC instruction adds the content of source operand plus the status of the carry flag with
destination operand
Eg: ADC AX, BX
SUB instruction subtracts the content of source operand and destination operand and stores the
result in the destination operand only.
Eg: SUB AX, BX
SBB instruction subtracts the content of destination operand with source operand plus the status
of the carry flag.
Eg: SBB AX, BX
MUL: Syntax of MUL instruction is,
3. Logical instructions: Logical instructions in the 8086 microprocessor are instructions that
perform logical operations on data stored in registers or memory locations. These instructions
can manipulate bits within a byte, set or clear individual bits, or perform Boolean operations
such as AND, OR, XOR, NOT and NEG. Logical instructions does not affect carry flag or
overflow flag. Few of the logical instructions are listed as below.
AND
OR
XOR
NOT
NEG
AND instruction performs a bitwise logical AND operation between destination and source
operands and stores the result in the destination operand.
Eg: AND AX, BX
OR: Syntax of OR instruction is,
XOR instruction performs a bitwise logical XOR operation between destination and source
operands and stores the result in the destination operand.
Eg: XOR AX, BX
NOT instruction performs a bitwise logical NOT (negation/1’s complement) operation on the
destination operand and stores the result in the destination operand only.
Eg: NOT AX
NEG instruction performs a bitwise logical NEG (2’s complement+1) operation on the
destination operand and stores the result in the destination operand only.
Eg: NEG AX
4. Branch Instructions: Branch instructions transfer the flow of execution of the program to
a new address specified in the instruction directly or indirectly. Branch instructions does not
affect carry flag or overflow flag. Few of the conditional branch instructions are as below.
JC (Jump if carry)
JNC (Jump if no carry)
JZ (Jump if zero)
JNZ (Jump if not zero)
JPE (Jump if parity bit is even)
JPO (Jump if parity bit is odd)
JC Address
JC instruction checks whether the carry flag is set or not. If yes, then jump takes place, that
is: If CF = 1, then jump.
Eg: JC NEXT
JNC Address
JNC checks whether the carry flag is reset or not. If yes, then jump takes place, that is: If CF =
0, then jump.
Eg: JNC NEXT
JZ Address
JZ checks whether the zero flag is set or not. If yes, then jump takes place, that is: If ZF = 1,
then jump.
Eg: JZ NEXT
JNZ Address
JNZ checks whether the zero flag is set or not. If no, then jump takes place, that is: If ZF = 0,
then jump.
Eg: JNZ NEXT
JPE Address
JPE checks whether the parity flag contains even number or odd. If even, then jump takes place.
Eg: JPE NEXT
JPO Address
JPO checks whether the parity flag contains even number or odd. If odd, then jump takes place.
Eg: JPO NEXT
5. Shift and Rotate instructions: These instructions are used to perform logical or arithmetic
shift and rotate operations where a bit of data is involved. Shift and Rotate instructions affect
carry flag or overflow flag. Few of the shift and rotate instructions are as below.
SHR (Shift Right)
SAR (Shift Arithmetic Right)
SHL (Shift Left)
SAL (Shift Arithmetic Left)
ROL (Rotate Left)
ROR (Rotate Right)
SHR instruction simply shifts the mentioned bits in the register to the right side one by one by
inserting the same number (bits that are being shifted) of zeroes from the left end. The rightmost
bit that is being shifted is stored in the Carry Flag (CF).
Eg: SHR AX, 2
This instruction shifts the mentioned bits in the register to the right side one by one, but instead
of inserting the zeroes from the left end, the MSB is restored. The rightmost bit that is being
shifted is stored in the Carry Flag (CF).
Eg: SAR BX, 5
This instruction simply shifts the mentioned bits in the register to the left side one by one by
inserting the same number (bits that are being shifted) of zeroes from the right end. The leftmost
bit that is being shifted is stored in the Carry Flag (CF).
Eg: SHL AX, 2
This instruction rotates the mentioned bits in the register to the right side one by one such that
rightmost bit that is being rotated is again stored as the leftmost bit in the register, and it is also
stored in the Carry Flag (CF).
Eg: ROR AH, 2
6. Machine Control Instructions: Machine control instructions are a type of instruction that
control machine functions such as Halt, Interrupt, or do nothing. These instructions does not
alter carry flag or overflow flag. Few machine control instructions as follows.
NOP (No-operation)
HLT (Halt)
NOP
NOP is used when no operation is performed. It is commonly used to fill in time delay or to
delete and insert instructions while troubleshooting.
HLT
HLT is used to stop the execution of the program temporarily. The microprocessor finishes
executing the current instruction and halts any further execution. The contents of the registers
are unaffected during the HLT state. HLT can be used to enter a wait state in which the
microprocessor waits for a specific event to occur before resuming execution. Processor gets
out of halt state upon an interrupt signal (INTR and NMI) or reset signal (RESET)
7. Flag manipulation instructions: The Flag manipulation instructions directly modify some
of the Flags of 8086. Few flag manipulation instructions are as follows.
8. String manipulation instructions: The 8086 supports a set of more powerful instructions
for string manipulations for referring to a string, two parameters are required. Few of the string
manipulation instructions are.
REP: This instruction is used as a prefix to other instructions, the instruction to which the REP
prefix is provided, is executed repeatedly until the CX register becomes zero (at each iteration
CX is automatically decremented by one).