Relative Addressing (30.2.1) - 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

Relative Addressing

Relative Addressing

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.

Introduction to Addressing Modes

🔒 Unlock Audio Lesson

Sign up and enroll to listen to this audio lesson

0:00
--:--
Teacher
Teacher Instructor

Today, we will explore different addressing modes. Let's start with immediate addressing. What do you think it means to load a value immediately?

Student 1
Student 1

I think it means that the value is directly in the instruction itself.

Teacher
Teacher Instructor

Exactly! An example is when we say `LOAD IMMEDIATE 20`. The value `20` is loaded without needing to look anywhere else.

Student 2
Student 2

So, we don't access memory in this case?

Teacher
Teacher Instructor

Correct! Now, what about direct addressing? Can anyone explain that?

Student 3
Student 3

It uses a specific memory location to get data directly.

Teacher
Teacher Instructor

That's right! When you see `LOAD DIRECT 3`, it means we're getting data from memory location 3.

Student 4
Student 4

What happens if the data is not at that location?

Teacher
Teacher Instructor

Good question! If the data isn't there, we won't get what we expect. Now, let’s summarize: Immediate addressing means values directly in the instruction, while direct addressing refers to specific memory locations.

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 talk about indirect addressing. Who can explain how it differs from direct addressing?

Student 1
Student 1

Indirect addressing points to a memory location to find the actual data, right?

Teacher
Teacher Instructor

Exactly! For example, in `LOAD INDIRECT 5`, the content at memory location 5 tells us where the real data is. What do you think we call that?

Student 2
Student 2

The address of another memory location?

Teacher
Teacher Instructor

Yes, correct! Now, let's discuss register indirect addressing. Who remembers this method?

Student 3
Student 3

It loads data using values from registers instead of direct locations.

Teacher
Teacher Instructor

Spot on! For instance, `LOAD REGISTER INDIRECT 2` will access the content from the memory location pointed to by register 2. Can someone give an example of when we might use this?

Student 4
Student 4

In loops, maybe?

Teacher
Teacher Instructor

Exactly! Using registers helps efficiently manage data movements during iterations.

Displacement Addressing

🔒 Unlock Audio Lesson

Sign up and enroll to listen to this audio lesson

0:00
--:--
Teacher
Teacher Instructor

Let's explore displacement addressing now. What do you remember about it?

Student 1
Student 1

I think it involves two components: a memory address and a register value.

Teacher
Teacher Instructor

Correct! They get added together to form the effective memory address. Can anyone give a practical use case?

Student 2
Student 2

Arrays! We can use it to access each element in sequence.

Teacher
Teacher Instructor

Exactly! You can start at one location and increment through the array using a register. Anyone know what registers are often used in this context?

Student 3
Student 3

The program counter or a base register?

Teacher
Teacher Instructor

Right! The program counter is key for relative addressing. And what about base registers?

Student 4
Student 4

Base registers give a stable point from which we can make calculations.

Teacher
Teacher Instructor

Exactly! This flexibility makes displacement addressing very powerful, especially for jumps and loops.

Types of Relative Addressing

🔒 Unlock Audio Lesson

Sign up and enroll to listen to this audio lesson

0:00
--:--
Teacher
Teacher Instructor

Today we're going to discuss types of relative addressing. What's the first variant we should discuss?

Student 1
Student 1

Relative addressing, where we add values from the program counter!

Teacher
Teacher Instructor

Correct! In relative addressing, we adjust our memory accesses based on the program counter's current value. Can anyone provide an example?

Student 2
Student 2

If the program counter points to 1 and we add 15, we access memory location 16?

Teacher
Teacher Instructor

Exactly! Now, let's talk about base register addressing. How does that differ?

Student 3
Student 3

We use a specific register as the base address instead of the program counter.

Teacher
Teacher Instructor

Right! The base register allows us to establish a particular base address, modifying it as needed. Lastly, what about index register addressing?

Student 4
Student 4

We can use any general-purpose register for loops, right?

Teacher
Teacher Instructor

Exactly! It makes accessing memory elements convenient. Great job summarizing the key concepts!

Introduction & Overview

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

Quick Overview

This section examines relative addressing, focusing on various addressing modes like immediate, direct, indirect, and how they relate to memory and registers.

Standard

The chapter delves into different addressing modes, especially relative addressing, which allows operations to utilize memory locations determined by the program counter or registers. Various examples illustrate how immediate, direct, indirect, and displacement addressing function, emphasizing their significance in accessing data.

