L-2.1: What is Addressing Mode | Various Types of Addressing Modes | COA

Gate Smashers
6 Sept 201911:45

Summary

TLDRIn this educational video, the concept of addressing modes in computer architecture is explored, emphasizing its significance in programming and exams. Addressing modes dictate how operand bits in instructions are interpreted, whether as direct data, memory addresses, or register numbers. The video outlines the benefits of addressing modes, such as reducing instruction size by using registers instead of memory addresses, and facilitating features like pointers, looping, and indexing. It introduces various addressing modes including immediate, direct, and indirect, and sets the stage for a detailed discussion in the next video.

Takeaways

  • 💡 Addressing mode is a crucial concept in computer organization and architecture, frequently appearing in competitive exams and academic curricula.
  • 📝 The script explains that an instruction typically contains an opcode and an operand, where the operand refers to the data on which operations are performed.
  • 🔍 Addressing mode clarifies how operand bits in an instruction should be interpreted, whether as direct data, memory addresses, or register numbers.
  • 👨‍💻 The video highlights the practical application of addressing modes in programming, especially when dealing with variables and constants.
  • 📉 Addressing modes can reduce the number of bits required in an instruction by utilizing registers instead of direct memory addresses, thus compacting instruction size.
  • 🔄 The script introduces various types of addressing modes including implied, immediate, register, indirect, direct, auto-increment, decrement, and others, which are essential for different programming scenarios.
  • 🏢 RISC systems typically have 4 to 6 addressing modes, while CISC systems may have more, reflecting the complexity and flexibility in handling data.
  • 🔑 Addressing modes facilitate advanced programming concepts like pointers, where the address of a variable is used in place of the data itself.
  • ➕ They also support looping constructs and counters through auto-increment and decrement modes, streamlining repetitive operations.
  • 🔄 The concept of relocation is discussed, explaining how addressing modes help in adjusting memory addresses when a program is moved to a different location in memory.

Q & A

  • What is an addressing mode in computer architecture?

    -An addressing mode is a way to determine how the operand of an instruction is used. It tells the CPU how to interpret the bits in the operand to access the data it needs to perform an operation.

  • Why are addressing modes important in computer organization?

    -Addressing modes are important because they allow for efficient use of memory and registers, reduce the size of instructions, and provide flexibility in how data is accessed and manipulated during program execution.

  • What are the benefits of using addressing modes?

    -Using addressing modes can reduce the number of bits required in an instruction, facilitate the use of pointers and looping constructs, and support features like indexed addressing and relocation.

  • What is the difference between an operand and an opcode in an instruction?

    -An operand is the data or address that an instruction operates on, while an opcode is the part of the instruction that specifies the operation to be performed, such as addition or subtraction.

  • How does an addressing mode help in the case of variables in programming?

    -Addressing modes help with variables by allowing the instruction to refer to the data indirectly through a register or memory address, rather than embedding the actual data value directly in the instruction.

  • Can you give an example of how addressing modes are used with constants in programming?

    -When a constant value like Pi is used in a program, the addressing mode might allow the instruction to directly embed the constant value in the operand, simplifying the instruction and potentially reducing its size.

  • What is the purpose of the indirect addressing mode?

    -The indirect addressing mode is used when the operand contains an address that points to the actual data location. This allows for multi-level indirection where the address in the operand leads to another address that contains the data.

  • How do auto-increment and auto-decrement addressing modes work?

    -Auto-increment and auto-decrement addressing modes automatically adjust the address in the operand by a specified amount after each access. This is useful for iterating through data structures like arrays or for implementing loops.

  • What is the role of addressing modes in supporting indexed data access?

    -Indexed addressing modes allow the CPU to access data based on a base address and an offset. This is useful for accessing elements in arrays or for implementing algorithms that require data access based on a variable index.

  • Why is addressing mode crucial for relocation in computer systems?

    -Addressing modes are crucial for relocation because they help in adjusting the addresses of instructions and data when a program is moved from one memory location to another, ensuring that the program can execute correctly regardless of its location in memory.

Outlines

00:00

💡 Introduction to Addressing Modes

The speaker introduces the concept of addressing modes in computer architecture, emphasizing its importance in competitive exams and academic studies. Addressing modes are crucial for understanding how instructions in a computer program interact with data. The speaker explains that instructions typically consist of an opcode (operation code) and an operand (data). The operand can be data itself, or it can be an address where the data is stored, such as in memory or registers. Addressing modes dictate how these operands are treated within an instruction, whether as direct data, memory addresses, or register numbers. The paragraph sets the stage for a deeper exploration of addressing modes and their significance in various programming scenarios.

