Important parts of 8051 Microcontroller | Accumulator of 8051 | Program Counter of 8051 | 8051

Engineering Funda
15 Aug 202214:33

Summary

TLDRThis video lecture delves into the intricacies of the 8051 microcontroller, focusing on key components like the 8-bit ALU that handles arithmetic and logical operations, including single-bit manipulation. It explains the role of the accumulator A, register B for multiplication and division, and the program counter (PC) in instruction execution. The video also covers the data pointer (DPTR) for addressing data in RAM or external memory, the stack pointer (SP) for managing the stack memory, and the program status word (PSW) that reflects the status of the program after each instruction. Examples and further explanations are promised in upcoming videos to clarify these concepts.

Takeaways

  • 😀 The 8051 microcontroller's ALU (Arithmetic and Logic Unit) is an 8-bit unit responsible for executing instructions and performing arithmetic and logical operations.
  • 🔢 The ALU in the 8051 can perform both 8-bit and single-bit operations, such as adding the accumulator to a register or complementing a specific bit of a port.
  • 📦 The accumulator (A) is an 8-bit register that is central to most arithmetic and logical operations in the 8051, often used as the primary operand for these operations.
  • 📈 Register B, also 8-bit, is specifically dedicated to multiplication and division instructions in the 8051, storing results in a combined form with the accumulator for 16-bit results.
  • 🔄 The program counter (PC) is a 16-bit register that points to the address of the next instruction to be executed in the program memory (ROM).
  • 📌 The data pointer (DPTR) is a 16-bit register used to point to data in the data memory (RAM) or external memory, and can also be used for lookup tables in ROM.
  • 🔠 The stack pointer (SP) is an 8-bit register that holds the address of the top of the stack in the internal RAM, used for last-in, first-out operations.
  • 🔄 The stack memory is used for storing return addresses for subroutines and interrupt service routines, and is pointed to by the stack pointer.
  • 📈 The program status word (PSW) is an 8-bit register that reflects the status of the program, such as carry and overflow flags, and can be altered by specific instructions.
  • 🔑 The PSW register is bit-addressable, allowing for individual bit manipulation to set or clear specific flags, influencing program control flow.
  • 🛠️ The 8051 microcontroller is based on the Harvard architecture, with separate memory spaces for program (ROM) and data (RAM), each pointed to by the PC and DPTR respectively.

Q & A

  • What is the primary function of the ALU in the 8051 microcontroller?

    -The ALU (Arithmetic and Logic Unit) in the 8051 microcontroller is responsible for executing instructions along with performing arithmetic and logical operations. It is an 8-bit unit that can also perform single-bit operations.

  • What is the significance of the accumulator in the 8051 microcontroller?

    -The accumulator, labeled as 'A', is an 8-bit register that is used for most arithmetic and logical operations in the 8051 microcontroller. It is central to the microcontroller's operations as many instructions are executed with respect to the accumulator.

  • What is the purpose of register B in the 8051 microcontroller?

    -Register B in the 8051 microcontroller is an 8-bit register dedicated to multiplication and division instructions. It works in conjunction with the accumulator to store the results of these operations, with B holding the higher byte and A holding the lower byte.

  • How does the 8051 microcontroller handle multiplication and division results?

    -When performing multiplication or division, the 8051 microcontroller stores the result in the accumulator (A) and register B. For multiplication, the 16-bit result is stored with B holding the higher byte and A the lower byte. For division, the quotient is in A and the remainder in B.

  • What is the role of the program counter (PC) in the 8051 microcontroller?

    -The program counter (PC) in the 8051 microcontroller is a 16-bit register that holds the address of the next instruction to be executed. It automatically increments after fetching an instruction, pointing to the subsequent instruction in the program memory.

  • How is the data pointer (DPTR) used in the 8051 microcontroller?

    -The data pointer (DPTR) in the 8051 microcontroller is a 16-bit register that holds the address of data in the data memory, which is RAM. It can also point to external RAM and is used for indexing and accessing lookup tables in ROM.

  • What is the purpose of the stack pointer (SP) in the 8051 microcontroller?

    -The stack pointer (SP) in the 8051 microcontroller is an 8-bit register that holds the address of the top of the stack in the internal RAM. It is used for managing the stack, which operates on a last-in, first-out basis and is crucial for subroutine and interrupt handling.

  • What is the role of the Program Status Word (PSW) in the 8051 microcontroller?

    -The Program Status Word (PSW) in the 8051 microcontroller is an 8-bit register that indicates the status of the program, such as whether a carry or overflow has occurred. It changes after every instruction execution and can also be manually altered by specific instructions.

  • How does the 8051 microcontroller perform single-bit operations?

    -The 8051 microcontroller can perform single-bit operations through its ALU. For example, the instruction 'CPL P0.3' complements a single bit of port 0, demonstrating the ALU's capability to handle one-bit logical operations.

  • What is the initial address indicated by the stack pointer (SP) after a reset in the 8051 microcontroller?

    -After a reset, the stack pointer (SP) in the 8051 microcontroller indicates the address 07h of the internal RAM, which is part of the stack memory area.

  • How is the 8051 microcontroller's internal RAM structured in relation to the stack pointer (SP)?

    -The internal RAM of the 8051 microcontroller has a stack memory area that ranges from 00h to 7Fh in address. The stack pointer (SP), being an 8-bit register, points to this area and is used with push and pop instructions as well as in subroutine and interrupt operations.

