0% found this document useful (0 votes)
135 views13 pages

COA UNIT 2 Notes

The document discusses the instruction set architecture of a CPU. It begins by defining what an instruction is - a group of bits that instructs the computer to perform a specific operation. An instruction contains an opcode and operand information. It then discusses different components of instruction set architecture like register transfer language, addressing modes, and classifications of instructions into categories like data transfer, arithmetic, logical, and others. It provides examples of common instructions like MOV, ADD, SUB etc. to illustrate these concepts.

Uploaded by

virajnjr10
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
135 views13 pages

COA UNIT 2 Notes

The document discusses the instruction set architecture of a CPU. It begins by defining what an instruction is - a group of bits that instructs the computer to perform a specific operation. An instruction contains an opcode and operand information. It then discusses different components of instruction set architecture like register transfer language, addressing modes, and classifications of instructions into categories like data transfer, arithmetic, logical, and others. It provides examples of common instructions like MOV, ADD, SUB etc. to illustrate these concepts.

Uploaded by

virajnjr10
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 13

UNIT-II: Instruction Set Architecture of a CPU

What is instruction?: A group of bits which instructs computer to perform specific operation.
Instruction contains two information (Syntax of Instruction):
Opcode Operand Information

8-Bits (For 8-bit instruction architecture)

Opcode (3-bits): Determines what operation needs to be performed.


Operand information (5-bits): This filed gives information about the operand on which
operation needs to be performed.
Conversion of High level programming into machine language (Binary code):

High Level Language Binary Language


(Instructions)

Register Transfer Language (RTL):

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)

Micro-operations: Basic operations performed on content of the registers is called as micro-


operations. Micro-operations are divided into 3-types.
i) Arithmetic micro-operations
ii) Logic micro-operations
iii) Shift micro-operations

Some of the arithmetic micro-operations are:

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) R1R2: When P=1 there is control signal and hence register transfer takes place from
R2 to R1), which can also be written as, P: R1R2

Register Transfer Language (RTL): Refers to symbolic notations which specifies register
transfer micro-operations.
Notations used in RTL:

Apart from above notations few other notations are:


1. If data is coming into the register, for example data is receiving into the MDR register
then it is represented as MDRin.
2. Id data is going out of the register, for example data is going out of the MDR register
then it is represented as MDRout.

Example of RTL: Fetch the data from memory to R0 register:

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.

Basic Requisites to understand Addressing mode:

1. MOV R0, R1: Here R0 is destination operand and R2 is source operand.


2. General Purpose registers in 8086 machine architecture:
3. Physical address can be calculated as,
Physical address= Segment Address*10H + offset.
Here, offset contains three parts: 1. Displacement 2. Base register content 3. Index
register content.

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.


2. Direct Addressing mode.
3. Register Addressing mode.
4. Register-indirect addressing mode.
5. Indexed addressing mode.
6. Register-relative addressing mode.
7. Based-Indexed addressing mode.
8. Relative-Base-Indexed addressing mode.

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]

6. Register-relative addressing mode: Here, the effective address is formed by adding


an 8bit/16bit displacement with the content of any one of the registers BX, BP, SI and
DI in the default segment of DS or ES segment.
Eg: MOV AX, 30H [BX]
7. Based-Indexed addressing mode: In this addressing mode, the effective address of
the data is formed by adding content of base register (BX or BP) to the content of the
index register (SI or DI).
Eg: MOV AX, [BX] [SI]

8. Relative-Based-Indexed addressing mode: In this addressing mode, the effective


address of the data is formed by adding 8bit/16bit displacement with content of base
register (BX or BP) and content of the index register (SI or DI).
Eg: MOV AX, 30H [BX] [SI]

Instruction Set of 8086 machine architecture:

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


2. Arithmetic instructions
3. Logical instructions
4. Branch instructions
5. Loop instructions
6. Machine/processor controlled instructions
7. Flag manipulation instructions
8. Shift and rotate instructions
9. String manipulation instructions

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 (MOVE operation)


 XCHG (Exchange operation)
 LEA (Load effective address)
 LDS (Load data segment register)
 LES (Load extra segment register)
 PUSH
 POP