Detailed

Detailed Summary

This section focuses on the concept of relative addressing in computer architecture, exploring different addressing modes crucial for instruction execution. It begins by explaining basic memory operations, where specific instructions like LOAD IMMEDIATE, LOAD DIRECT, and LOAD INDIRECT showcase how data can be loaded from either immediate values, directly from memory locations, or indirectly through memory addresses stored in other locations.

Key Addressing Modes Explained:

  • Immediate Addressing: The value is provided directly in the instruction, eliminating the need for referencing memory. For example, a command like LOAD IMMEDIATE 20 means the value 20 is stored directly in the accumulator.
  • Direct Addressing: This mode uses a specific memory location directly. For instance, LOAD DIRECT 3 loads the value from the third memory location.
  • Indirect Addressing: Here, the instruction does not contain the final data; instead, it references another memory location to find the data. An example is LOAD INDIRECT 5, meaning the value at memory location 5 points to another location where the actual data resides.
  • Register Indirect Addressing: Similar to indirect addressing, but uses values from registers. LOAD REGISTER INDIRECT 2 loads data found in the memory location indicated by register 2.

The section also elaborates on displacement modes, explaining how they utilize two components: an explicit address and a register value. This method is efficient in loops and array access as it allows dynamic memory location addressing by adding these two components together.

Finally, variations like relative addressing, base register addressing, and index register addressing are discussed with examples. This section emphasizes how these modes are not only fundamental for operations but also crucial for enhancing the efficiency and flexibility of programs in fetching and storing data in a structured manner.

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.

Immediate Addressing

Chapter 1 of 7

🔒 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. [...] It is says load immediate 20.

Detailed Explanation

Immediate addressing means the actual value we want to use is part of the instruction itself rather than being stored in a memory location. In this example, when we use 'LOAD IMMEDIATE 20', we are telling the system to directly load the value '20' into the accumulator. This type of addressing is very straightforward as it requires no further referencing to memory or registers.

Examples & Analogies

Think of this like sending a letter where the message is written directly on the envelope. You don't need to open up the envelope to see what the message is; it's right there, just like how the value '20' is directly in the instruction.

Direct Addressing

Chapter 2 of 7

🔒 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, load accumulator 3; that means, to the accumulator you load the data which is present in memory location 3 that is 20.

Detailed Explanation

In direct addressing mode, we refer directly to a memory address. Here, 'LOAD DIRECT 3' means we want to load data from the memory location '3' directly into the accumulator. If we look at memory location '3', we find that it contains the value '20', so that value gets loaded into the accumulator.

Examples & Analogies

Imagine you have a container with numbered slots, and you know that the slot number 3 contains a specific item, say a ball. When you say 'get me the ball from slot 3', you directly access that slot and retrieve the ball, just like accessing memory directly.

Indirect Addressing

Chapter 3 of 7

🔒 Unlock Audio Chapter

Sign up and enroll to access the full audio experience

0:00
--:--

Chapter Content

Then LOAD INDIRECT 5. [...] So, what is memory location 1 present; that is 49.

Detailed Explanation

Indirect addressing introduces an additional layer of reference. In this case, 'LOAD INDIRECT 5' means that we first check memory location '5', which stores another value, say '1'. We then use that value to find the actual data we want, which is located in memory location '1'. Hence, we load the value '49' into the accumulator through this two-step process.

Examples & Analogies

This method is like asking someone to fetch a book for you. You tell them to first go to a specific shelf (memory location '5') and find the number of the book (which is at location '1'). They go and get that number and then head to another shelf to find the book corresponding to that number.

Register Direct Addressing

Chapter 4 of 7

🔒 Unlock Audio Chapter

Sign up and enroll to access the full audio experience

0:00
--:--

Chapter Content

Then LOAD REGISTER DIRECT 2. [...] So, as I told you our assumption was register 2 has the value 3.

Detailed Explanation

In register direct addressing, the instruction specifies to load data from a register rather than directly from memory. For example, 'LOAD REGISTER DIRECT 2' tells us to load the content of register '2' (which has the value '3') into the accumulator. This means we are directly using values stored in registers rather than going through memory.

Examples & Analogies

Think of this like having a toolbox where each tool is in a specific spot. If I say 'get me the tool at spot 2', you don’t have to look through a warehouse (the memory), because you already know exactly where it is in your toolbox.

Register Indirect Addressing

Chapter 5 of 7

🔒 Unlock Audio Chapter

Sign up and enroll to access the full audio experience