Outlines

00:00

🤖 Introduction to 8051 Microcontroller Terminologies

This paragraph introduces the video lecture series on the 8051 microcontroller, focusing on key terminologies. The speaker plans to explain the functioning of the Arithmetic Logic Unit (ALU), the significance of the Accumulator (A), Register B, Program Counter (PC), Stack Pointer (SP), and Program Status Word (PSW). The ALU, an 8-bit unit, performs both arithmetic and logical operations, including single-bit operations. Examples are given to illustrate these concepts, such as adding values using the accumulator and complementing bits of a port.

05:02

📚 Understanding the 8051 Microcontroller's Memory Architecture

The second paragraph delves into the Harvard architecture of the 8051 microcontroller, which separates program and data memory. The internal ROM holds the program instructions, while the RAM stores data. The Program Counter (PC), a 16-bit register, points to the instruction addresses. As instructions are fetched and executed, PC automatically increments to the next instruction. The Data Pointer (DPTR), also 16 bits, points to data in RAM and can address external RAM or be used for lookup tables. The paragraph also explains the use of DPTR in index addressing with the 'movex' instruction.

10:03

🔄 Exploring the Stack Pointer and Program Status Word in 8051

This paragraph explains the function of the Stack Pointer (SP) in the 8051 microcontroller, which holds the address of the top of the stack in the internal RAM. The stack operates on a Last In, First Out (LIFO) principle and is used for subroutine and interrupt handling. The initial address of the SP after reset is 07h. Additionally, the Program Status Word (PSW) is discussed as an 8-bit register that reflects the status of the program, such as carry and overflow flags. The PSW changes after each instruction execution and can be manipulated with specific instructions. The speaker promises a future video detailing how the PSW works and its flags.

Mindmap

Keywords

💡Microcontroller

A microcontroller is a small computer on a single integrated circuit chip that contains a processor core, memory, and programmable input/output peripherals. In the context of the video, it is the main theme as the script discusses the 8051 microcontroller, highlighting its various components and functions.

💡ALU (Arithmetic Logic Unit)

The ALU is a part of the CPU that performs arithmetic and logical operations. In the video, it is explained that the 8051 microcontroller has an 8-bit ALU responsible for executing instructions and performing operations, which is central to understanding the microcontroller's computational capabilities.

💡Accumulator (A)

The accumulator is a register used in a processor for storing results of arithmetic and logic operations. The script emphasizes its significance in the 8051 microcontroller, where it is an 8-bit register involved in most arithmetic and logical operations, exemplified by the instruction 'add a, r1'.

💡Register B

Register B is an 8-bit register dedicated to multiplication and division operations in the 8051 microcontroller. The script illustrates its use in instructions like 'mul a, b', where the result of multiplying the accumulator and register B is stored, with B holding the higher byte.

💡Program Counter (PC)

The program counter is a register that stores the memory address of the next instruction to be executed. The script explains its 16-bit size in the 8051 and its role in pointing to the instruction address in the program memory, highlighting its automatic incrementation after each instruction fetch.