MOV: Syntax of MOV instruction is,

MOV Destination operand, Source Operand

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 Destination Operand, Source Operand

XCHG instructions exchange the content of destination operand and source operand
Eg: 1) XCHG AX, BX 2) XCHG AX, [4895H]

LEA: Syntax of LEA instruction is,

LEA Register, Source operand

LEA instruction loads effective address mentioned in the source operand into the register
(Destination Operand).
Eg: LEA AX, [4895H]

LDS: Syntax of LDS instruction is,

LDS Register, Memory address of the first word of Data Segment

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: Syntax of LES register is,

LES Register, Memory address of the first word of Extra Segment

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: Syntax of the PUSH instruction is,

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: Syntax of POP instruction is,

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: Syntax of ADD instruction is,

ADD Destination operand, Source Operand

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: Syntax of ADC instruction is,

ADC Destination operand, Source Operand

ADC instruction adds the content of source operand plus the status of the carry flag with
destination operand
Eg: ADC AX, BX

SUB: Syntax of SUB instruction is,

SUB Destination operand, Source Operand

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: Syntax of SBB instruction is,

SBB Destination operand, Source Operand

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,

MUL Source operand

Here, by default the destination operand is always ACCUMULATOR register so it is not


necessary to mention destination operand explicitly. MUL instruction performs multiplication
operation with source operand and default accumulator register and the result is stored in
accumulator register only.
Eg: MUL BX

INC: Syntax of INC operand is,

INC Destination operand

INC instruction increments the value of destination operand by 1.


Eg: INC AX

DEC: Syntax of INC operand is,

DEC Destination operand

DEC instruction decrements the value of destination operand by 1.


Eg: DEC AX

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: Syntax of AND instruction is,

AND Destination operand, Source Operand

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,

OR Destination operand, Source Operand

OR instruction performs a bitwise logical OR operation between destination and source


operands and stores the result in the destination operand.
Eg: OR AX, BX

XOR: Syntax of XOR instruction is,

XOR Destination operand, Source Operand

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: Syntax of NOT instruction is,

NOT Destination operand

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: Syntax of NEG instruction is,

NEG Destination operand

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: Syntax of JC instruction is,

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: Syntax of JNC instruction is,

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: Syntax of JZ instruction is,

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: Syntax of JNZ instruction is,

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: Syntax of JPE instruction is,

JPE Address

JPE checks whether the parity flag contains even number or odd. If even, then jump takes place.
Eg: JPE NEXT

JPO: Syntax of JPO instruction is,

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: Syntax of SHR instructions is,

SHR Register, Number of bits to be shifted

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

SAR: Syntax of SAR instructions is,

SAR Register, Number of bits to be shifted

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

SHL: Syntax of SHL instructions is,

SHL Register, Number of bits to be shifted

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

SAL: Syntax of SAL instructions is,

SAL Register, Number of bits to be shifted

This instruction is the same as SHL.


Eg: SAL AX, 3

ROL: Syntax of ROL instructions is,

ROL Register, Number of bits to be shifted


This instruction rotates the mentioned bits in the register to the left side one by one such that
leftmost bit that is being rotated is again stored as the rightmost bit in the register, and it is also
stored in the Carry Flag (CF).
Eg: ROL AH, 3

ROR: Syntax of ROL instructions is,

ROR Register, Number of bits to be shifted

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: Syntax of NOP instructions is,

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: Syntax of HLT instructions is,

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.

 CLC (Clear Carry Flag)


 CMC (Complement Carry Flag)
 STC (Set Carry Flag)
 CLD (Clear Direction Flag)
 STD (Set Direction Flag)
 CLI (Clear Interrupt Flag)
 STI (Set Interrupt Flag)

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 (Repeat instruction prefix)


 REPE/REPZ (Repeat instruction while equal/zero)
 MOVSB/MOVSW (Move string byte or string word)
 CMPS (Compare string byte or string word)

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).

REPE/REPZ: Used to repeat the given instruction until CX = 0 or zero flag ZF = 1.

MOVSB/MOVSW: Used to move the byte/word from one string to another.

CMPS: Used to compare two string bytes/words.

You might also like