0% found this document useful (0 votes)
11 views27 pages

Lecture 1.2.3 (Instruction Types, Addressing Modes)

The document provides an overview of instruction types in computer organization and architecture, detailing three main categories: Register Reference Instructions, Memory Reference Instructions, and Input/Output Instructions. Each category is explained with its advantages, disadvantages, and examples from various architectures like 8085 Microprocessor and x86. Additionally, it discusses addressing modes, highlighting their significance in operand selection and execution of instructions.

Uploaded by

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

Lecture 1.2.3 (Instruction Types, Addressing Modes)

The document provides an overview of instruction types in computer organization and architecture, detailing three main categories: Register Reference Instructions, Memory Reference Instructions, and Input/Output Instructions. Each category is explained with its advantages, disadvantages, and examples from various architectures like 8085 Microprocessor and x86. Additionally, it discusses addressing modes, highlighting their significance in operand selection and execution of instructions.

Uploaded by

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

University Institute of Engineering

Department of Computer Science & Engineering

COMPUTER ORGANIZATION & ARCHITECTURE


(23CST-204/23ITT-204)

ER. SHIKHA ATWAL


E11186

ASSISTANT PROFESSOR

BE-CSE
INSTRUCTION TYPES

Instructions are a set of machine language instructions that a particular processor


understands and executes. A computer performs tasks on the basis of the
instruction provided.
An instruction which is of 16-bit comprises of groups called fields. These fields
include:
oThe Operation code (Opcode) field which specifies the operation to be
performed is of 3 bits (12 to 14).
oThe Address field which contains the location of the operand, i.e., register or
memory location is of 12 bits (0 to 11).
oThe Mode field which specifies how the operand will be located is of 1 bit
(15th).
15 14 11
0 Mode (I) Opcode Operand/ address of operand

There are basically three types of instructions:


1. Register reference instructions
2. Memory Reference Instructions
3. Input Output Instructions
1. Register Reference Instructions are a class of instructions designed to operate
directly on the processor's registers, without accessing memory.

 These instructions are used to perform operations like data transfer,


arithmetic, logical operations, and control tasks within the CPU.
 Direct Register Access: Operate directly on CPU registers rather than involving
memory locations.
 Efficient Execution: Typically faster than memory-reference instructions since
they do not require additional memory access cycles.
 Simpler Encoding: These instructions are often simpler in terms of opcode and
operand specification.
Opcode=111, I=0
The Register-reference instructions are represented by the Opcode 111 with a 0
in the leftmost bit (bit 15) of the instruction.
A Register-reference instruction specifies an operation on or a test of the AC
(Accumulator) register.

Advantages
1. Faster Execution: Registers are faster to access than memory.
2. Reduced Memory Bottleneck: Fewer memory accesses reduce overall processing
time.
3. Compact Instruction Encoding: Register operations typically use shorter
instruction formats.
Disadvantages

1. Limited Scope: Register reference instructions only operate on data stored in


registers, requiring extra instructions to load/store data from memory,
increasing overall instruction count.

2. Register Dependency: They rely heavily on the availability of registers,


which can be limited in number, potentially causing inefficiency in register-
constrained architectures.

3. Complex Register Management: Managing data in multiple registers during


complex operations can lead to increased programming complexity and errors.
Examples in Various Architectures

1. 8085 Microprocessor (Accumulator-based):


oCMA: Complement the content of the accumulator.
oRLC: Rotate the content of the accumulator left.

2. x86 Assembly (General-purpose registers):


oMOV AX, BX: Copy the content of BX into AX.
oINC AX: Increment the value in AX.
2. Memory Reference Instructions are instructions that perform operations
involving data stored in the main memory.

 These instructions require interaction with the memory unit, making them slower
than register reference instructions due to the additional time required for memory
access.
 Instruction Format: Typically include a memory address or a mechanism
to compute one (e.g., direct, indirect addressing).
 Primary Operations:
oReading data from memory.
oWriting data to memory.
oPerforming operations where one or more operands are in memory.
Opcode=000 through 110
In Memory-reference instruction, 12 bits of memory is used to specify an address
and one bit to specify the addressing mode 'I'.

Advantages

1. Flexibility: Allow operations involving large datasets that cannot fit in registers.
2. Support Complex Operations: Useful for working with arrays, structures, and
dynamic data.
Disadvantages

1.Slower Execution: Accessing memory is slower than accessing registers.


2.Higher Power Consumption: Memory operations consume more energy
compared to register operations.

Examples in Various Architectures


3. 8085 Microprocessor:
o LDA 2000H: Load the accumulator with the content of memory location
2000H.
o STA 3000H: Store the content of the accumulator into memory location
3000H.
o ADD M: Add the content of the memory location pointed to by the
HL register pair to the accumulator.
2. x86 Architecture:
o MOV AX, [1000H]: Load the content of memory address 1000H into the
AX register.
o MOV [2000H], BX: Store the content of BX into memory address 2000H.
3. Input/Output (I/O) Instructions are used to transfer data between the
processor and peripheral devices like keyboards, printers, displays, and storage
devices.

 These instructions enable communication between the CPU and I/O


devices through I/O ports.
 Device Communication: Facilitate data transfer between the CPU and
external devices.
 Addressing: Port-based Addressing can be used which uses specific addresses
(I/O ports) for I/O devices and Memory-mapped I/O which treats device
addresses as part of the memory address space.
 Modes of Data Transfer: Programmed I/O, Interrupt-driven I/O, Direct
Memory Access (DMA). These modes of data transfer will be discussed in detail
in later unit.
Opcode=111, I=1
Just like the Register-reference instruction, an Input-Output instruction does not need
a reference to memory and is recognized by the operation code 111 with a 1
in the leftmost bit of the instruction. The remaining 12 bits are used to specify the
type of the input-output operation or test performed.

Advantages of I/O Instructions

1. Efficient Data Management: Simplify communication with devices.


2. Flexibility: Support various addressing schemes and data transfer modes.
3. Reduced Latency: With techniques like interrupt-driven I/O and DMA.
Disadvantages
1. Programmed I/O Overhead: Polling wastes CPU time.
2. Complexity: Managing multiple I/O devices can be challenging.
3. Dependency: Device-specific instructions limit portability.

Examples in Various Architectures


4. 8085 Microprocessor
 Input: IN 05H (Reads data from port 05H into the accumulator).
 Output: OUT 06H (Writes data from the accumulator to port 06H).
5. x86 Architecture
 Input: IN AL, DX (Reads data from the port specified in DX into AL).
 Output: OUT DX, AL (Writes the data in AL to the port specified in DX).
Note:
o The three operation code bits in positions 12 through 14 should be equal to
111. Otherwise, the instruction is a memory-reference type, and the bit in
position 15 is taken as the addressing mode I.
o When the three operation code bits are equal to 111, control unit inspects the
bit in position 15. If the bit is 0, the instruction is a register-reference type.
Otherwise, the instruction is an input-output type having bit 1 at position 15.
ADDRESSING MODES
The operation field of an instruction specifies the operation to be performed. This
operation must be executed on some data stored in computer registers or memory
words. The way the operands are chosen during program execution is dependent
on the addressing mode of the instruction.
The addressing mode specifies a rule for interpreting or modifying the address
field of the instruction before the operand is actually referenced.
Computers use addressing mode techniques for the purpose of accommodating
one or both of the following provisions:
1. To give programming versatility to the user by providing such
facilities as pointers to memory, counters for loop control, indexing of data,
and program relocation.
2. To reduce the number of bits in the addressing field of the instruction.
Effective Address (EA): The effective address refers to the address of an
exact memory location in which an operand’s value is actually present. Let
us now explain all of the addressing modes.

Instruction Format
1. Implied Mode: In this mode the operands are specified implicitly in the definition
of the instruction. For example, the instruction "complement accumulator" is an
implied- mode instruction because the operand in the accumulator register is
implied in the definition of the instruction. In fact, all register reference
instructions that use an accumulator are implied-mode instructions.