💡Data Pointer (DPTR)

The data pointer is a 16-bit register used to point to data in memory. The video script describes its function in accessing data memory in the 8051 microcontroller, with examples of how it can be used for external RAM addressing or as a pointer for lookup tables.

💡Stack Pointer (SP)

The stack pointer is an 8-bit register that holds the address of the top of the stack in memory. The script explains its role in managing the stack memory area within the internal RAM of the 8051, following the Last In, First Out (LIFO) principle, and its use in push and pop operations.

💡PSW (Program Status Word)

The PSW is an 8-bit register that reflects the status of the program, such as carry or overflow flags. The video script describes how it changes after each instruction execution and how it can be manipulated with specific instructions to set or clear flags, indicating the status of the program's operations.

💡Instruction Execution

Instruction execution refers to the process by which a microcontroller carries out the tasks defined by its program instructions. The script provides examples of how different instructions are executed by the 8051's ALU, affecting the state of registers like the accumulator and PSW.

💡Howard Architecture

The Howard architecture is a system design where program and data memories are separate. The script mentions that the 8051 microcontroller is based on this architecture, with internal ROM for program storage and RAM for data, which influences how the program counter and data pointer function.

Highlights

Introduction to the 8051 microcontroller and its key terminologies.

Explanation of the ALU's function within the 8051 microcontroller.

The 8-bit ALU's role in executing instructions and performing arithmetic and logical operations.

Capability of the ALU to perform single-bit operations in addition to 8-bit operations.

The significance of the Accumulator A in 8051 for most arithmetic and logical operations.

Description of the 8-bit Register B used for multiplication and division instructions.

How the multiplication instruction 'mul a b' stores a 16-bit result in A and B registers.

Division operation 'div a b' and how the quotient and remainder are stored in A and B registers.

Introduction to the Program Counter (PC) and its 16-bit size for instruction addressing.

Explanation of Harvard architecture in 8051 with separate memory for program and data.

The Data Pointer (DPTR), its 16-bit size, and its role in pointing to data in RAM or external memory.

Use of DPTR for accessing lookup tables in ROM through index addressing mode.

Introduction to the Stack Pointer (SP), its 8-bit size, and its function in managing the stack memory.

Stack memory's operation based on Last In, First Out (LIFO) principle and its relation to SP.

Explanation of the Program Status Word (PSW), its 8-bit size, and its role in indicating program status.

PSW's bit-addressability and the ability to change flag status through specific instructions.

Invitation for viewers to ask questions and get help in the comments section.

Transcripts

play00:00

welcome to engineering fender family

play00:02

this video is a part of microcontroller

play00:04

eight zero five one video lecture series

play00:06

and in this video i'll be going to

play00:08

explain you few very interesting and

play00:10

important terminologies of

play00:12

microcontroller eight zero five one like

play00:14

i'll explain you how alu is functioning

play00:16

with eight zero five one

play00:17

like what is the significance of

play00:19

accumulator resistor b

play00:21

as well as pc stack pointer and psw

play00:24

resistor that is there with eight zero

play00:26

five once i'll explain you each and

play00:27

everything with example so that will

play00:29

gives you more clarity let us see all

play00:31

those things step by step so first of

play00:33

all i'll explain you how alu is there so

play00:36

arithmetic and logic unit that is a part

play00:39

of cpu that you should know

play00:41

here with 8051 we have 8 bits of alu

play00:45

that is responsible for execution of

play00:48

instruction along with arithmetic and

play00:50

logical operation so all the arithmetic

play00:53

and logical operation performed inside

play00:55

cpu is been done by alu

play00:58

size of alu is eight bits with eight

play01:00

zero five one

play01:02

here my dear students it is not only

play01:04

eight bits of arithmetic and logical

play01:06

operation that can be there with alu

play01:09

here you can perform single bit

play01:10

operation as well let me give you some

play01:12

examples so that will give you more

play01:14

clarity

play01:15

for example when you execute

play01:17

add a comma r1 all you do is you will be

play01:21

adding accumulator a with r1

play01:24

and the result will get stored inside a

play01:27

you should know my dear students a

play01:29

r0 to r7 all the resistor are having

