Addressing Modes of 8051 Microcontroller | Immediate | Register | Direct | Indirect | Indexed

Engineering Funda
18 Aug 202213:44

Summary

TLDRThis video from the microcontroller 8051 lecture series introduces and explains the five addressing modes of the 8051 microcontroller. It covers Immediate, Register, Direct, Indirect, and Indexed addressing modes with examples to clarify their applications in specifying operands for instructions. The explanation highlights the unique characteristics of each mode, such as using the accumulator for Register addressing and the use of the Data Pointer (DPTR) for Indirect addressing, as well as the distinction between accessing internal and external RAM and ROM through these modes.

Takeaways

  • 📘 Addressing modes define how operands are specified in microcontroller 8051 instructions.
  • 🔢 Immediate addressing mode involves specifying data directly in the instruction, prefixed with a hashtag (#).
  • 💾 Register addressing mode uses registers like A and R0-R7 to specify operands and requires the accumulator for certain operations.
  • 🏠 Direct addressing mode provides the address of the operand within the instruction, applicable for internal RAM or SFRs.
  • 🔑 Indirect addressing mode uses a register to give the address of the operand, allowing access to internal and external RAM.
  • 📍 External RAM access in 8051 requires 16-bit addressing with the DPTR register and the use of the 'X' in the 'MOVE' instruction.
  • 🔄 Indexed addressing mode is used to access data from code memory, which is separate from data memory in the Harvard architecture.
  • 🚫 Certain operations are not allowed, such as moving data directly between registers R0-R7 without using the accumulator in register addressing mode.
  • 📡 SFRs have a specific address range from 80H to FFH, while internal RAM addresses range from 00H to 7FH.
  • 🔣 Data in the instruction with a hashtag represents immediate data, which can be one or two bytes long.
  • 🛠 The script provides examples to illustrate each addressing mode, emphasizing the differences and specific use cases.

Q & A

  • What are addressing modes in the context of microcontroller 8051?

    -Addressing modes in the context of microcontroller 8051 are ways of specifying operands in an instruction. They define how data or memory locations are referenced within the instruction set of the microcontroller.

  • How many addressing modes does the 8051 microcontroller have?

    -The 8051 microcontroller has five addressing modes.

  • What is Immediate Addressing Mode and how is data specified in it?

    -Immediate Addressing Mode is a way of specifying operands where the data is included in the instruction itself. Data is specified by writing a hashtag (#) before the data value, which can be one or two bytes.

  • What is the significance of the hashtag symbol in Immediate Addressing Mode?

    -In Immediate Addressing Mode, the hashtag symbol indicates that the following value is data that is to be used directly in the instruction, rather than a memory location or register.

  • Can you provide an example of Immediate Addressing Mode?

    -An example of Immediate Addressing Mode is 'MOV A, #15h', which moves the hexadecimal data 15h into register A.

  • What is Register Addressing Mode and which registers are used in it?

    -Register Addressing Mode is a way of specifying operands using registers. In the 8051 microcontroller, registers A and R0 to R7 are used for this purpose.

  • Why can't registers R0 to R7 be used directly with each other in Register Addressing Mode?

    -In the 8051 microcontroller, you cannot use registers R0 to R7 directly with each other in Register Addressing Mode because the accumulator must be used as an intermediary for data transfer between these registers.

  • What is Direct Addressing Mode and how is the operand's address specified?

    -Direct Addressing Mode is a way of specifying operands by providing the address of the operand directly in the instruction. This address can be for internal RAM or Special Function Registers (SFRs).

  • Can you give an example of Direct Addressing Mode?

    -An example of Direct Addressing Mode is 'MOV A, 35h', which moves the data from the internal RAM location 35h into the accumulator A.

  • What is Indirect Addressing Mode and how does it differ from Direct Addressing Mode?

    -Indirect Addressing Mode specifies the operand's address through a register. It differs from Direct Addressing Mode in that it uses a register to point to the address of the operand, rather than specifying the address directly in the instruction.

  • How is External RAM accessed in the 8051 microcontroller?

    -External RAM is accessed in the 8051 microcontroller using the Data Pointer (DPTR) register for 16-bit addressing or any of the registers R0 to R7 for 8-bit addressing with Indirect Addressing Mode.

  • What is Indexed Addressing Mode and what is its purpose?

    -Indexed Addressing Mode is used to access data from code memory. Its purpose is to access non-volatile data stored in ROM, such as ASCII data or data related to interfacing with a seven-segment display.

  • Can you explain how Indexed Addressing Mode works with an example?

    -Indexed Addressing Mode works by using an instruction like 'MOVC A, @A + DPTR', which means the data at the address calculated by adding the value in register A to the Data Pointer (DPTR) is moved into the accumulator A from the code memory.

Outlines

00:00

🤖 Introduction to Addressing Modes in Microcontroller 8051

This paragraph introduces the concept of addressing modes in the context of the 8051 microcontroller. Addressing modes are explained as methods for specifying operands in instructions. The 8051 microcontroller is highlighted to have five addressing modes, which will be detailed in the lecture. Immediate addressing mode is introduced first, where data is specified directly within the instruction using a hashtag (#). Examples are provided to illustrate how immediate data is used in instructions, and a note is made about the 8051's unique data pointer (DPTR) being a 16-bit register, unlike other 8-bit registers.

05:00

🔍 Exploring Register and Direct Addressing Modes

The paragraph delves into register addressing mode, where data is specified using registers like accumulator (A) and registers R0 to R7. It clarifies that in the 8051, certain operations between registers are not allowed, specifically the direct transfer between R0 to R7 registers. Direct addressing mode is also discussed, where the operand's address is included in the instruction itself. Examples are given to illustrate how internal RAM and Special Function Registers (SFRs) are accessed using direct addressing, with addresses ranging from 00h to 7Fh for internal RAM and 80h to FFh for SFRs.

10:00

🔗 Indirect and Indexed Addressing Modes Explained

This paragraph explains indirect addressing mode, where the address of the operand is given by a register, allowing access to both internal and external RAM. The use of the '@' symbol and registers R0 to R7 for accessing internal RAM is detailed, along with the use of the DPTR register for external RAM access using the 'movex' instruction. The paragraph also introduces indexed addressing mode, which is used to access data from code memory in the Harvard architecture of the 8051 microcontroller. The importance of storing non-volatile data in ROM is emphasized, and the use of the 'c' symbol in instructions to access code memory is explained with examples.

Mindmap

Keywords

💡Addressing Modes

Addressing modes in the context of the video refer to the different methods used by the 8051 microcontroller to specify operands in an instruction. They are fundamental to understanding how the microcontroller processes instructions and accesses data or memory locations. The video explains five addressing modes, each with its own syntax and use case, which are crucial for programming and controlling the microcontroller effectively.

💡Microcontroller 8051

The Microcontroller 8051 is a specific type of microcontroller that was introduced by Intel in 1981. It is an 8-bit microcontroller with an architecture that supports a wide range of applications. In the video, the 8051 is the central topic, and various concepts such as its addressing modes are discussed to educate viewers on how to program and utilize its capabilities.

💡Immediate Addressing Mode

Immediate addressing mode is one of the five addressing modes explained in the video. It involves specifying data directly within the instruction itself, preceded by a '#' symbol. This mode is used when the data required for an operation is known at the time the instruction is written. For example, 'MOV A, #15h' moves the immediate data '15h' into accumulator A.

💡Register Addressing Mode

Register addressing mode is used when data is specified by registers, such as accumulator A or registers R0 to R7. The video clarifies that while data can be moved between the accumulator and these registers, direct operations between registers R0 to R7 are not allowed, emphasizing the unique constraints of the 8051 microcontroller.

💡Direct Addressing Mode

In direct addressing mode, the operand's address is explicitly stated in the instruction. This mode is used for accessing data stored in specific memory locations, such as internal RAM or Special Function Registers (SFRs). The video provides examples like 'MOV A, 35h', which moves data from the memory location '35h' into accumulator A.

💡Indirect Addressing Mode

Indirect addressing mode uses a register to provide the address of the operand. This mode is versatile as it allows access to both internal and external RAM through registers. The video script mentions using '@' with 'R1' as an example, where the content of 'R1' is treated as an address to access data in internal RAM.

💡External RAM

External RAM refers to memory locations outside the microcontroller's internal memory. The video discusses accessing this memory using 16-bit addressing with the DPTR (Data Pointer) register and also 8-bit addressing with registers like R0 to R7, which requires padding zeros for the upper 8 bits of the address.

💡Internal RAM

Internal RAM is the memory within the microcontroller itself, which is used for storing data locally. The video explains that internal RAM has a limited range from '00h' to '7Fh' and is accessed using direct or indirect addressing modes.

💡Indexed Addressing Mode

Indexed addressing mode is used to access data from code memory, which is part of the Harvard architecture of the 8051 microcontroller. This mode is essential for accessing non-volatile data stored in ROM, such as ASCII data for display purposes. The video illustrates this with 'MOVC A, @A+DPTR', which accesses code memory at an address calculated by adding the value in accumulator A to the value in the DPTR register.

💡Accumulator

The accumulator is a specific register in the 8051 microcontroller used for arithmetic and logical operations. It is often involved in data transfer operations, as shown in the video when explaining various addressing modes, such as moving data into or out of the accumulator using instructions like 'MOV A, R2'.

💡Special Function Registers (SFRs)

Special Function Registers are a set of registers in the 8051 microcontroller that have specific functions, such as controlling I/O ports or the timer. The video mentions that direct addressing mode can be used to access these registers, with '80h' being an example address allocated to port zero.

Highlights

Introduction to addressing modes in microcontroller 8051.

Explanation of what addressing modes are and their role in specifying operands in instructions.

Introduction of five addressing modes available in the 8051 microcontroller.

Immediate addressing mode explained, including the use of the hashtag symbol before data.

Example of immediate addressing mode with the use of hex data in instructions.

Differentiation between data pointer (DPTR) and other 8-bit registers in 8051.

Register addressing mode explained, with the use of registers A and R0 to R7.

Limitation in 8051 regarding the use of registers with each other in register addressing mode.

Direct addressing mode explained, with the inclusion of specific addresses in instructions.

Examples of direct addressing mode using internal RAM and SFR addresses.

Indirect addressing mode explained, with the use of registers to point to operand addresses.

Use of internal RAM and external RAM with indirect addressing mode.

External RAM addressing with the use of DPTR and the MOVEX instruction.

8-bit addressing in external RAM using registers R0 to R7 and the MOVEX instruction.

Index addressing mode for accessing data from code memory in the Harvard architecture.

Explanation of the use of the 'C' in instructions for index addressing mode.

Clarification of addressing modes for internal and external ROM and RAM.

Invitation for viewers to ask questions if they have any confusion regarding addressing modes.

Transcripts

play00:00

welcome to engineering funda family this

play00:02

video is a part of

play00:03

microcontroller8051 video lecture series

play00:05

and in this video i'll be going to

play00:07

explain you

play00:08

addressing modes of microcontroller 8051

play00:11

let me explain you first what is the

play00:13

meaning of addressing modes

play00:14

see addressing mode means what it is a

play00:17

way of specifying operands in

play00:19

instruction so when you write any

play00:21

instruction in that obviously you will

play00:23

be having operands

play00:25

those operands may be data it may be

play00:27

resistor it may be memory location right

play00:30

so how to specify operands that is

play00:33

defined by addressing modes so with

play00:36

eight zero five one microcontroller we

play00:38

have five addressing modes i'll explain

play00:40

you each and every addressing modes

play00:42

along with examples so that will gives

play00:44

you more clarity let us see all those

play00:45

things step by step

play00:47

so my dear students when we talk about

play00:49

addressing modes then you should know

play00:51

various formats of specifying operands

play00:54

in instruction is referred as addressing

play00:56

mode

play00:57

here

play00:58

when we talk about immediate addressing

play01:00

mode

play01:01

then in immediate addressing mode we

play01:03

specify

play01:05

data in instruction itself

play01:07

that data may be of one byte or two byte

play01:10

here my dear students when you write

play01:13

data at that time you will have to write

play01:15

hashtag

play01:16

before data

play01:18

so once you write hashtag after that you

play01:20

have to mention data right whatever data

play01:23

that you want to specify

play01:25

let me give you example so here for

play01:27

example when you write mu a comma

play01:30

hashtag 15 hacks

play01:32

then what you are doing

play01:34

this 15 hex data which is specified in

play01:37

this instruction that you are copying

play01:39

inside resistor a

play01:42

when you write move dptr comma hashtag

play01:46

1000 hex

play01:48

then what you do is here this 1000 hex

play01:50

data that you are copying inside dptr

play01:54

and one more thing that you need to note

play01:56

down

play01:56

see

play01:57

with 8051 we just have this dpdr

play02:01

resistor in which directly we can have

play02:03

16 bits other resistors are having size

play02:06

of 8 bits only right

play02:08

so here when you specify data

play02:11

like this hashtag then 15 hacks

play02:15

or you can say

play02:16

here we have two bytes data

play02:19

that is having same format hashtag then

play02:21

two byte data and then hacks so this is

play02:23

how we can represent this immediate data

play02:26

in instruction that's why it is referred

play02:29

as immediate addressing mode

play02:31

now i'll explain you resistor addressing

play02:33

mode so from name itself you can

play02:36

understand

play02:37

see here you will be specifying data by

play02:40

resistors right

play02:42

in instruction you will be specifying

play02:44

data by resistor only

play02:46

here

play02:47

you will be using this resistors only

play02:49

like a and r0 to r7 so these resistors

play02:53

that we will be using

play02:56

here my dear students for example when

play02:59

you write mu a comma r2 then what you

play03:02

are doing you are copying r2 inside a

play03:05

when you write mu r2 comma a then what

play03:08

you are doing you are copying the

play03:09

content of a into r2 so that is how we

play03:13

specify

play03:14

data inside resistor and then you are

play03:16

performing

play03:18

operations based on resistors only right

play03:21

like when you write move r1 comma r2

play03:24

then you will be thinking like you will

play03:25

be copying r2 inside r1 right but my

play03:28

dear students this is not allowed with

play03:31

eight zero five one why the reason is

play03:33

you will have to use

play03:35

accumulator in terms of resistor

play03:37

addressing mode you cannot use r0 to r7

play03:41

resistor with each other

play03:43

right so that is how things are there

play03:45

with 805 1 this is not allowed that's

play03:47

why specifically i have mentioned this

play03:49

instruction many of the time students

play03:51

are asking me like sir i am having error

play03:54

and they are writing it like this and if

play03:56

you write instructions like this

play03:58

definitely you will be finding errors

play04:00

right so you are not allowed to do this

play04:02

now my dear students when you talk about

play04:05

direct addressing mode then in that

play04:07

addressing mode

play04:08

address of operand will be given in

play04:11

instruction

play04:12

so here you will be giving address of

play04:14

operand remember this

play04:16

here

play04:17

you are using internal ram or sfr

play04:20

address right internal ram address is

play04:22

there from 0 0 hex to 7 half x

play04:26

and sfr address that is there from eight

play04:30

zero hex to ff hacks so that is what we

play04:34

are using it with direct addressing mode

play04:36

let me give you some example like when

play04:39

you write move a comma 35 hacks then

play04:42

what you are doing here you see you have

play04:44

not written hashtag see here when you

play04:46

write hashtag then that is immediate

play04:49

data but when you don't write hashtag

play04:51

means this is address

play04:53

and this is what ram address right

play04:57

now ram address is there in between 0 to

play05:00

7 f that's why i'm saying it is ram

play05:02

address

play05:03

sfr address that is there from 8 0 hex

play05:06

to ffx

play05:07

so when you write

play05:09

a comma 35

play05:11

means here my dear students this 35 is

play05:14

address and at this address

play05:17

whatever data is there inside ram that

play05:20

is internal ram right that will be

play05:22

copied inside

play05:24

accumulator a that is how it is

play05:26

happening

play05:27

when you execute move a comma 8 0 hex

play05:31

what you are doing

play05:32

you are copying

play05:33

the content of 8 0 hex address eight

play05:37

zero hex that is what allocated with

play05:40

port zero right

play05:42

so here my dear students when you write

play05:45

a comma eight zero means eight zero

play05:47

hacks is address

play05:48

and for that whatever content is there

play05:50

that you will be copying it inside

play05:53

accumulator a

play05:54

right

play05:55

for example when you write move

play05:58

3 0 hex comma 3 5 hex then what you are

play06:01

doing

play06:01

see 3 5 hacks that is also address over

play06:04

here and three zero hex that is also

play06:06

address

play06:07

and

play06:08

both address are having some data

play06:10

right so now what will happen after this

play06:13

instruction 35 hex address is having

play06:15

whatever data that you will be copying

play06:18

it inside

play06:19

three zero hex address that is how this

play06:22

instruction is happening right

play06:24

now my dear students i'll explain you

play06:26

indirect addressing mode so in indirect

play06:29

addressing mode

play06:30

address of

play06:31

operand will be given by resistor so

play06:34

here with

play06:35

internal ram we have resistors as well

play06:37

as sfrs are also resistors so address of

play06:41

operand will be given by resistor now

play06:43

you will be not using direct addressing

play06:46

right like we have written direct

play06:47

address over here

play06:49

if you can remember direct address of

play06:51

different sfr that is good but if you

play06:53

cannot remember direct address then you

play06:55

can use resistors right so here internal

play06:58

ram external ram can be accessed by this

play07:01

mode

play07:02

and here for example when you write

play07:06

this

play07:06

indirect addressing mode with the use of

play07:09

at the rate at that time my dear

play07:11

students you will be using internal ram

play07:13

remember this

play07:15

and here when you write move a comma at

play07:18

the rate r1 then what you are doing

play07:21

this r1 is having whatever data now that

play07:23

is address

play07:25

and at that address whatever data is

play07:27

there with internal ram that you will be

play07:28

copying it inside a so obviously r1 can

play07:32

be there with the value in between 0 to

play07:36

7 f remember this right

play07:39

internal ram is there from the range of

play07:41

0 0x to 7f hex so r1 can be pointing any

play07:47

data inside that internal ram and that

play07:50

data will be copied inside a

play07:52

here when you write move at the rate r2

play07:54

comma a then what you are doing is you

play07:56

are moving content of a

play07:59

at the memory location pointed by

play08:01

resistor r2 right and obviously as i

play08:04

have told you now r2 that is pointing

play08:06

what internal ram right so r2 must be

play08:10

there in between 0 0 to

play08:12

7 f hex then only you can use this at

play08:15

the rate

play08:17

now my dear students

play08:19

for external ram you will be having

play08:22

16 bits of addressing by dbtr and for

play08:25

that you'll have to use x you see here

play08:28

normal move was there but now you will

play08:30

be using movex

play08:32

so in that situation what you are doing

play08:34

is you are using external ram

play08:37

and how to use that by using dbtr data

play08:40

pointer resistor that is pointing

play08:43

external ram only right so you can

play08:46

directly use it by using data pointer

play08:48

how you see when you write move x a

play08:51

comma at the red db tr then dptr is a

play08:54

pointer which is pointing external ram

play08:57

at that location whatever data is there

play08:59

that you will be copying inside

play09:00

accumulator a

play09:02

when you write mu x

play09:04

at the rate dbt or comma a then what you

play09:06

are doing you are copying the content of

play09:08

a

play09:09

at the memory location pointed by dpdr

play09:12

right

play09:13

so external ram that we can access by

play09:15

using dbtr but along with that you will

play09:18

have to use x in move instruction

play09:21

now my dear students i'll explain you

play09:24

external ram with 8 bits of addressing

play09:27

so 8 bits of addressing is possible

play09:29

using external ram

play09:30

in that you can use any resistor like r0

play09:34

to r7

play09:35

but here there are few basic things that

play09:37

you need to note down

play09:38

see external ram that is having address

play09:41

of 16 bits here 8 bits that we are using

play09:44

by resistor

play09:46

so external ram is been accessed that's

play09:48

why move x that you'll have to write

play09:49

first

play09:50

then when you write a comma at the rate

play09:52

r1

play09:53

then

play09:54

external ram address that is been

play09:57

pointed by r1 but how you see

play10:00

if value of r1 is 25 hex then initial

play10:04

two digits of this hex that should be 0

play10:07

means 0 0 to 5 hex that will be my

play10:10

address that was pointed by r1 in terms

play10:12

of 16 bits and at that

play10:15

location whatever content is there that

play10:18

you will be copying inside accumulator

play10:20

right so here my dear students you can

play10:23

use eight bits but by default

play10:26

assembler will convert that address in

play10:28

terms of 16 bits by adding eight

play10:31

zeros over here in terms of binary

play10:34

for example when you write mu x at the

play10:36

rate r0 comma a then you will be copying

play10:39

the content of a

play10:40

at the memory location pointed by r0 in

play10:43

external ram remember this as you are

play10:46

writing x over here it will be external

play10:48

ram only but in external ram

play10:51

see

play10:52

this r0 contain 35 hex if it is like

play10:55

this then initial two hex digits that

play10:58

will be 0 as per

play11:01

this

play11:02

external ram operation for external ram

play11:05

you will have to write x over here

play11:06

remember this normally we use dbtr

play11:08

resistor only but as if you use other

play11:11

resistor then it will be padding zeros

play11:14

like this that is how things are

play11:16

happening now i'll explain you index

play11:18

addressing mode

play11:20

here this mode is been used to access

play11:23

data from code memory you should know my

play11:25

dear students8051

play11:27

that is based on harvard architecture so

play11:29

in harvard architecture we have

play11:33

separate memory for data and code

play11:36

code is there with rom

play11:37

and data is there with ram right but

play11:41

in some situation you may need to store

play11:44

those data which are not volatile

play11:47

for example if i say ascii data then

play11:49

ascii data should not be volatile data

play11:52

so that should be stored inside rom for

play11:54

example seven segment display that you

play11:56

are interfacing so that is also

play11:58

non-volatile data that also you need to

play12:00

store inside rom so those data which are

play12:02

not volatile that you must store inside

play12:04

rom as ram is volatile memory so when

play12:07

you restart system the data of ram will

play12:09

get vanished right so that you must need

play12:12

to store inside

play12:13

rom only

play12:15

and for that you will have to use index

play12:17

addressing mode in

play12:18

instructions so here when you write c

play12:22

at that time you will be using index

play12:24

addressing mode let me explain you that

play12:26

so you see here move and then see that

play12:28

i'm writing

play12:29

right so mosi means what you are using

play12:32

code memory

play12:33

right and how you see a comma at the

play12:36

rate a plus dbtr what it means

play12:39

a plus dbtr now that is my address and

play12:42

at that address whatever content is

play12:44

there that you are copying it inside

play12:46

accumulator a

play12:48

for example when you write move c a

play12:50

comma at the red a plus b c so what you

play12:54

are doing

play12:55

you are having

play12:57

address which is a plus pc

play12:59

and at that location whatever content is

play13:02

there inside rom remember this it is

play13:04

there inside rom

play13:06

so inside rom whatever content is there

play13:09

that you are copying it inside

play13:11

accumulator a so when you write c at the

play13:14

time you will be using code memory means

play13:16

it will be internal or external rom and

play13:20

when you write x at that time you will

play13:22

be using external ram

play13:24

and when you don't write anything at the

play13:26

time you will be using internal ram

play13:28

which is having size of 0 0 to

play13:30

7 f hex that is how all the addressing

play13:33

modes are there

play13:35

so i think now it is clear to you how

play13:37

addressing modes are there still if any

play13:39

confusion is there just post that in

play13:40

common box i'll be happy to help you

play13:42

thank you so much for watching this

play13:43

video

Rate This

5.0 / 5 (0 votes)

Связанные теги
Microcontroller8051Addressing ModesInstruction SetImmediate ModeRegister ModeDirect ModeIndirect ModeExternal RAMInternal RAMEducational Video
Вам нужно краткое изложение на английском?