Examples Of Addressing Modes (30.3) - Addressing Modes - Computer Organisation and Architecture - Vol 1
Students

Academic Programs

AI-powered learning for grades 8-12, aligned with major curricula

Professional

Professional Courses

Industry-relevant training in Business, Technology, and Design

Games

Interactive Games

Fun games to boost memory, math, typing, and English skills

Examples of Addressing Modes

Examples of Addressing Modes

Enroll to start learning

You’ve not yet enrolled in this course. Please enroll for free to listen to audio lessons, classroom podcasts and take practice test.

Practice

Interactive Audio Lesson

Listen to a student-teacher conversation explaining the topic in a relatable way.

Immediate Addressing Mode

🔒 Unlock Audio Lesson

Sign up and enroll to listen to this audio lesson

0:00
--:--
Teacher
Teacher Instructor

Today, we're going to learn about the immediate addressing mode. This mode allows us to use an operand directly in an instruction. For example, when I say `LOAD IMMEDIATE 20`, what happens?

Student 1
Student 1

The value of 20 gets loaded directly into the accumulator?

Teacher
Teacher Instructor

Exactly! No need to reference memory—it’s efficient. Can anyone remind me what it means for an instruction to be immediate?

Student 2
Student 2

It means the value is contained within the instruction itself.

Teacher
Teacher Instructor

Yes! Now let’s remember that with the acronym IMD: Immediate Means Direct!

Direct Addressing Mode

🔒 Unlock Audio Lesson

Sign up and enroll to listen to this audio lesson

0:00
--:--
Teacher
Teacher Instructor

Next, we move to direct addressing. When I mention `LOAD DIRECT 3`, what happens to the accumulator?

Student 3
Student 3

It loads the value stored in memory location 3 into the accumulator.

Teacher
Teacher Instructor

Correct! So what if memory location 3 contains the number 20?

Student 4
Student 4

Then the accumulator would hold 20 after executing that instruction.

Teacher
Teacher Instructor

Great! Remember the acronym DAVE: Direct Addressing = Value from Exact location!

Indirect and Register Indirect Addressing

🔒 Unlock Audio Lesson

Sign up and enroll to listen to this audio lesson

0:00
--:--
Teacher
Teacher Instructor

Now, let's dive into indirect addressing. With the command `LOAD INDIRECT 5`, why is it interesting?

Student 2
Student 2

Because it uses a value that points to another memory location!

Teacher
Teacher Instructor

Exactly! Memory location 5 might point to memory location 1, which holds data such as 49. So the accumulator would load 49. How about register indirect addressing? What’s different here?

Student 1
Student 1

It uses a register to indicate which memory location to access.

Teacher
Teacher Instructor

Right! For instance, if register 2 is 3, we look at memory location 3 for our data. Let's remember this concept using the mnemonic ‘ID2’: Indirect Data from 2nd location.

Displacement Addressing

🔒 Unlock Audio Lesson

Sign up and enroll to listen to this audio lesson

0:00
--:--
Teacher
Teacher Instructor

Lastly, let's look at displacement addressing. What does it involve?

Student 4
Student 4

It combines a register and a constant to find the memory address of the data.

Teacher
Teacher Instructor

Correct! If we say at memory location 3 we have the constant 2 in a register, then combining them gives us the effective memory location of 5. Who can think of when we might use this?

Student 3
Student 3

In loops! It would help us switch between different memory locations efficiently.

Teacher
Teacher Instructor

Exactly! Remember DM for Displacement Mode — it means ‘Dynamic Memory access’. Well done, everyone!

Introduction & Overview

Read summaries of the section's main ideas at different levels of detail.

Quick Overview

This section introduces different addressing modes, such as immediate, direct, indirect, and displacement modes, essential for accessing data in memory and manipulating data efficiently.

Standard

In this section, we dive into various addressing modes used in programming and computer architecture, detailing the immediate, direct, indirect, and displacement addressing modes, along with their applications and examples. The examples demonstrate how these modes influence data retrieval from memory and register utilization.

Detailed

Detailed Summary