0:00
--:--

Chapter Content

But in case of register indirect we first refer to register 2, [...], the content of 20 will be loaded over here.

Detailed Explanation

In register indirect addressing, the register holds the address of the memory location we want to access. If 'LOAD REGISTER INDIRECT 2' is given, it means we first look at register '2' to find out which memory location to access (which contains '3') and then load from that memory location ('3') into the accumulator. This adds flexibility since the memory location can vary depending on the content of the register.

Examples & Analogies

This is like using a map (the register) that tells you where to find a treasure (the data in memory). Your friend (the accumulator) won't know what treasure to look for unless you first check your map for the right coordinates.

Displacement Addressing

Chapter 6 of 7

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

Detailed Explanation

Displacement addressing is a mix of both memory and register addresses. It typically uses two components: one is a specific memory address and the other is a value from a register. By adding these two values together, we find the effective memory location where the data is located. This mode is often useful for loops and array accessing, enabling you to easily move through contiguous memory locations.

Examples & Analogies

Think of this like using a GPS app to get to a series of locations (like delivering parcels). The app might tell you to start at your current location (the base register) and then drive a specific distance (the displacement or offset) to reach each destination.

Advantages of Displacement Addressing

Chapter 7 of 7

🔒 Unlock Audio Chapter

Sign up and enroll to access the full audio experience

0:00
--:--

Chapter Content

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

Detailed Explanation

Using displacement addressing allows for great flexibility and efficiency, particularly when working with loops or arrays. For instance, if you're writing a piece of code that needs to process multiple items stored in memory, you can start from one memory location and incrementally access subsequent locations by simply adjusting the value in a register. This makes it far easier to manage data structures like arrays where elements are stored in contiguous locations.

Examples & Analogies

Imagine you are reading a book and you decide to read multiple chapters. Instead of flipping back and forth (like referencing different memory locations), you just note the page number of the last chapter you read, then you only adjust the page number as you continue reading—the adjustment is similar to how we adjust using registers.

Key Concepts

  • Immediate Addressing: Value is part of the instruction.

  • Direct Addressing: Accessing specified memory location directly.

  • Indirect Addressing: Refers to another location for the actual data.

  • Register Indirect Addressing: Using registers to point to memory addresses.

  • Displacement Addressing: Combines memory address and register value to calculate an effective address.

  • Relative Addressing: Uses the program counter to determine memory locations.

  • Base Register Addressing: Uses a fixed base address stored in a specific register.

  • Index Register Addressing: Employs general-purpose registers for loops and iterations.

Examples & Applications

In LOAD IMMEDIATE 20, the instruction specifies that 20 is directly loaded into the accumulator.

For LOAD DIRECT 3, the system accesses memory location 3 directly, retrieving its value.

In LOAD INDIRECT 5, the instruction accesses memory location 5, which contains another address leading to the actual data.

Using LOAD REGISTER INDIRECT 2, the instruction leverages the content of register 2 to find what should be loaded into the accumulator.

Memory Aids

Interactive tools to help you remember key concepts

🎵

Rhymes

To IMMEDIATE load, the value's in the code, direct from the line, no memory to erode.

📖

Stories

Imagine you're a postman. Immediate addressing is when you deliver a letter that holds the address right inside, skipping any mailbox. Direct addressing is reaching directly to the mailbox with a specific name on it, whereas indirect addressing requires looking up a particular mailbox to find another address before delivering.

🧠

Memory Tools

D-R-I (Direct, Register, Indirect): Remember to Deliver results from Direct and Register, and Indirect handles another address.

🎯

Acronyms

D.R.I.S (Direct, Register Indirect, Indirect, Static)

For accessing types in a sequence - remember D.R.I.S!

Flash Cards

Glossary

Immediate Addressing

A mode where the value is explicitly included in the instruction itself.

Direct Addressing

A mode that accesses a specific memory location directly to retrieve data.

Indirect Addressing

An addressing mode where the instruction refers to a memory location that holds the address of the actual data.

Register Indirect Addressing

A mode that uses register values to point to memory locations, retrieving data indirectly.

Displacement Addressing

An addressing method that combines a base address with a value from a register to determine the effective address.

Relative Addressing

A form of displacement addressing tied to the current value of the program counter.

Base Register Addressing

An addressing mode where data is accessed using a base address stored in a specific register.

Index Register Addressing

Using a general-purpose register to facilitate iteration, commonly in loops.

Reference links

Supplementary resources to enhance your learning experience.