05:00

🔑 Benefits and Types of Addressing Modes

This paragraph delves into the benefits of addressing modes, such as reducing the number of bits required in an instruction by using register numbers instead of memory addresses. The speaker illustrates this with an example of a 1M memory size requiring 20 bits for addressing, but only 4 bits if using register numbers. Addressing modes also facilitate the use of pointers, looping with automatic increment and decrement, and indexing. The paragraph lists various types of addressing modes, including implied, immediate, register, indirect, direct, auto-increment, decrement, relative address mode, indexed addressing mode, and base register. The speaker notes that RISC systems typically have fewer addressing modes compared to CISC systems, which can have more complex and varied addressing modes.

10:01

🔄 Addressing Modes in Practical Computing

The final paragraph discusses the practical applications of addressing modes in computing. It explains how addressing modes help in executing instructions that involve variables, pointers, and looping. The speaker mentions that the value of variables is determined at runtime, and addressing modes are essential for accessing this data during instruction execution. The paragraph also touches on the concept of relocation, where the execution of a process may occur at different memory locations over time, and addressing modes help in adjusting the memory addresses accordingly. The speaker concludes by stating that the next video will explore each addressing mode in detail, promising a deeper understanding of how these modes facilitate various programming tasks.

Mindmap

Keywords

💡Addressing Mode

Addressing mode refers to the way in which a processor specifies the location of an operand, which is the data it operates on. In the context of the video, addressing modes are crucial for understanding how instructions interact with data in computer architecture. The video explains that addressing modes determine whether an operand represents direct data, a memory address, or a register number. This concept is foundational to the video's theme, as it sets the stage for discussing various types of addressing modes and their applications in programming and computer operations.

💡Operand

An operand is the data that an instruction operates on. In the video, the term is used to explain that in programming, operations such as addition or subtraction are performed on data, which can be constants or variables. Operands are integral to the video's discussion of addressing modes because they are the elements whose addresses or values are manipulated by these modes. The video clarifies that operands can be stored in memory or registers, and addressing modes dictate how these operands are accessed during instruction execution.

💡Opcode

Opcode stands for operation code and represents the part of an instruction that specifies the operation to be performed, such as addition, subtraction, or multiplication. The video uses opcode in the context of explaining the structure of an instruction, which typically includes both an opcode and an operand. Understanding opcodes is essential for grasping how addressing modes fit into the larger picture of instruction execution, as opcodes define the actions to be taken on the data pointed to by operands.

💡Memory

Memory refers to the computer's storage where data and instructions are held. In the video, memory is discussed in relation to where operands can be stored. Addressing modes are important because they determine how the processor retrieves data from memory. The video explains that operands can be direct data or the address of data stored in memory, highlighting the significance of memory in the context of addressing modes and instruction execution.

💡Registers

Registers are small, fast storage locations within the CPU used to hold temporary data. The video mentions registers as an alternative to memory for storing operands, which can help reduce the size of instructions. By using registers, the video suggests that addressing modes can facilitate more efficient data access and manipulation, as register numbers can be represented with fewer bits than memory addresses, thus saving space in the instruction set.

💡Direct Addressing Mode

Direct addressing mode is one of the types of addressing modes discussed in the video, where the operand directly contains the memory address of the data. This mode is straightforward and efficient for accessing data because the address is explicitly provided in the instruction. The video implies that direct addressing is a fundamental mode that allows for quick data retrieval, which is essential for performance in computer systems.

💡Indirect Addressing Mode

Indirect addressing mode is another addressing mode mentioned in the video, where the operand contains the address of another location that holds the actual data. This mode is useful for implementing pointers and accessing data through intermediate addresses. The video explains that indirect addressing allows for more complex data access patterns, such as those used in linked data structures or when working with pointers in programming.

💡Indexed Addressing Mode

Indexed addressing mode is used when data is accessed through a base address plus an offset. The video suggests that this mode is beneficial for accessing elements in arrays or performing operations on blocks of data with a common base address. Indexed addressing is a powerful concept in the video's discussion of addressing modes, as it enables efficient access to sequential data structures, which are common in programming.

💡Relocation

Relocation in the context of the video refers to the process of adjusting memory addresses in code or data when a program is moved to a different memory location. This concept is important for understanding how programs can be executed in different environments or memory spaces without hardcoding specific addresses. The video implies that addressing modes play a role in relocation by allowing for flexible address interpretation that can be adjusted as needed.

💡Instruction Size

