Unit4_EE3404_MPMC
Unit4_EE3404_MPMC
[Regulation-2021]
Unit 4
Introduction to 8051
Microcontroller
MP&MC/EE3404 Lecture Notes
by
Dr.I.William Christopher
Asso.Prof/EEE Dept./LICET
6/9/2024 EE3404/MPMC/Unit-4 1
Course Objectives
▪ To study the addressing modes & instruction set of 8085
& 8051
6/9/2024 EE3404/MPMC/Unit-4 3
Units of Microprocessor & Microcontroller
The Course deals with the following Units:
Unit –I : Introduction to 8085 Architecture
6/9/2024 EE3404/MPMC/Unit-4 4
Text and Reference Books
Textbooks:
1) Ramesh S. Gaonkar, ‘Microprocessor Architecture Programming and
Application’, Pen ram International (P)ltd., Mumbai, 6th Education, 2013.
2) Muhammad Ali Mazidi & Janice Gilli Mazidi, ‘The 8051 Micro Controller
and Embedded Systems’, Pearson Education, Second Edition 2011.
3) Muhammad Ali Mazidi & Janice Gilli Mazidi, ‘The PIC Micro Controller
and Embedded Systems’, 2010
Reference Books:
1) Douglas V. Hall, “Micro-processors & Interfacing”, Tata McGraw Hill 3rd
Edition, 2017.
2) Krishna Kant, “Micro-processors & Micro-controllers”, Prentice Hall of
India, 2007.
3) Mike Predko, “8051 Micro-controllers”, McGraw Hill, 2009
4) Kenneth Ayala, ‘The 8051 Microcontroller’, Thomson, 3rd Edition 2004.
6/9/2024 EE3404/MPMC/Unit-4 5
Unit-I: Introduction to 8085 Architecture
Topics to be discussed:
▪ Functional Block Diagram
▪ Memory Interfacing
▪ Timing Diagram
▪ Interrupt Structure
6/9/2024 EE3404/MPMC/Unit-4 6
Unit-II: 8085 Instruction Set and Programming
Topics to be discussed:
▪ Instruction Format and Addressing Modes
▪ Assembly Language Format
▪ Data Transfer, Data Manipulation &
Control Instructions
▪ Programming:
✓Loop structure with Counting & Indexing
✓Look up table
✓Subroutine instructions
✓Stack
6/9/2024 EE3404/MPMC/Unit-4 7
Unit-III: Interfacing Basics and ICs
Topics to be discussed:
▪ Study of Architecture and programming of ICs:
✓ 8255 - PPI
✓ 8259 - PIC
✓ 8251 - USART
✓ 8279 - Keyboard display controller
✓ 8254 - Timer/Counter
▪ Interfacing with 8085
✓A/D and D/A converter interfacing
6/9/2024 EE3404/MPMC/Unit-4 8
Unit-IV: Introduction to 8051 Microcontroller
Topics to be discussed:
▪ Functional Block Diagram
▪ Instruction Format And Addressing Modes
▪ Interrupt Structure
▪ Timer
▪ I/O Ports
▪ Serial Communication
▪ Simple Programming
▪ Keyboard And Display Interface
▪ Temperature Control System
▪ Stepper Motor Control
▪ Usage of IDE for Assembly Language Programming
6/9/2024 EE3404/MPMC/Unit-4 9
Unit-V: Introduction to RISC Based Architecture
Topics to be discussed:
▪ PIC16 /18 Architecture
▪ Memory Organization
▪ Addressing Modes
▪ Instruction Set
▪ Programming Techniques
▪ Timers
▪ I/O Ports
▪ Interrupt Programming
6/9/2024 EE3404/MPMC/Unit-4 10
Introduction
6/9/2024 EE3404/MPMC/Unit-4 11
Introduction to Microcontrollers
• Microcontroller – silicon chip which includes microprocessor,
memory & I/O ports in a single package.
• A Microcontroller has a CPU (Microprocessor) in addition to a
fixed amount of RAM,ROM, I/O ports and a timer all on a single
chip.
• 8051/8031 is a 8- bit Microcontroller.
• It has, ✓ CPU + I/O + Timer's) [+ ROM] [+ RAM]
✓ Low to moderate performance only
✓ Limited RAM space, ROM space and I/O pins
✓ EPROM version available
✓ Low chip-count to implement a small system
✓ Low-cost at large quantities
✓ Development tools readily available at reasonable
6/9/2024 EE3404/MPMC/Unit-4 12
Features of 8051/8031 Microcontroller
• ROM – 4K bytes
• RAM – 128 bytes
• Timers – ‘2’ (Timer 0, Timer 1)
• I/O Pins – ‘32’ [4 ports: Port 0 (AD0-AD7); Port 1;
Port 2 (A8-A15); Port 3 (Important Alternate Functions);
Each Port has 8 I/O pins]
• Serial Port – ‘1’ (UART : TxD (Transmit Data);
RxD (Receive Data);)
• Interrupt Sources – ‘6’ ( IE0; IE1; TF0; TF1; RI+TI )
• 8031 is called “ROM-less 8051”
• 8052 has all features of 8051 in addition to an extra 128 bytes of
RAM, extra Timer and extra 2 Interrupt Sources.
6/9/2024 EE3404/MPMC/Unit-4 13
Pin out of 8051 Microcontroller
6/9/2024 EE3404/MPMC/Unit-4 14
Pin out of
8051
Microcontroller
6/9/2024 EE3404/MPMC/Unit-4 15
Pin Descriptions of 8051
6/9/2024 EE3404/MPMC/Unit-4 16
Alternate functions of Port pins of 8051
6/9/2024 EE3404/MPMC/Unit-4 17
Functional block diagram/Architecture of 8051/8031
6/9/2024 EE3404/MPMC/Unit-4 18
Architecture of 8051 Microcontroller
6/9/2024 EE3404/MPMC/Unit-4 19
8-bit Registers of 8051
6/9/2024 EE3404/MPMC/Unit-4 20
Register Banks of 8051 Microcontroller
▪ Four banks of 8 byte-sized registers, Each Bank has 8
Registers R0 to R7
▪ Addresses are :
18H - 1FH for bank 3
10H – 17H for bank 2
08H - 0FH for bank 1
00H - 07H for bank 0 (default)
▪ Active bank selected by bits [ RS1, RS0 ] in PSW (Program Status
Word).
▪ Permits fast “context switching” in Interrupt Service Routines (ISR).
6/9/2024 EE3404/MPMC/Unit-4 21
Program Status Word (PSW) of 8051
6/9/2024 EE3404/MPMC/Unit-4 22
Register Bank of 8051
6/9/2024 EE3404/MPMC/Unit-4 23
16-bit Registers of 8051
DPH DPL
D15 D8 D7 D0
6/9/2024 EE3404/MPMC/Unit-4 24
16-bit CPU Registers of 8051
Stack Pointer :
✓ It is 8 bit wide.
✓ It is incremented before data is stored during PUSH and CALL
instructions.
✓ The stack array can reside anywhere in on-chip RAM.
✓ The stack pointer is initialized to 07H after a reset.
✓ This causes the stack to begin at location 08H.
Data Pointer (DPTR) :
✓ It consists of a high byte (DPH) and a low byte (DPL).
✓ Its function is to hold a 16 bit address.
✓ It may be manipulated as a 16 bit data register or as two
independent 8 bit registers.
✓ It serves as a base register in indirect jumps, lookup table
instructions and external data transfer.
6/9/2024 EE3404/MPMC/Unit-4 25
Von Neumann & Harvard Architectures
6/9/2024 EE3404/MPMC/Unit-4 26
Memory Space of 8051
6/9/2024 EE3404/MPMC/Unit-4 27
PolyU 11
Memory Organization of 8051
6/9/2024 EE3404/MPMC/Unit-4 28
Program Memory
✓ When the EA pin is connected to Vcc, program fetches to addresses 0000H
through OFFFH are directed to the internal ROM and program fetches to
addresses 1000H through FFFFH are directed to external ROM/EPROM.
✓ On the other hand when EA pin is grounded, all addresses (0000H to FFFFH)
fetched by program are directed to the external ROM/EPROM.
6/9/2024 EE3404/MPMC/Unit-4 29
Accessing External
Accessing External Code Memory
The PSEN signal is used to Code
activate Memory
output enable signal of the
external ROM/EPROM , as shown in the Figure.
Figure 2-8
Accessing
external
code
memory
6/9/2024 EE3404/MPMC/Unit-4 31
8051 Data Memory
✓ The 8051 can address up to 64 Kbytes of external data
memory.
6/9/2024 EE3404/MPMC/Unit-4 33
Data Memory
Accessing External Data Memory
Figure
2-11
nterface
to 1K
RAM
6/9/2024 EE3404/MPMC/Unit-4 35
Timing diagram for
External Data Memory Write Cycle
6/9/2024 EE3404/MPMC/Unit-4 36
Special Function Registers (SFRs)
✓ Unlike other microprocessors in the Intel family, 8051 uses
memory mapped I/O through a set of special function
registers that are implemented in the address space
immediately above the 128 bytes of RAM.
6/9/2024 EE3404/MPMC/Unit-4 38
Special Function Registers (SFRs)
6/9/2024 EE3404/MPMC/Unit-4 39
I/O Ports of 8051
✓ I/O Ports The 8051 has 4 bidirectional 8-bit I/O ports.
✓ Each port is connected to an 8-bit register in the SFR.
✓ P0 = 80H, P1 = 90H, P2 = A0H, P3 = B0H
✓ Each port is also connected to an output driver and an
input buffer.
✓ All ports are configured for output at reset.
✓ Some of the 4 ports have uses in addition to simple I/O.
✓ Ports P0 and P2 double as the 8051’s Address and Data
busses.
✓ Port P3 doubles as the 8051’s external control lines for the
timers and counters.
6/9/2024 EE3404/MPMC/Unit-4 40
I/O Ports of 8051
Port P0 :
✓P0 can be used for input or output.
✓The pins of P0 are connected internally to an “open drain”
circuit (similar to open collector but using MOS
transistors).
✓Therefore, it must be connected to an external pull-up
resistor (10 KΩ ) to operate properly as an output port.
✓To operate P0 as an input port, it must be programmed by
writing 1’s to all of its bits
6/9/2024 EE3404/MPMC/Unit-4 41
I/O Ports of 8051
Pull-up Resistor Pull-down Resistor
6/9/2024 EE3404/MPMC/Unit-4 42
I/O Ports of 8051
Port P0
6/9/2024 EE3404/MPMC/Unit-4 43
I/O Ports of 8051
Port P0
6/9/2024 EE3404/MPMC/Unit-4 44
I/O Ports of 8051
Dual Role of P0 :
6/9/2024 EE3404/MPMC/Unit-4 47
I/O Ports of 8051
Port P1 as Input:
6/9/2024 EE3404/MPMC/Unit-4 48
I/O Ports of 8051
Port P2 :
6/9/2024 EE3404/MPMC/Unit-4 49
I/O Ports of 8051
Port P2 :
6/9/2024 EE3404/MPMC/Unit-4 50
I/O Ports of 8051
Dual role of Port P2 :
✓ It is also designed as A8-A15, indicating the dual function.
✓ Since an 8051 is capable of accessing 64K bytes of
external memory, it needs a path for the 16 bits of the
address.
✓ While P0 provides the lower 8 bits via A0-A7, it is the job
of P2 to provide bits A8-A15 of the address.
✓ In other words, when 8051 is connected to external
memory, P2 is used for the upper 8 bits of the 16 bit
address, and it cannot be used for I/O.
6/9/2024 EE3404/MPMC/Unit-4 51
I/O Ports of 8051
Port P3 :
✓ Port 3 occupies a total of 8 pins, pins 10 through 17.
✓ It can be used as input or output.
✓ P3 does not need any pull-up resistors, the same as
P1 and P2 did not.
✓ Although port 3 is configured as an output port upon
reset.
✓ Port 3 has the additional function of providing some
extremely important signals such as interrupts.
6/9/2024 EE3404/MPMC/Unit-4 52
I/O Ports of 8051
Port P3 :
6/9/2024 EE3404/MPMC/Unit-4 53
I/O Ports of 8051
Dual Role of Port P3 :
✓ Port 3 occupies a total of 8 pins, pins 10 through 17.
✓ It can be used as input or output.
✓ P3 does not need any pull-up resistors, the same as P1
and P2 did not.
✓ Although port 3 is configured as an output port upon
reset.
✓ P3.0 and P3.1 are used for the RxD and TxD serial
communications signals.
✓ Bits P3.2 and P3.3 are set aside for external interrupts.
✓ Bits P3.4 and P3.5 are used for timers 0 and 1.
✓ Finally P3.6 and P3.7 are used to provide the WR and RD
signals
6/9/2024 EE3404/MPMC/Unit-4 54
I/O Ports of 8051
Alternate functions of Port P3 :
6/9/2024 EE3404/MPMC/Unit-4 55
Timers of 8051
✓ 8051 has two 16-bit programmable UP timers/counters.
6/9/2024 EE3404/MPMC/Unit-4 56
Timers of 8051
6/9/2024 EE3404/MPMC/Unit-4 57
Timers of 8051
Clock
✓ Every Timer needs a clock to work, and 8051 provides it
from an external crystal which is the main clock source for
Timer.
✓ The internal circuitry in the 8051 microcontrollers
provides a clock source to the timers which is 1/12th of
the frequency of crystal attached to the microcontroller,
also called as Machine cycle frequency.
6/9/2024 EE3404/MPMC/Unit-4 58
Timers of 8051
Clock
For example, suppose we have crystal frequency of
11.0592 MHz then microcontroller will provide 1/12th
i.e.
Timer clock frequency
= (Crystal Oscillator frequency)/12
= (11.0592 MHz)/12
= 921.6 KHz
period T = 1/(921.6 KHz)=1.085 μS
6/9/2024 EE3404/MPMC/Unit-4 59
Timers of 8051
✓ In the “Timer" function mode, the counter is incremented in
every machine cycle. Thus, one can think of it as counting
machine cycles. Hence the clock rate is 1/12 th of the
oscillator frequency.
✓ In the "Counter" function mode, the register is incremented
in response to a 1 to 0 transition at its corresponding
external input pin (T0 or T1).
✓ It requires 2 machine cycles to detect a high to low
transition. Hence maximum count rate is 1/24 th of oscillator
frequency.
✓ The operation of the timers/counters is controlled by two
special function registers, TMOD and TCON respectively.
6/9/2024 EE3404/MPMC/Unit-4 60
Timers of 8051
TMOD (Timer Mode) Register
6/9/2024 EE3404/MPMC/Unit-4 61
Timers of 8051
TCON (Timer Control) Register (1)
6/9/2024 EE3404/MPMC/Unit-4 62
Timers of 8051
TCON (Timer Control) Register (2)
6/9/2024 EE3404/MPMC/Unit-4 63
TMOD (Timer Mode) Register of 8051
Mode-0 (13-bit timer mode)
✓ Mode 0 is 13-bit timer mode for which 8-bit of THx and 5-bit of TLx
(as Pre-scaler) are used.
✓ It is mostly used for interfacing possible with old MCS-48 family
microcontrollers.
6/9/2024 EE3404/MPMC/Unit-4 66
TMOD (Timer Mode) Register of 8051
Mode-1 (16-bit timer mode)
This mode is similar to mode-0 except for the fact that the Timer
operates in 16-bit mode.
6/9/2024 EE3404/MPMC/Unit-4 67
TMOD (Timer Mode) Register of 8051
Mode-2 (8-bit auto-reload timer mode)
✓ Mode 2 is 8-bit auto-reload timer mode.
✓ In this mode we have to load the THx-8 bit value only.
✓ when the Timer gets started, THx value gets automatically loaded
into the TLx and TLx start counting from that value.
✓ After the value of TLx overflows from the 0xFF to 0x0, the TFx flag
gets set and again value from the THx gets automatically loaded
into the TLx register. That’s why this is called as auto reload mode.
6/9/2024 EE3404/MPMC/Unit-4 68
TMOD (Timer Mode) Register of 8051
Mode-2 (8-bit auto-reload timer mode)
✓ This is a 8 bit counter/timer operation.
✓ Counting is performed in TLX while THX stores a constant value.
✓ In this mode when the timer overflows i.e. TLX becomes FFH, it is
fed with the value stored in THX.
✓ For example if we load THX with 50H then the timer in mode 2
will count from 50H to FFH. After that 50H is again reloaded. This
mode is useful in applications like fixed time sampling.
6/9/2024 EE3404/MPMC/Unit-4 69
TMOD (Timer Mode) Register of 8051
Mode-3 (Split timer mode)
✓ Timer 1 in mode-3 simply holds its count.
✓ The effect is same as setting TR1=0. Timer0 in mode-3 establishes
TL0 and TH0 as two separate counters.
✓ Control bits TR1 and TF1 are used by Timer-0 (higher 8 bits) (TH0)
in Mode-3 while TR0 and TF0 are available to Timer-0 lower 8
bits(TL0).
6/9/2024 EE3404/MPMC/Unit-4 70
Timer interrupt in 8051
✓ It has two timer interrupts assigned with different vector address.
✓ When Timer count rolls over from its max value to 0, it sets timer
flag TFx. This will interrupt the 8051 microcontroller to serve ISR
(interrupt service routine) if global and timer interrupt is enabled.
✓ Timer overflow interrupt assigned with vector address shown in the
table.
✓ 8051 microcontroller jumps directly to the vector address on the
occurrence of a corresponding interrupt.
Interrupt source Vector address
Timer 0 overflow (TF0) 000BH
Timer 1 overflow (TF1) 001BH
6/9/2024 EE3404/MPMC/Unit-4 71
Interrupts of 8051
✓ Interrupts are basically the events that temporarily
suspend the main program, pass the control to the
external sources and execute their task.
✓ It then passes the control to the main program where it
had left off.
✓ 8051 has five interrupts.
✓ All of the interrupts can be enabled or disabled by using
the IE (Interrupt Enable) register.
✓ The Interrupts priority level can be decided by using the
IP (Interrupt Priority) register
6/9/2024 EE3404/MPMC/Unit-4 72
Interrupts of 8051
✓ Interrupts and their vector addresses are given below
Interrupt Address
INT0 0003H
INT1 000BH
T0 0013H
T1 001BH
TI/RI 0023H
6/9/2024 EE3404/MPMC/Unit-4 73
Interrupt Structure of 8051
6/9/2024 EE3404/MPMC/Unit-4 74
Interrupt Structure of 8051
6/9/2024 EE3404/MPMC/Unit-4 75
IE (Interrupt Enable) Register
✓ This register can be used to enable or disable interrupts
programmatically.
✓ This register is an SFR and the address is A8H.
6/9/2024 EE3404/MPMC/Unit-4 76
IP (Interrupt Priority) Register
6/9/2024 EE3404/MPMC/Unit-4 77
Basics of Serial Communication (1)
Serial versus Parallel Data Transfer-1
6/9/2024 EE3404/MPMC/Unit-4 78
Basics of Serial Communication (2)
Serial versus Parallel Data Transfer-2
6/9/2024 EE3404/MPMC/Unit-4 79
Basics of Serial Communication (3)
Simplex, Half-, and Full-Duplex Transfers
6/9/2024 EE3404/MPMC/Unit-4 80
Basics of Serial Communication (4)
Asynchronous Communication Synchronous Communication
Transmitter and receiver are not Transmitter and receiver are
synchronized by clock. synchronized by clock.
Character may arrive at any rate at Character is received at constant
receiver rate.
Data transfer is character oriented Data transfer takes place in blocks.
Start and stop bits are not required
Start and stop bits are required to to establish communication of each
establish communication of each character, however
character. ,synchronization bits are required
to transfer the data block.
Used in low-speed transmissions Used in high-speed transmission
6/9/2024 EE3404/MPMC/Unit-4 81
Basics of Serial Communication (5)
Asynchronous Data Framing – Start & Stop Bits
6/9/2024 EE3404/MPMC/Unit-4 82
Basics of Serial Communication (6)
Data Transfer Rate
▪ The rate of data transfer in serial data communication is stated in
bps (bits per second).
▪ Another widely used terminology for bps is baud rate. However,
the baud and bps rates are not necessarily equal.
▪ This is because baud rate is the modem terminology and is defined
as the number of signal changes per second.
▪ In modems a single change of signal sometimes transfers several
bits of data.
▪ As far as the conductor wire is concerned, the baud rate and bps
are the same
6/9/2024 EE3404/MPMC/Unit-4 83
Basics of Serial Communication (7)
RS232 Standards (1)
▪ To allow compatibility among data communication equipment
made by various manufacturers, an interfacing standard called
RS232 was set by the Electronics Industries Association (EIA) in
1960.
▪ In 1963, it was modified and called RS232A.
▪ RS232B and RS232C were issued in 1965 and 1969, respectively.
▪ Here, we refer to it simply as RS232.
▪ Today, RS232 is the most widely used serial I/O interfacing
standard.
▪ This standard is used in PCs and numerous types of equipment.
6/9/2024 EE3404/MPMC/Unit-4 84
Basics of Serial Communication (8)
RS232 Standards (2)
▪ However, since the standard was set long before the advent of the
TTL logic family, its input and output voltage levels are not TTL-
compatible.
6/9/2024 EE3404/MPMC/Unit-4 85
Basics of Serial Communication (9)
RS232 Pins – DB 25 Connector
6/9/2024 EE3404/MPMC/Unit-4 86
Basics of Serial Communication (10)
RS232 Pins – DB 9 Connector
6/9/2024 EE3404/MPMC/Unit-4 87
Basics of Serial Communication (12)
Null Modem Connection
6/9/2024 EE3404/MPMC/Unit-4 88
Serial Communication in 8051 (1)
✓ The RS232 standard is not TTL-compatible;
✓ Therefore, it requires a line driver such as the MAX232 chip to
convert RS232 voltage levels to TTL levels, and vice versa. T
6/9/2024 EE3404/MPMC/Unit-4 89
Serial Communication in 8051 (2)
Baud Rate:-The rate at which the number of bits are
transmitted
6/9/2024 EE3404/MPMC/Unit-4 90
Serial Communication in 8051 (3)
Serial Interface
✓ The serial port of 8051 is full duplex, i.e., it can transmit and
receive simultaneously.
✓ The register SBUF is used to hold the data. The special function
register SBUF is physically two registers.
✓ The other is, read-only and holds the received data from
external sources via RXD.
6/9/2024 EE3404/MPMC/Unit-4 91
Serial Communication in 8051 (4)
SBUF Register
• It is an 8-bit register used for serial communication.
• For a byte data to be transferred via the TxD line, it must be
placed in the SBUF register.
• The moment a byte is written into SBUF, it is framed with the start
and stop bits and transferred serially via the TxD line.
• SBUF holds the byte of data when it is received by 8051 RxD line.
• When the bits are received serially via RxD, the 8051 deframes it
by eliminating the stop and start bits, making a byte out of the
data received, and then placing it in SBUF.
6/9/2024 EE3404/MPMC/Unit-4 92
Serial Communication in 8051 (5)
Serial Port Control Register (SCON)-1
Register SCON controls serial data communication.
Address: 098H (Bit addressable)
6/9/2024 EE3404/MPMC/Unit-4 93
Serial Communication in 8051 (6)
Serial Port Control Register (SCON)-2
Register SCON controls serial data communication.
Address: 098H (Bit addressable)
6/9/2024 EE3404/MPMC/Unit-4 94
Serial Communication in 8051 (7)
PCON (Power Control Register)
6/9/2024 EE3404/MPMC/Unit-4 95
Addressing Modes of 8051 Microcontroller (1)
▪ The length of an 8051 instruction is 1, 2, or 3 bytes.
▪ The opcode for an instruction is always 8 bits long. Hence 28
256 opcodes are possible, of which 255 opcodes have been
implemented.
▪ They can be classified into 111 types of instructions.
▪ If the crystal frequency is 12 MHz, then 64 instruction types are
executed in just 1s, and the rest in just 2s (except for multiply
and divide instructions that need 4s).
▪ Intel 8051 provides the following addressing modes for
accessing data from internal data memory or external data
memory
6/9/2024 EE3404/MPMC/Unit-4 96
Addressing Modes of 8051 Microcontroller (2)
▪ The CPU can access data in various ways.
▪ The data could be in a register, or in memory, or be provided
as an immediate value.
▪ These various ways of accessing data are called addressing
modes.
▪ The 8051 provides distinct addressing modes. They are as
follows:
1) Register Addressing
2) Register Indirect Addressing
3) Direct Byte Addressing
4) Stack Addressing
5) Register-Specific/ Implied Addressing
6) Immediate Addressing
7) Base + Index Register Addressing
6/9/2024 EE3404/MPMC/Unit-4 97
Addressing Modes of 8051 Microcontroller (3)
Register Addressing
▪ It involves the use of registers to hold the data to be
manipulated.
▪ Examples
6/9/2024 EE3404/MPMC/Unit-4 98
Addressing Modes of 8051 Microcontroller (4)
Register Indirect Addressing (1)
▪ In this mode, a register is used as a pointer to the data.
▪ If the data is inside the CPU, only registers R0 and R1 are
used for this purpose
▪ When R0 and R1 are used as pointers, that is, when they
hold the addresses of RAM locations, they must be
preceded by the “@” sign
▪ Examples
6/9/2024 EE3404/MPMC/Unit-4 99
Addressing Modes of 8051 Microcontroller (5)
Register Indirect Addressing (2)
Examples:
MOV A, @R1
2-Byte Instruction
Low byte
Opcode data/address
3-Byte Instruction
Low byte High byte
Opcode data/address data/address
2) MOV A, #FFH; Load immediate 8-bit data (FFH) into the accumulator.
Solution: The row and column can be used to identify the key.
(a) The row belongs to D0 and the column belongs to D2; therefore,
key number 2 was pressed.
(b) The row belongs to D1 and the column belongs to D3; therefore,
key number 7 was pressed.
6/9/2024 EE3404/MPMC/Unit-4 155
Keyboard and Display Interface (17)
Assembly Language Program (1)