play01:33

size of 8 bits so here we have performed

play01:36

8 bits of addition

play01:38

when you execute cpl p

play01:41

0.3 what you do is you will be

play01:44

complementing this bit of port 0. port 0

play01:49

is having 8 bits see here we have port

play01:51

0. so this port 0 that is having 8 bits

play01:55

in that

play01:56

p 0.3 that is one bit of that port

play02:01

that we can complement by this

play02:03

instruction so this alu can perform one

play02:06

bit operation as well so in short my

play02:08

dear students you should know eight zero

play02:10

five one performs eight bits of

play02:12

arithmetic and logical operation as well

play02:14

as it can perform one bit logical and

play02:16

arithmetic operations

play02:18

let me explain you

play02:20

second term that is accumulator a

play02:23

accumulator a that is a resistor with

play02:27

size of 8 bits

play02:28

here my dear students you should know

play02:30

this is spatial resistor why the reason

play02:32

is

play02:33

most of the arithmetic and logical

play02:35

operations of eight zero five one that

play02:37

happens with respect to accumulator only

play02:40

right

play02:41

so here accumulator

play02:43

is used with most of the arithmetic and

play02:45

logical operations

play02:47

here if i give you some example then it

play02:49

will gives you more clarity like when

play02:51

you write add a comma r0 what you do you

play02:54

will be adding a with r0 and answer will

play02:56

get stored inside a

play02:59

as if you execute a and l

play03:01

what you do is you perform logic and

play03:04

operation

play03:05

when you write a n l then a comma r 1

play03:09

then you will be performing logic and

play03:11

operation of a with r 1 and then you

play03:14

will be storing answer inside a

play03:16

so almost all the arithmetic and logical

play03:19

operation that can be executed along

play03:21

with

play03:22

resistor which is accumulator a

play03:26

now my dear students i'll explain you

play03:28

one more essential resistor which is

play03:31

resistor b it is also having size of 8

play03:34

bits and this is dedicatedly provided

play03:37

with 8051

play03:39

for multiplication and division

play03:41

instructions

play03:42

let me give you example

play03:44

like when you write mul a b what you do

play03:47

you multiply a and b and then

play03:50

answer will get stored inside ba

play03:53

you see when you have two data

play03:55

multiplication that data is having size

play03:57

of 8 bits only accumulator is having

play03:59

size of 8 bit

play04:01

this b is having size of 8 bit when you

play04:03

multiply 8 bit into 8 bit your answer

play04:06

will be of 16 bits

play04:08

so 16 bits that will get stored inside

play04:10

again

play04:11

ba where b will hold higher byte and a

play04:15

will hold lower byte that is how it is

play04:18

getting stored inside ba so b is

play04:21

dedicatedly provided for multiplication

play04:23

and division when you write div a b what

play04:26

you do you will be doing

play04:28

a divided by b operation

play04:31

now

play04:32

here when you perform this your answer

play04:35

will be there in terms of quotient and

play04:36

reminder

play04:38

so quotient will be there inside a after

play04:40

a divided by b and remainder will be

play04:42

there inside b after a divided by b that

play04:45

is how a and b

play04:47

resistors are there inside 8 0 5 1.

play04:51

now my dear students i'll explain you

play04:53

how program counter is there

play04:55

so you should know my dear students

play04:57

8051

play04:59

that is based on howard architecture

play05:02

howard architecture means what

play05:04

howard architecture means

play05:06

for program and for data we will be

play05:09

having separate memory

play05:11

you see here internally we have 4 kb of

play05:14

rom and 128 byte of ram

play05:17

so ram will be holding data and rom will

play05:20

be holding program means instructions so

play05:24

address

play05:25

of instruction inside program will be

play05:28

pointed by pc

play05:29

so whenever you execute any program

play05:32

you will be executing that with respect

play05:34

to one by one instructions

play05:36

so that instruction address that will be

play05:40

pointed by pc it is having size of 16

play05:43

bits

play05:44

and

play05:45

you will be observing instruction

play05:47

address that will be there with pc so

play05:49

when you fetch one

play05:51

automatically pc will get increment and

play05:54

it will be pointing next instruction to

play05:56

be executed so for example here you are

play05:59

writing program