Instruction size refers to the number of bits or bytes required to represent an instruction in a computer's architecture. The video discusses how addressing modes can influence instruction size, particularly in terms of reducing the number of bits needed to specify operands. By using registers or other compact addressing modes, the video suggests that the size of instructions can be minimized, which can lead to more efficient use of memory and potentially faster execution.

Highlights

Addressing mode is a crucial topic in computer organization and architecture.

Addressing modes are important for competitive exams and college/university level exams.

An instruction typically contains an opcode and an operand, where the operand refers to data.

Opcode represents the operation such as addition, subtraction, or multiplication.

In micro-instructions, data is not directly included but rather the address of the data.

Addressing mode determines how to treat operand bits in an instruction.

There are various types of addressing modes, including implied, immediate, register, indirect, direct, and more.

Addressing modes can reduce the number of bits needed in an instruction by using registers instead of direct memory addresses.

Addressing modes facilitate the use of pointers in programming by interpreting operand bits as memory addresses.

Auto-increment and auto-decrement addressing modes are used for looping and counters in programs.

Indexed addressing mode allows for data indexing, which is useful in arrays and similar data structures.

Relocation is made possible by addressing modes, which is essential when a program's memory location changes.

Addressing modes help in executing instructions that involve variables, whose values are determined at runtime.

Immediate mode allows for passing direct values in instructions, which is different from using variable values.

The video will cover each addressing mode in detail in the next part.

Transcripts

play00:00

Hello friends, welcome to Gate Smashers

play00:02

In today's video, we are going to discuss what is an addressing mode

play00:05

and what are the types of addressing mode

play00:08

If we talk about computer organization and architecture

play00:10

then addressing mode is one of the most important topic

play00:14

because if you talk about any competitive exam

play00:16

or if you talk about college or university level exam

play00:20

then there also you will definitely get the question of addressing mode

play00:25

and it is a very simple topic

play00:27

First in this video I am going to tell you what is addressing mode

play00:30

What are the benefits of addressing mode and what it is providing us

play00:33

and then what are the types of addressing mode

play00:36

which we will explain one by one

play00:38

So here if we talk about what is an addressing mode

play00:41

So if we talk about instruction

play00:43

which we are discussing about in the previous videos

play00:46

So generally in instruction what we have in instruction

play00:50

Opcode and operand

play00:55

What is operand generally?

play00:57

Operand means data

play00:59

Means which data you have to work on

play01:01

and what is opcode? Operation

play01:03

Means plus, minus, multiplication

play01:07

Now on what you will do plus minus multiplication?

play01:09

Will do on data only

play01:11

Like we write programs in simple C

play01:12

A is equal to 10, int B is equal to 20

play01:15

C is equal to A plus B

play01:17

Means we are doing addition or subtraction

play01:19

So the data which we pass

play01:21

This data

play01:22

What we are saying about operand is actually

play01:26

We are talking about data

play01:28

But if we talk about an instruction

play01:31

If we talk about any micro-instruction

play01:33

Then in instruction we don't have data directly

play01:37

What can we have?

play01:39

The address of that data can be

play01:41

Means the data which we are bringing in the computer

play01:44

Whatever data is coming, which we are passing in the programs

play01:47

That data is either saved in our memory

play01:49

Or that data is saved in our registers

play01:52

So what we are writing operand here

play01:54

Whatever data we are writing here

play01:56

Whatever bits we are writing here

play01:58

What are those bits actually representing?

play02:00

Are they directly representing data?

play02:02

Or are they representing some address of memory?

play02:05

Or are they representing some number of register?

play02:08

What is that actually?

play02:10

We get to know from addressing mode

play02:11

So addressing mode basically tells us

play02:14

That how to treat these operand bits

play02:17

Means how to consider them

play02:20

This actually tells us addressing mode

play02:22

So here if we talk

play02:24

We can give direct data here

play02:26

Or we give the address that we generally give here

play02:30

Why? Because if we talk about programming

play02:32

Then in programming we work on variables

play02:35

We work on constant

play02:36

If we are giving directly constant

play02:38

In any C program we are giving direct constant value

play02:41

Let's say we are giving the value of constant Pi

play02:44

Now what is the value of Pi? It is constant

play02:46

Now if you are giving this constant value

play02:48

Then you can give that data directly in the instruction

play02:51

But generally we work on variables

play02:54

We can also work like this in variables

play02:56

Like if I have data

play02:58

A is equal to B * C

play03:00

Now here when will A come

play03:04

A value will come when we execute B * C

play03:07

Means when this instruction will be executed

play03:09

After that I will get to know the A value