This section provides a comprehensive examination of several key addressing modes in computer architecture. Addressing modes are crucial for determining how an instruction accesses data across memory and registers. The key modes discussed include:

  1. Immediate Addressing: This mode allows immediate data access; the value is specified directly in the instruction. For instance, LOAD IMMEDIATE 20 places the value 20 into the accumulator without referring to any memory location.
  2. Direct Addressing: Here, the instruction specifies a memory location directly. For example, LOAD DIRECT 3 would retrieve the value located at memory address 3 and load it into the accumulator.
  3. Indirect Addressing: This mode involves a memory location containing the address of the actual data. For instance, in LOAD INDIRECT 5, memory location 5 contains the address 1, which in turn contains the desired data (e.g., 49).
  4. Register and Register Indirect Addressing: In LOAD REGISTER DIRECT 2, data is retrieved from a specified register directly, while in REGISTER INDIRECT 2, the value in the register points to the memory location where the data resides.
  5. Displacement Addressing: This mode utilizes both a register and an explicit memory address to compute the effective address. For example, combining the contents of the register with a constant displacement allows for dynamic data access, crucial for loops and arrays.

Further, the section discusses variations such as relative addressing, base register addressing, and index register addressing, which reveal their importance in programming context, especially for jumps and iterations.

Youtube Videos

One Shot of Computer Organisation and Architecture for Semester exam
One Shot of Computer Organisation and Architecture for Semester exam

Audio Book

Dive deep into the subject with an immersive audiobook experience.

Loading Immediate Value

Chapter 1 of 10

🔒 Unlock Audio Chapter

Sign up and enroll to access the full audio experience

0:00
--:--

Chapter Content

So, let us write an instruction LOAD IMMEDIATE 20 that is may be the opcode can be something like LDI. Generally here I have discussed in a more linguistic manner, but we always have a mnemonic for that so it may be LDI that is load immediate or you can put some times a person may call it load indirect also. So, I you can also have the word load immediate it’s up to you how you define your instruction set. So, this is LOAD IMMEDIATE 20. So, what does it happen as an immediate? So, in that case the value of twenty binary twenty will be in the instruction itself in immediate mode of instruction you need not refer to any of the memory location neither you have to refer to any other register other than the accumulator. So, it says load immediate 20. So, in this case what happens the value of 20 that is 20 binary will be loaded into the accumulator.

Detailed Explanation

The instruction LOAD IMMEDIATE 20 indicates that the program should load the value 20 directly into the accumulator, a special register in the CPU used for arithmetic and logic operations. In immediate addressing mode, the value to be loaded is included in the instruction itself, which means there is no need to look for this value in memory or another register. The binary representation of 20 will be directly stored in the accumulator to be used in future operations.

Examples & Analogies

Imagine if you were given a shopping list (instruction) and asked to take a specific amount of money (value 20) directly from your wallet (accumulator) without checking your bank balance (memory). You don’t need to look anywhere else to find the cash; it’s simply right there in your wallet.

Loading Direct Value

Chapter 2 of 10

🔒 Unlock Audio Chapter

Sign up and enroll to access the full audio experience

0:00
--:--

Chapter Content

LOAD DIRECT 3 is a direct addressing mode. So, what is a direct addressing mode? Direct addressing modes means this 3 actually refer to the memory location 3 where the data is present in the memory location 3 so, direct. So, load accumulator 3; that means, to the accumulator you load the data which is present in memory location 3 that is 20. So, the 20 will be stored in the accumulator.

Detailed Explanation

In direct addressing mode, the instruction specifies a memory location directly. The instruction LOAD DIRECT 3 means that the processor will go to memory location 3 and fetch the data stored there, which is the value 20, and load it into the accumulator. This method requires looking up the memory to find the right data, unlike immediate addressing where the data is specified directly in the instruction.

Examples & Analogies

Think of it like looking up the address of a friend (memory location 3) in your contacts. When you want to send them something, you go directly to that address in your contacts to find their phone number (the value). You directly access the location where that information resides to get what you need.

Loading Indirect Value

Chapter 3 of 10

🔒 Unlock Audio Chapter

Sign up and enroll to access the full audio experience

0:00
--:--

Chapter Content

Then LOAD INDIRECT 5. Now this is interesting load indirect 5 means accumulator will be loaded with something which is present in memory location 5 memory location 5 has value 1 now it’s an indirect. So, 1 is not the data the data is actually present in memory location one. So, what is memory location 1 present; that is 49. So, the 49 will be stored in your accumulator that is load indirect 5, 5; 1 is the content this is nothing this is not the data or the operand basically it is the address of the memory where actually the operand is present or the data is present that is 49.

Detailed Explanation

The instruction LOAD INDIRECT 5 uses an address (5) to point to another location (memory) rather than directly to a value. Memory location 5 contains the value 1, which itself is the address of where the actual data (49) is stored. Thus, the accumulator will load the value found at memory address 1 (which is 49). This indirection adds an extra step in fetching data required for computation.

Examples & Analogies