play06:00

let us say first instruction that is

play06:02

getting fetch pc will get automatically

play06:04

incremented by one it will be now

play06:06

pointing next instruction once first

play06:08

instruction is getting executed

play06:10

pc is already having next instructions

play06:12

address so now next instruction is ready

play06:15

to be fetched

play06:16

once next instruction is getting fetch

play06:18

pc again will get automatically get

play06:20

incremented and it will be pointing

play06:23

third instruction and it will wait till

play06:25

second instruction is getting executed

play06:27

so what will happen is my dear students

play06:30

pc

play06:31

increments automatically once you

play06:34

fetch any instruction and those

play06:36

instructions will be there in program

play06:38

memory means it will be there inside rom

play06:40

only as eight zero five one is there

play06:44

based on howard argue texture

play06:47

now my dear students i'll explain you

play06:49

dbdr data pointer data pointer dbdr that

play06:53

is having size of 16 bits

play06:55

right

play06:56

and my dear students it will be holding

play07:00

address of data in data memory data

play07:02

memory will be ram always with 8051 it

play07:06

is there with howard architecture

play07:08

program memory will be rom data memory

play07:10

will be ram

play07:12

program memory will be pointed by pc

play07:15

data memory will be pointed by dbdr that

play07:17

is how it will be there you should know

play07:19

that so here dptr

play07:22

that is holding

play07:24

data of ram memory

play07:27

right so here you will be observing it

play07:29

is further divided into two parts dbdr

play07:32

means dph means higher byte of dvdr and

play07:34

dpl means lower byte of dpdr here my

play07:37

dear students this dptr that is of 16

play07:41

bits what it means it is not pointing

play07:44

internal ram you see internal ram is

play07:46

having size of 128 bit so address of

play07:49

internal ram

play07:50

that is just

play07:52

of 8 bits

play07:54

but here how much

play07:56

size is there with dpdr 16 bit so

play07:58

obviously this dpdr that will be

play08:02

pointing

play08:03

external ram as if you interface

play08:05

external ram then only

play08:07

that data will be pointed by dpdr

play08:10

remember this

play08:11

it can also be used as a pointer for

play08:13

lookup table

play08:15

like you see what i have told you is

play08:17

you will be using rom for which purpose

play08:20

program program will be having what

play08:23

instructions

play08:24

and you will be using ram for which

play08:27

purpose data right why we store data

play08:30

inside ram the reason is data may be

play08:32

volatile

play08:34

but

play08:35

in some cases

play08:37

as if you wanted to have data

play08:40

that should not be volatile in that case

play08:42

what you will be doing

play08:43

obviously if data is not volatile in

play08:47

that case we must store inside rom when

play08:50

you store those data

play08:52

which are not volatile inside rom

play08:55

at that time you will have to make

play08:57

lookup table and you will have to store

play08:59

it inside rom

play09:00

and to access that

play09:03

you can use this dptr so here what you

play09:06

can do is you can make index addressing

play09:09

mode by which we can have usage of dbdr

play09:12

let me explain you by example

play09:14

here when you have lookup table

play09:17

operation at that time remember you will

play09:18

have to write movex do not forget this x

play09:23

right when you write x what you do is

play09:26

you will be using dptr as per pointer

play09:31

right

play09:32

see normally what we write is move a

play09:35

comma

play09:36

any address right so at a time it will

play09:39

be taking data inside a that is normal

play09:41

move but when you use

play09:44

this dpdr as a pointer for ram at a time

play09:47

you will have to write x over here so

play09:49

what will happen you see when you write

play09:51

mu x a comma at the rate db dr means

play09:55

ram is pointed by dbtr

play09:58

and at that address whatever data is

play10:00

there that you will be moving inside a

play10:03

now you see i'll give you one example

play10:05

which is the based on lookup table when

play10:06

you want to access lookup table inside

play10:08

rom at the time you'll have to use c

play10:10

after move you'll have to write c when

play10:13

you write move c a comma at the rate a

play10:16

plus d b d r then all you do is

play10:19

here a plus dptr that will be my address

play10:23

that is the address of rom

play10:26

and at that address whatever data is

play10:28

there that i'll be moving inside

play10:29

accumulator a that is how this move c is