play03:13

Now this A value

play03:14

How can I give it in the instruction?

play03:17

When I will get to know after the execution of the instruction

play03:21

That what is the value of A

play03:22

Then we can never give the value of data

play03:25

Directly in the instruction

play03:27

Means you can't write directly

play03:28

Subtraction 2

play03:30

Or subtraction 3

play03:32

Or multiplication 4

play03:33

What do we actually give?

play03:35

We work on variables

play03:37

So whenever we talk about variables in programs

play03:39

Or we ask the user for data many times

play03:41

We write scanf

play03:42

So scanf is when we ask the user for data

play03:45

At run time

play03:46

When the program runs and is executed

play03:48

At that time we take data from the user

play03:50

So for these type of instructions

play03:52

We can't give the data directly in the instruction

play03:56

So here I have these bits

play03:59

How we have to treat them

play04:01

How to consider them

play04:03

That actually tells us

play04:04

Addressing mode

play04:05

So generally the variables we have

play04:08

They are generally saved in our memory

play04:10

Whatever data they have

play04:12

Or where they are saved

play04:14

They are saved in the registers

play04:16

So there we have the data given in operand

play04:19

Is it address?

play04:21

Is it the number of the register?

play04:22

These bits how to consider

play04:25

This tells us addressing modes

play04:27

So addressing modes are different types of addressing modes

play04:30

Which I have written here

play04:31

Implied, immediate, register, indirect, direct

play04:34

Auto increment, decrement, direct addressing mode

play04:37

Relative address mode

play04:38

Indexed addressing mode, base register

play04:41

So if we talk about the risk environment

play04:43

If we talk about the risk systems

play04:45

Reduced instructions

play04:46

So there we have

play04:47

Near about 4 to 5 or 5 to 6 addressing modes

play04:51

But the CISC computers

play04:53

Means the complex instruction computers

play04:56

There we have many times

play04:58

Many addressing modes

play05:00

It depends

play05:01

In different computers

play05:03

Different computer organizations

play05:04

Different addressing modes can be

play05:06

But generally

play05:07

In the risk system

play05:08

There are 5 to 6 addressing modes

play05:11

Which tell us that these bits

play05:13

Whatever value is written in operand

play05:14

Whatever address is written

play05:16

How to treat it

play05:18

Now if we talk here

play05:20

What is the benefit of addressing mode

play05:22

The first benefit of addressing mode

play05:24

That number of bits

play05:26

We can reduce in the instruction

play05:28

How?

play05:29

Let's say

play05:30

If we have a memory

play05:32

And the size of the memory

play05:34

Let's say 1M

play05:35

Means 1 million words

play05:37

There are 1M words in this whole memory

play05:40

Now in these 1M words

play05:42

Your instruction can be anywhere

play05:44

Your data can be anywhere

play05:46

Now if you give in the instruction

play05:49

Address

play05:50

Where is your data

play05:52

So obviously the size of your address

play05:55

Will be 20 bits

play05:56

Because 1M is the location here

play05:59

So to represent 1M locations

play06:02

How many bits do we use?

play06:03

20 bits

play06:04

So the space of your address in the instruction

play06:07

Which is the space of operand

play06:09

How many bits will it be?

play06:10

It will be 20 bits

play06:12

And we also have opcode bits

play06:14

So the size of your instruction

play06:16

Will increase

play06:17

So we can keep data in the register

play06:21

If we talk

play06:22

Let's say we have 16 registers

play06:25

Number of registers is 16

play06:28

So obviously in 16 registers

play06:30

Where can the data be read

play06:31

Any register can have data read

play06:34

So if I want to represent 16 registers in bits

play06:38

How many bits will I use?

play06:40

4 bits

play06:41

How?

play06:41

From 0 to 15 number of registers

play06:44

Total registers will be 16

play06:46

And if we want to represent 16 from 0 to 15

play06:49

How many bits do we use?

play06:51

4 bits

play06:52

So if we want to reduce the size of the instruction

play06:55

Then we can keep the data in the register

play06:57

And we can pass the register number in operand

play07:01

So how many will be here?

play07:03

How many bits will be here instead of 20 bits?

play07:06

4 bits

play07:06

So the size of this will be reduced

play07:10

So this basically provides the facility to the programmer

play07:12

That you can reduce the instruction size

play07:15

You can reduce the bits

play07:17

Apart from this

play07:18

If we talk about

play07:19

Let's say we use pointers in our program

play07:23

What is a pointer?

play07:24

Let's say if I say int a is equal to 10

play07:28

Now what will happen?

play07:29