Consider a library system where you have a catalog (memory location 5) that tells you where to find a specific book (data). When you look up the catalog and find the book isn’t there but instead it gives you a shelf number (the address). You need to go to that shelf number (memory location 1) to get the actual book (value 49).

Loading from Register Directly

Chapter 4 of 10

🔒 Unlock Audio Chapter

Sign up and enroll to access the full audio experience

0:00
--:--

Chapter Content

Then LOAD REGISTER DIRECT 2. So, in this case as I told you what it says it’s a direct it is a direct instruction, but instead of referring to a memory it is referring to register it is saying load register direct 2 that is you load to the accumulator what is available in register number 2. So, as I told you our assumption was register 2 has the value 3. So, it will be loaded into the register next is as this normally indirect so this is called register indirect 2.

Detailed Explanation

The instruction LOAD REGISTER DIRECT 2 is similar to direct addressing but instead of accessing memory directly, it retrieves data from a specified register (in this case, register 2). The value in register 2, which is assumed to be 3, is loaded into the accumulator. This method is efficient because accessing data from a register is faster than accessing data from memory.

Examples & Analogies

It’s similar to having a specific folder (register) on your desk where you keep important documents (data). When you need a document, you simply reach for that folder and pull it out quickly, rather than going through files stored elsewhere (memory), which might take more time.

Register Indirect Addressing

Chapter 5 of 10

🔒 Unlock Audio Chapter

Sign up and enroll to access the full audio experience

0:00
--:--

Chapter Content

So, register indirect 2 means so register 2 has a value of 3. So, now it’s the indirect mode of addressing. So, 3 is not the data basically you have to access memory location 3 because 3 is present over register 2 and the content is 20, so 20 will be loaded over here same thing like load indirect. But in case of register indirect we first refer to register 2, register 2 has the value 3; 3 is not the data over here we have to look at the memory location 3 is there where the content of 20 is there the 20 will go to the accumulator.

Detailed Explanation

Register indirect addressing utilizes a register to specify an address where the required data can be found. In this example, register 2 holds the value 3, which points to memory location 3. The instruction LOAD REGISTER INDIRECT 2 thus means the processor needs to look up memory location 3 to get the value 20 and load it into the accumulator. The effective memory address is determined using the value stored in the register.

Examples & Analogies

Imagine if your desk has a drawer (register 2) containing items. If you need an item located in a specific box (memory location 3) within that drawer, you first check which box the item is in (value 3 holds the address), and pull it out. This way, you are using the drawer to find what you need indirectly.

Displacement Addressing Mode

Chapter 6 of 10

🔒 Unlock Audio Chapter

Sign up and enroll to access the full audio experience

0:00
--:--

Chapter Content

But wherever you talk about displacing displacement basically you will find that there are two components of addresses which will be used together to get the effective one. So, what is the displacement mode it says it has 2 address field one contains an explicit address of main memory say that is a it has some explicit value and the other address field refers to a register whose content something say R it refers to some memory R that is one of this component refers to the memory another R correspondence to a register though just two components basically. One is for the memory and one is for the register for obtaining the exact value that where the operand will be present, these two are actually added.

Detailed Explanation

Displacement addressing mode combines two components: one is a fixed address in memory, and the other is an offset provided through a register. The effective address is calculated by adding the fixed address to the value in the register. This method allows for flexibility and ease in accessing data that is located at varying offsets from a base memory address.

Examples & Analogies

Think of this addressing mode as calculating the total cost of items in a shopping cart. The base price of the items (memory address) plus any discounts that are present in your wallet (register value) combine to determine how much you actually pay (effective address).

Types of Displacement Addressing

Chapter 7 of 10

🔒 Unlock Audio Chapter

Sign up and enroll to access the full audio experience

0:00
--:--

Chapter Content

So, there are lot of advantages of this means compared to the other one there are lot of applicability of this one first is if you think of loops then actually it will go say I want to access 10 memory locations one after the another. So, it will first start with say I can make this content as 0 then it will start with 3 this memory location is 3. So, it will start with 3 then I increase one then it will go for 4, 5, 6, 7, 8, 9, 10. So, I can just change the value of the register by 1 1 1 1 and you can continuously access first location second location third location and so forth.

Detailed Explanation

Displacement addressing can be particularly useful in programming scenarios such as loops or arrays. For example, if you are iterating over a series of memory locations (like a loop), by incrementing the register value, you can access one memory location after another easily. The flexibility allows for efficient processing of data collections with sequential memory addresses.

Examples & Analogies

Imagine you are picking apples from a row of trees (memory locations). Each time you pick an apple, you move to the next tree by taking a step (incrementing the register). Instead of having to remember where each tree is located, you can systematically proceed along the row.

