0% found this document useful (0 votes)
8 views

Unit 2 AddressingModes

The document explains computer instruction codes, which are binary codes that dictate micro-operations in a computer's memory. It categorizes instruction codes into operation codes (Opcodes) and addresses, detailing various instruction formats and addressing modes such as immediate, direct, and indirect addressing. Additionally, it discusses the advantages and disadvantages of different addressing modes and provides FAQs related to instruction codes and effective addresses.

Uploaded by

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

Unit 2 AddressingModes

The document explains computer instruction codes, which are binary codes that dictate micro-operations in a computer's memory. It categorizes instruction codes into operation codes (Opcodes) and addresses, detailing various instruction formats and addressing modes such as immediate, direct, and indirect addressing. Additionally, it discusses the advantages and disadvantages of different addressing modes and provides FAQs related to instruction codes and effective addresses.

Uploaded by

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

Introduction

Computer instruction is a binary code that specifies the micro-operations in a sequence stored in
the computer's memory and the data. Instruction codes and addresses are unique to each
computer.
Generally, we can categorize instruction codes and addresses into operation codes(Opcodes) and
addresses. Opcodes specify how to perform a specific instruction. An address specifies which we
should use- a register or an area, for a particular action. Operands are precise computer
instructions that show what information the computer requires to function.
Instruction code
Instruction codes are bits that instruct the computer to execute a specific operation. An
instruction comprises groups called fields. These fields include:
An instruction comprises groups called fields. These fields include:
 The Operation code (Opcode) field determines the process that needs to perform.
 The Address field contains the operand's location, i.e., register or memory location.
 The Mode field specifies how the operand locates.

Instruction Format
Opcodes
An opcode is a collection of bits representing the basic operations, including add, subtract,
multiply, complement, and shift. The number of bits required for the opcode is determined by the
number of functions the computer gives. For ‘2n’ operations, the minimum bits accessible to the
opcode should be ‘n’, where n is the number of bits. We implement these operations on
information saved in processor registers or memory.
Types of Opcodes
There are three different types of instruction codes on the main computer. The instruction's
operation code (opcode) is 3 bits long, and the remaining 13 bits are determined by the operation
code encountered.
There are three types of formats:
1. Memory Reference Instruction: It specifies the address with 12 bits and the addressing
mode with 1 bit (I). For direct addresses, I equal 0, while for indirect addresses, I equal 1.
2. Register Reference Instruction: The opcode 111 with a 0 in the leftmost bit of the
instruction recognizes these instructions. The remaining 12 bits specify the procedure to be
carried out.
3. Input-Output Instruction: The operation code 111 with a 1 in the leftmost bit of instruction
recognizes these instructions. The input-output action is specified using the remaining 12
bits.
Address
We represent the memory address where a given instruction is built. We use an instruction code's
address bits as an operand rather than an address. The instruction in such methods has an
immediate operand. The command is directed to a direct address if the second portion contains
an address.
In the second half, there is another choice, which includes the operand's address. It points to an
oblique address. One bit might indicate whether the instruction code executes the direct or
indirect address.
Addressing Modes
We can mainly describe the address field for instruction in the following ways:
 Direct Addressing − Uses the address of the operand.
 Indirect Addressing − Enables the address as a pointer to the operand.
 Immediate operand − The second part of the instruction code specifies an operand.

Accumulator Register (AC): This register is found in single register processors (AC), and it
performs all operations with memory operands.
Effective Address (EA) is the address of the operand or the target address. It defines the address
that we can execute as a target address for a branch type instruction or the address we can use
directly to create an operand for a computation type instruction without any changes.
Types of Addressing Modes
We have discussed below different types of addressing modes:
Immediate Mode
An immediate mode instruction specifies the operand in the instruction itself rather than the
address field. For example, the expression “ADD 100” adds 100 to the contents of the
accumulator. 100 here is the operand.
Register Mode
We store operands in the register in the CPU, and instruction addresses are the addresses of the
registers in which operands are stored.

Advantages:
 Shorter instructions and faster instruction fetch.
 Speedier memory access to the operand(s).
Disadvantages:
 Minimal address space.
 Using multiple registers allows performance, but it complicates the instructions.
Register Indirect Mode
A register that specifies the address of an operand located in memory is used in this mode. Thus,
the register possesses the address of the operand rather than the operand itself.
Auto Increment/Decrement Mode
The register increments or decrements after or before it uses the value.
Direct Addressing Mode
In this, we include the operand's effective address in the instruction.
Data is accessed using a single memory reference.
There are no extra calculations required to determine the operand's effective address.
For example, in ADD C2, 1000, the 1000 represents the operand's effective address.
NOTE: The operand's effective address is where we found it.
Indirect Addressing Mode
The address component of the instruction defines where the effective address is stored in
memory because several memory lookups are required to locate the operand, slowing down the
execution.
Displacement Addressing Mode
To acquire the effective address of the operand, we append the contents of the indexed register to
the Address section of the instruction.
EA = A + (R), where the address field contains two values: A (the base value) and R (the
Displacement), or vice versa.

Relative Addressing Mode


It's a Displacement addressing mode variant. PC (Program Counter) contents are added to the
instruction's address component to acquire the effective address.
EA = A + (PC), where PC is the program counter, and EA is the effective address.
A cell apart from the current cell is the operand (the one pointed to by PC).
Base Register Addressing Mode
It's a variation of Displacement addressing mode.
EA = A + (R), where A is the displacement and R is the pointer to the base address.
Stack Addressing Mode
In this addressing mode, the operand is at the top of the stack. For example, ADD; this
instruction will POP the top two items off the stack, add them, and then PUSH the result to the
top of the stack. This is how ADD instruction works.

FAQs
1. What is the instruction code?
Ans: An instruction code is a sequence of bits that tells the computer how to do something. An
instruction's operation code is a set of bits that describe operations like addition, subtraction,
shift, complement, etc.
2. What is the instruction address?
Ans: An instruction address is a special-purpose register that is used to hold the next instruction's
address to be performed during the execution of a series of instructions in a computer program.
3. What are the three basic types of instruction?
Ans: A primary computer has three instruction code formats which are:
 Memory-reference instruction
 Register-reference instruction
 Input-Output instruction

4. What is an effective address?


Ans: Effective Address (EA) is the address of the operand or the target address. It defines the
address that we can execute as a target address for a branch type instruction or the address we
can use directly to create an operand for a computation type instruction without any changes.
5. Why are Opcodes and operands in Instruction code?
Ans: Each statement in assembly language is composed of an opcode and an operand. The
opcode is the instruction that the CPU executes, and the operand is the data or memory location
where that instruction is executed.
The data itself or the place where data is to be processed is provided by an operand (expressed as
hexadecimal format). Some instructions don't require an operand, while others require multiple
operands.

You might also like