2. Immediate Mode: In the immediate mode, we specify the operand in the


instruction itself. Or, in simpler words, instead of an address field, the immediate-
mode instruction consists of an operand field. An operand field contains the actual
operand that is to be used in conjunction with an operation that is determined in the
given instruction. The immediate-mode instructions help initialize registers to a
certain constant value.
3. Register Mode: Also called Register Direct Mode. In the register mode, the
operands exist in those registers that reside within a CPU. In this case, we select a
specific register from a certain register field in the given instruction. The k-bit
field is capable of determining one 2k register.

4. Register Indirect Mode: In the register indirect mode, the instruction available to
us defines that particular register in the CPU whose contents provides the
operand’s address in the memory. In simpler words, any selected register would
include the address of an operand instead of the operand itself.

The reference to a register is equivalent to specifying any memory address. The pros of
using this type of instruction are that an instruction’s address field would make use of
fewer bits to select a register than would be require when someone wants to directly
specify a memory address.
5. Autoincrement or Autodecrement Mode: The Autodecrement or
Autoincrement mode is very similar to the register indirect mode. The only
exception is that the register is decremented or incremented before or after its
value is used to access memory. When the address stored in the register defines a
data table in memory, it is very crucial to decrement or increment the register
after accessing the table every time. It can be obtained using the decrement
or increment instruction.

6. Direct Address Mode: In the direct address mode, the address part of the
instruction is equal to the effective address. The operand would reside in memory,
and the address here is given directly by the instruction’s address field. The
address field would specify the actual branch address in a branch-type instruction.
7. Indirect Address Mode: In an indirect address mode, the address field of an
available instruction gives that address in which the effective address gets stored
in memory. The control fetches the instruction available in the memory and then
uses its address part in order to (again) access memory to read its effective
address.

8. Indexed Addressing Mode: In the indexed addressing mode, the content of a


given index register gets added to an instruction’s address part so as to obtain the
effective address. Here, the index register refers to a special CPU register that
consists of an index value. An instruction’s address field defines the beginning
address of any data array present in memory.
The effective address (EA) in these modes is obtained from the following
computation: EA= address part of instruction + content of CPU register

The CPU register used in the computation may be the program counter, an
index register, or a base register. In either case we have a different addressing mode
which is used for a different application.

9. Relative Address Mode: In relative addressing mode, the Effective Address (EA)
of the operand is calculated by adding the content of the CPU register to the address
part of the instruction word. Essentially, the effective address is the sum of the
displacement (the immediate value specified in the instruction) and the value of the
register. The address part of the given instruction is typically a signed number, which
can be either negative or positive. The resultant effective address is relative to the
address of the next instruction.
EA = Displacement + CPU Register
Here's a symbolic representation of relative addressing mode: X(PC)
The effective address for it can be calculated as follows: EA = X + (PC)
Because the operand addresses in this mode are found relative to the program
counter, it's referred to as the relative address mode.
Numerical Example for Addressing Mode
References

Reference Books:
 J.P. Hayes, “Computer Architecture and Organization”, Third Edition.
 Mano, M., “Computer System Architecture”, Third Edition, Prentice Hall.
 Stallings, W., “Computer Organization and Architecture”, Eighth Edition,
Pearson Education.

Text Books:
 Carpinelli J.D,” Computer systems organization &Architecture”, Fourth
Edition, Addison Wesley.
 Patterson and Hennessy, “Computer Architecture”, Fifth Edition Morgaon
Kauffman.
Reference Website

 https://www.studytonight.com/computer-architecture/addressingmodes-instruc
tioncycle
 http://www.eie.polyu.edu.hk/~enyhchan/addrmode.pdf

Video References

 https://www.youtube.com/watch?v=ol_g3Lt66xA
 https://www.youtube.com/watch?v=_CH4cm5PhK8

You might also like