Relative Addressing

Chapter 8 of 10

🔒 Unlock Audio Chapter

Sign up and enroll to access the full audio experience

0:00
--:--

Chapter Content

In fact, the variations all starts based on what register you are accessing for this. The second part is more or less constant that is constant in the sense that it refers to a memory location in the main memory, but what register you are using it for and what is the purpose we will define the different types of displacement addressing like first is the relative addressing. So, it is also called program counter relative addressing.

Detailed Explanation

Relative addressing involves using the program counter to determine the effective address. In this mode, the contents of the program counter, which points to the next instruction in a sequence, are combined with a displacement value to calculate where in memory the needed data is located. This method is essential for operations like jumps or branches in code, allowing software to dynamically navigate through memory.

Examples & Analogies

Think of this like a GPS system that tells you how far you are from a specific landmark (program counter). You can add or subtract distance from that landmark (displacement) to navigate to your next destination, adjusting your route based on your current location.

Base Register Addressing

Chapter 9 of 10

🔒 Unlock Audio Chapter

Sign up and enroll to access the full audio experience

0:00
--:--

Chapter Content

So, instead of the program counter if the referenced register contains a main memory address and the address field contains a displacement. So, if the name of the register if I call it as the base register instead of the program counter if it is a base register we call it as a base register addressing mode and if the address field as if the you have 3 type of registers basically.

Detailed Explanation

In base register addressing, instead of using the program counter as a reference, a designated base register provides the primary address. A displacement is then added to the value in the base register to calculate the effective address in memory. This technique is useful for accessing data that is organized in blocks or segments.

Examples & Analogies

This is like using a starting point on a map (base register) to get to different locations. By adding how far you want to go (displacement) from that starting point, you arrive at your desired destination seamlessly.

Index Register Addressing

Chapter 10 of 10

🔒 Unlock Audio Chapter

Sign up and enroll to access the full audio experience

0:00
--:--

Chapter Content

If indexed register addressing is generally used for loops like for example, 𝑖=𝑗,𝑖=1 to 10 then do something. So, that if I refer 𝑖 to a register then it will actually I called as the indexed register addressing. Because I will map 𝑖 to a general purpose register like an array if there is an array and I index it with 𝑗, so zeroth element, 1 element, 2 element, third element and so forth.

Detailed Explanation

Index register addressing allows programmers to efficiently navigate arrays by mapping an index variable to a general-purpose register. This approach lets the register hold the position of the current element in an array, allowing easy iteration through the elements by incrementing the index value within the loop structure.

Examples & Analogies

Imagine you are pulling books from a shelf organized by numbers (array). You designate an index card (register) that tells you which number to start from. Each time you take out a book, you increment the index card number by 1 to get to the next book. This way, you can access the entire collection without losing track.

Key Concepts

  • Immediate Addressing: Operand specified directly within instruction.

  • Direct Addressing: Operand memory location given directly in instruction.

  • Indirect Addressing: The instruction points to a location that holds the actual operand's address.

  • Displacement Addressing: Combines a base address in registers with a constant for dynamic addressing.

Examples & Applications

LOAD IMMEDIATE 20 places the value 20 in the accumulator without referring to memory.

LOAD DIRECT 3 retrieves the value from memory location 3 and loads it into the accumulator.

LOAD INDIRECT 5 uses the value at memory location 5 to find the actual operand at another memory location.

LOAD REGISTER DIRECT 2 refers directly to data in register 2.

LOAD INDIRECT using a register involves using the register value as an address pointer for nearest data.

Memory Aids

Interactive tools to help you remember key concepts

🎵

Rhymes

Immediate addressing is quick and neat, it loads direct, it can't be beat!

📖

Stories

Once upon a time in Data Land, a wizard named Addressing used his spells to fetch data from immediate realms, leading to fast retrievals without delays!

🧠

Memory Tools

ID = Immediate Direct; D = Direct Address, indirect uses a pointer to fetch!

🎯

Acronyms

AIMD

Addressing Immediate Mode Direct for quick retrieval.

Flash Cards

Glossary

Addressing Mode

A method used in computer architecture to specify how an operand is accessed in memory.

Immediate Addressing

A technique where the operand is specified within the instruction itself.

Direct Addressing

Addressing mode where the operand's memory address is given directly.

Indirect Addressing

An addressing mode where a memory location contains the address of the actual operand.

Displacement Addressing

An addressing mode that combines a register and a constant to determine an effective address.

Reference links

Supplementary resources to enhance your learning experience.