play10:33

operating so mosi is there in terms of

play10:36

index addressing right

play10:38

so that is how dpdr is working now my

play10:41

dear students i'll be going to explain

play10:43

you stack pointer

play10:45

stack pointer is having size of 8 bits

play10:48

and it will be holding address of top of

play10:50

stack

play10:51

you should know my dear students this

play10:53

stack that is operating as per last in

play10:56

first out

play10:57

and address of that stack will be holded

play11:00

by this eight bits of resistor which is

play11:02

there with stack pointer and you should

play11:04

know my dear students you see here we

play11:06

have internal ram of eight zero five one

play11:08

so this internal ram's address

play11:11

that will be holded by stack pointer so

play11:14

internal ram is having stack memory only

play11:18

and address of that will be there with

play11:21

sp you see 128 byte of internal ram is

play11:24

there so 128 byte means what will be the

play11:27

address range it will be starting from 0

play11:30

0 hex and it will go up to 7 f hex so

play11:33

that internal ram

play11:35

will be

play11:36

working with stack memory and that

play11:39

memory will be pointed by stack pointer

play11:41

resistor right so internal ram address

play11:44

that is ranging from 0 0 hex to 7 f x

play11:47

and that is having stack memory area

play11:50

that is pointed by stack pointer

play11:53

resistor we use that with push and pop

play11:56

instructions as well as we use stack

play11:59

memory in subroutine as well as

play12:01

interrupt subroutine so this stack

play12:03

memory which will be used for subroutine

play12:06

as well as interrupt subroutine

play12:09

when you reset this 8051 at that time

play12:12

this tag pointer will indicate 0 7 hex

play12:16

address of internal ram right

play12:18

why the reason is this internal ram is

play12:21

also holding resistors data right so on

play12:25

reset it will be having initial address

play12:28

of 0 7 with sp

play12:31

here my dear students there are many

play12:32

other things which is happening inside

play12:35

this ram but here you just understand

play12:38

this internal ram will be having stack

play12:40

memory that will be pointed by stack

play12:42

pointer that is having size of 8 bits it

play12:45

will be having range from 0 0x to 7 fx

play12:48

in future coming videos i'll explain you

play12:50

how this internal ram structure is there

play12:52

that will gives you more clarity

play12:55

here my dear students when we talk about

play12:57

psw then you should know it is program

play13:00

status word

play13:01

it is of 8 bits and it will be showing

play13:04

you status like whether carry is there

play13:06

or not like whether overflow is there or

play13:08

not right so that is how status is

play13:11

indicated by psw resistor and that

play13:14

operation will be performed inside cpu

play13:16

so whatever operation that we performed

play13:18

by executing instruction after

play13:20

every instruction execution this phw

play13:24

flag will change

play13:26

how it will change for that i'll make

play13:28

separate video in that i'll show you how

play13:31

all the flags are there here just

play13:33

understand one thing psw is having size

play13:36

of 8 bits it is holding status of

play13:38

program and it will change after

play13:41

every instruction execution

play13:44

and we can also change the status of

play13:47

flag by executing instructions like set

play13:51

b psw 0.2 clear psw 0.2 so here we are

play13:56

setting this bit we are clearing this

play13:58

bit why the reason is psw is bit

play14:02

addressable resistor so here bit by bit

play14:05

operation can be performed as well as

play14:07

you can have

play14:08

complete

play14:10

resistor

play14:11

operations and this flag resistor is

play14:15

showing you how program status is there

play14:18

so in next coming videos i'll explain

play14:20

you how psw is there so i think now

play14:23

you are having fair enough idea about

play14:25

how all these elements are there with

play14:27

8051 still if any confusion is there

play14:29

just post that in comments i'll be happy

play14:31

to help you thank you so much for

play14:32

watching this video

Rate This

5.0 / 5 (0 votes)

相关标签
Microcontroller8051ALUAccumulatorInstruction ExecutionArithmetic LogicRegister BMultiplicationDivisionProgram CounterStack PointerPSWEngineering EducationTechnical TutorialMicrochipCPU FunctionsMemory ManagementInstruction SetEmbedded SystemsElectronic DesignLogic OperationsData PointerStatus Flags
您是否需要英文摘要?