A variable will be saved in memory

play07:32

And the value in it will be 10

play07:34

Now this location

play07:36

Let's say the location is 100

play07:38

Now if I pass the pointer

play07:39

Let's say there is a pointer ptr

play07:41

And what will we do in ptr?

play07:43

We will pass address of a

play07:45

So address of a is 100

play07:47

So what value will come in ptr?

play07:49

100

play07:50

So here we are using the pointer

play07:53

We will go to a location

play07:54

Let's say this is my memory

play07:56

We checked operand

play07:59

The value in operand was 100

play08:01

We went to 100 location

play08:02

The data in 100 location

play08:05

Is it our direct data?

play08:07

Or is it also an address?

play08:08

We also know this through

play08:10

Addressing mode

play08:12

It may be that the value is 200

play08:14

Now what to consider 200?

play08:16

Is it an address?

play08:17

Or is it data?

play08:19

If we talk about indirect mode

play08:21

So what does indirect mode say?

play08:23

That yes, this is also a location ahead

play08:26

Means you will have to go to 200 location from here

play08:29

Whatever data is there in 200 location

play08:31

10, 20

play08:32

Pick it up and use it

play08:34

So if we want to facilitate pointers here

play08:37

Then we can use the addressing mode here

play08:40

Or if we talk about counters

play08:43

Let's say if we talk about looping

play08:46

There is a for loop, for i is equal to 1 to 10

play08:48

Now here we want that if

play08:50

For i is equal to 1 to 10 is written

play08:53

And we printf it

play08:55

So what does it mean?

play08:56

Here 1 to 10 automatically increments

play09:01

So automatically for increment and decrement

play09:03

We have a facility in addressing mode

play09:06

Apart from this, indexing

play09:07

If we want to put indexing in the data

play09:10

Then we also have the facility of indexing

play09:12

Indexed addressing mode

play09:13

And apart from this we have relocation

play09:16

Relocation means

play09:17

Let's say I have a data

play09:19

Means the data is in the memory

play09:22

The data is in 100 to 200

play09:24

Any process is there in 100 to 200

play09:27

Now in that process

play09:29

Or in those instructions we have written

play09:31

Whatever instruction is written on 100

play09:33

Let's say go to

play09:35

170 location

play09:37

Means jump to 170

play09:39

Now here you will go to 170

play09:41

Whatever instruction is written

play09:43

You will pick up that instruction

play09:45

But what happens is

play09:46

We use the funda of relocation

play09:48

Means when this process is executed by CPU

play09:52

Or will use it

play09:53

In future if this process comes again

play09:55

Then it is not necessary that it gets the same location

play09:58

It may get a different location

play10:01

Means now it may be between 500 to 600

play10:05

This process is now fit between 500 and 600

play10:09

Now here if I write go to 170

play10:13

Then what will happen?

play10:14

It will go to such an address

play10:16

Which is actually invalid

play10:19

Means go to 170 means

play10:22

According to this question

play10:24

It should have been go to 570

play10:26

It should have been at 70

play10:28

But who changes the addresses?

play10:30

To relocate these addresses

play10:32

We also use the concept of addressing mode

play10:35

So addressing mode provides many facilities and benefits

play10:39

That is what

play10:40

Basically if we are using looping

play10:42

Or if we are using pointers

play10:44

Or if we are using variables here

play10:48

All the variables we use

play10:49

The value of the variables is calculated at run time

play10:53

At execution time

play10:54

So if we want to bring the data at that time

play10:56

Then addressing mode only helps there

play10:59

We do not pass data directly in the instruction

play11:03

There are some modes

play11:04

Like there is an immediate mode

play11:06

I will bring them in detail one by one

play11:08

But here I am giving a simple example

play11:10

There are many instructions

play11:12

In which we can also pass direct value

play11:14

But what we write in most of the code

play11:16

We use variables

play11:18

So when the data of variables comes

play11:19

When we run the instruction

play11:22

When one instruction is run

play11:23

After that we get to know the other data

play11:25

So at that time we

play11:26

Can't pass the data inside the instruction

play11:30

So these are different benefits of addressing modes

play11:34

Which help us to execute all these points

play11:38

So now we will see all these modes in detail one by one in the next video

play11:42

Thank you.

Rate This

5.0 / 5 (0 votes)

Ähnliche Tags
Addressing ModesComputer ArchitectureMemory ManagementOpcode OperandInstruction SetProgramming ConceptsData ProcessingVariable HandlingInstruction SizeCISC vs RISC
Benötigen Sie eine Zusammenfassung auf Englisch?