Microcontroller - Module1
Microcontroller - Module1
The 8051 Microcontroller is designed by Intel in 1981. 8051 is 40 pin DIP IC. This is an 8-bit
microcontroller.
It is a very famous Microcontroller of Intel family. As we know Microprocessor like 8085, Z-
80 or M6800 contains the ALU, control unit and some registers, but there were no internal
storages. The Microcontroller contains the RAM and ROM, IO ports inside it. Some
microcontroller also contains the ADC in it. As most of the required components are inside
the chip, so the cost of application is also reduced.
These kinds of microcontrollers are used in different appliances like televisions, washing
machines, telephones or some other electronic gadgets. The microcontroller is more complex
than microprocessors based on their architecture. The first generation Intel Microcontroller
was 8048. The 8051 is successor of that. So it is treated as the second generation
microcontroller. 8051 belongs to MCS-51 family of Intel Microcontrollers.
RISC and CISC are two different types of computer architectures that are used to design the
microprocessors that are found in computers. The fundamental difference between RISC and
CISC is that RISC (Reduced Instruction Set Computer) includes simple instructions and
takes one cycle, while the CISC (Complex Instruction Set Computer) includes complex
instructions and takes multiple cycles.
.
What is RISC?
In the RISC architecture, the instruction set of the computer system is simplified to reduce
the execution time. RISC architecture has a small set of instructions that generally includes
register-to-register operations.
The RISC architecture uses comparatively a simple instruction format that is easy to decode.
The instruction length can be fixed and aligned to word boundaries. RISC processors can
execute only one instruction per clock cycle.
What is CISC?
The CISC architecture comprises a complex instruction set. A CISC processor has a
variable-length instruction format. In this processor architecture, the instructions that require
register operands can take only two bytes.
In a CISC processor architecture, the instructions which require two memory addresses can
take five bytes to comprise the complete instruction code. Therefore, in a CISC processor, the
execution of instructions may take a varying number of clock cycles. The CISC processor
also provides direct manipulation of operands that are stored in the memory.
The primary objective of the CISC processor architecture is to support a single machine
instruction for each statement that is written in a high-level programming language.
The following are the important characteristics of a CISC processor architecture ?
• CISC can have variable-length instruction formats.
• It supports a set of a large number of instructions, typically from 100 to 250
instructions.
• It has a large variety of addressing modes, typically from 5 to 20 different modes.
• CISC has some instructions which perform specialized tasks and are used
infrequently.
CISC architectures have a large, complex instruction set and a less efficient execution
pipeline. This allows CISC processors to perform a wider range of tasks, but they are not as
fast as RISC processors when executing instructions.
Difference between RISC and CISC
The following table highlights all the important differences between RISC and CISC
architectures ?
[Link]. RISC CISC
Examples of RISC chips include SPARC, Examples of CISC include Intel architecture,
6.
POWER PC. AMD.
Registers are used for procedure The stack is used for procedure arguments and
12.
arguments and return addresses. return addresses.
The most significant difference between RISC and CISC architectures is the size and
complexity of the instruction set. RISC is a microprocessor architecture that uses a small
instruction set of uniform length that allows fast execution, while the CISC architecture is
one that offers hundreds of instructions of different sizes that allows the users to perform a
wider range of tasks.
Von Neumann and Harvard architectures are the two basic models in the field of computer
architecture, explaining the organization of memory and processing units in a computer
system. For those involved in Computer Science or working in companies providing
computing technologies, it is essential to understand the characteristics of these architectures.
There are two models of multiprocessing architectures: Von Neumann and Harvard. While
the former occupies a dominant position. From the its principal differences from the latter,
along with their respective advantages and disadvantages, we can understand which
architecture is more suitable for a given application.
Von Neumann Architecture
Von Neumann Architecture is a digital computer architecture whose design is based on the
concept of stored program computers where program data and instruction data are stored in
the same memory. This architecture was designed by the famous mathematician and
physicist John Von Neumann in 1945.
Advantages of Von Neumann Architecture
• Simplicity: The fact that all data and instructions are stored in a single memory space
helps the process of designing a computer system as there is no need to create
complicated systems of routing since pathways may coincide.
• Cost-Effective: A smaller number of components is needed as compared to the other
architectural designs hence more economical.
• Flexibility: A program can Always be changed or altered without experiencing a
change in some underlying physical aspects such as the circuitry.
Disadvantages of Von Neumann Architecture
• Bottleneck Issues: The shared bus can be a problem because the data and control
instructions cannot be obtained simultaneously and therefore it becomes slow.
• Memory Corruption: Since the data and instructions reside in the same memory,
then there is a temptation of one erasing the other thereby producing system faults.
Harvard Architecture
Harvard Architecture is the digital computer architecture whose design is based on the
concept where there are separate storage and separate buses (signal path) for instruction and
data. It was basically developed to overcome the bottleneck of Von Neumann Architecture.
Features
• Separate memory spaces
• Fixed instruction length
• Parallel instruction and data access
• More efficient memory usage
• Suitable for embedded systems
• Limited flexibility
Advantages of Harvard Architecture
• Faster Processing: The availability of two buses for data and instructions avoids a
problem of contention where only one bus is used and this enhances the velocity of
the system.
• Improved Security: In this way the chance of memory corruption is at least cut in
half since data is not stored in the same locations as instructions.
• Efficient Use of Resources: It enables the use of different memory for data and for
instructions of different sizes as this help in optimal utilization of the buses and other
resources.
Disadvantages of Harvard Architecture
• Complexity: The design and the implementation of this type are more intricate, thus
necessitating other hardware facilities.
• Higher Cost: Since the concept of Harvard architecture calls for two sets of memory
and two separate buses, their implementation costs are comparatively high than Von
Neumann architecture.
• Less Flexibility Competitors : Changing or even improving the system can also be a
little tricky because of the different memory regions.
The Von Neumann and Harvard architectures are fundamental concepts in computer
organization, each with distinct memory and processor setups.
Same physical memory address is used for Separate physical memory address is used
instructions and data. for instructions and data.
There is common bus for data and Separate buses are used for transferring data
instruction transfer. and instruction.
CPU can not access instructions and CPU can access instructions and read/write
read/write at the same time. at the same time.
It is used in personal computers and small It is used in micro controllers and signal
computers. processing.
In the following diagram, the system bus connects all the support devices to the CPU.
The system bus consists of an 8-bit data bus, a 16-bit address bus and bus control signals.
All other devices like program memory, ports, data memory, serial interface, interrupt
control, timers, and the CPU are all interfaced together through the system bus.
The pin diagram of 8051 microcontroller looks as follows −
• Pins 1 to 8 − These pins are known as Port 1. This port doesnt serve any other
functions. It is internally pulled up, bi-directional I/O port.
• Pin 9 − It is a RESET pin, which is used to reset the microcontroller to its initial
values.
• Pins 10 to 17 − These pins are known as Port 3. This port serves some functions like
interrupts, timer input, control signals, serial communication signals RxD and TxD,
etc.
• Pins 18 & 19 − These pins are used for interfacing an external crystal to get the
system clock.
• Pin 20 − This pin provides the power supply to the circuit.
• Pins 21 to 28 − These pins are known as Port 2. It serves as I/O port. Higher order
address bus signals are also multiplexed using this port.
• Pin 29 − This is PSEN pin which stands for Program Store Enable. It is used to read a
signal from the external program memory.
• Pin 30 − This is EA pin which stands for External Access input. It is used to
enable/disable the external memory interfacing.
• Pin 31 − This is ALE pin which stands for Address Latch Enable. It is used to
demultiplex the address-data signal of port.
• Pins 32 to 39 − These pins are known as Port 0. It serves as I/O port. Lower order
address and data bus signals are multiplexed using this port.
• Pin 40 − This pin is used to provide power supply to the circuit.
8051 microcontrollers have 4 I/O ports each of 8-bit, which can be configured as input or
output. Hence, total 32 input/output pins allow the microcontroller to be connected with the
peripheral devices.
• Pin configuration, i.e. the pin can be configured as 1 for input and 0 for output as per
the logic state.
o Input/Output (I/O) pin − All the circuits within the microcontroller must be
connected to one of its pins except P0 port because it does not have pull-up
resistors built-in.
o Input pin − Logic 1 is applied to a bit of the P register. The output FE
transistor is turned off and the other pin remains connected to the power
supply voltage over a pull-up resistor of high resistance.
• Port 0 − The P0 (zero) port is characterized by two functions −
o When the external memory is used then the lower address byte (addresses
A0A7) is applied on it, else all bits of this port are configured as input/output.
o When P0 port is configured as an output then other ports consisting of pins
with built-in pull-up resistor connected by its end to 5V power supply, the pins
of this port have this resistor left out.
Input Configuration of Ports
If any pin of this port is configured as an input, then it acts as if it floats, i.e. the input has
unlimited input resistance and in-determined potential.
Output Configuration
When the pin is configured as an output, then it acts as an open drain. By applying logic 0 to
a port bit, the appropriate pin will be connected to ground (0V), and applying logic 1, the
external output will keep on floating.
In order to apply logic 1 (5V) on this output pin, it is necessary to build an external pullup
resistor.
Port 1
P1 is a true I/O port as it doesnt have any alternative functions as in P0, but this port can be
configured as general I/O only. It has a built-in pull-up resistor and is completely compatible
with TTL circuits.
Port 2
P2 is similar to P0 when the external memory is used. Pins of this port occupy addresses
intended for the external memory chip. This port can be used for higher address byte with
addresses A8-A15. When no memory is added then this port can be used as a general
input/output port similar to Port 1.
Port 3
In this port, functions are similar to other ports except that the logic 1 must be applied to
appropriate bit of the P3 register.
Pins Current Limitations
• When pins are configured as an output (i.e. logic 0), then the single port pins can
receive a current of 10mA.
• When these pins are configured as inputs (i.e. logic 1), then built-in pull-up resistors
provide very weak current, but can activate up to 4 TTL inputs of LS series.
• If all 8 bits of a port are active, then the total current must be limited to 15mA (port
P0: 26mA).
• If all ports (32 bits) are active, then the total maximum current must be limited to
71mA.
Interrupts are 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 5 interrupt signals, i.e. INT0, TFO, INT1, TF1, RI/TI. Each interrupt can be enabled
or disabled by setting bits of the IE register and the whole interrupt system can be disabled by
clearing the EA bit of the same register.
IE (Interrupt Enable) Register
This register is responsible for enabling and disabling the interrupt. EA register is set to one
for enabling interrupts and set to 0 for disabling the interrupts. Its bit sequence and their
meanings are shown in the following figure.
Microcontrollers are the key components of several electronic devices and embedded
systems, and they are brain behind their automated functioning or operation. Today,
microcontrollers are being used in devices, ranging from simple home appliances to complex
industrial automation systems.
Microcontrollers use several different types of instructions to perform operations; these
instructions are collectively known as instruction set.
When all of the register banks are being used, the scratch pad area will be 20H to 7FH. But
from 20H to 2FH (16 bytes or 128 bits) can be used as bit addressable RAM. By using some
simple instructions with 8-bit memory address we can check the bit addressing. For an
example the instruction CLR 6FH, using this instruction it clears the location 6FH. As we
know the8-bit address can locate 256 different locations, but here only128-bits are
addressable. Another section of bit addressable locations is 80H to FFH. The remaining
locations (30H to 7EH) of the RAM can be used to store variable data and stack.
Stack Area
The stack area in 8051always can be implemented in the internal data memory. Here the
stack pointer (SP) is an only 8-bit register, because the internal RAM area is only in range
00H to 7FH, and when all register banks are being used, the stack location will be in range
30H to 7FH. So in such a case, the SP will be initialized with 2FH.
The stack pointer SP increases before each PUSH operation and decreases after each pop
instruction.
When the 8051 is reset, the Stack Pointer will point to 07H. It means the location 08H to
7FHcan be used as a stack. We are assuming that the register bank 0 is in use and 20H to 27H
are not like bit-addressable area.
The 8051 microcontroller is one of the most widely used type of microcontrollers in various
embedded systems, ranging from small electronic devices to complex industrial systems. One
of the key drawbacks of the 8051 microcontroller is that it has limited internal memory that
makes it essential to interface with an external memory like RAM or ROM. This external
memory interfacing allows the 8051 microcontroller to store larger programs, perform
complex operations, and handle large amount of data.
The following instructions are used to access the external ROM interfaced with the 8051
microcontroller −
Mnemonic Operation
MOVX A, @Rp This instruction copies the content of external RAM at address Rp to A.
MOVX A, @DPTR This instruction copies the content of external RAM at address DPTR to A.
MOVX @Rp, A This instruction copies the data from A to external address in Rp.
MOVX DPTR, A This instruction copies the data from A to external address in DPTR
Address decoding is one of the important processes which ensures that the correct memory
device is selected. As we know, the 8051 microcontroller has a 16-bit address bus (A0 to
A15), hence address decoding becomes a necessary process for correct memory mapping.
Issues in External Memory Interfacing in 8051 Microcontroller
When interfacing external memory devices with the 8051 microcontroller, several issues can
arise, some very common of them are as follows –
• If the timing signals which are used to control the external memory access are
incorrect, then they can cause errors in transfer or program execution.
• Interferences like electromagnetic interference or radio frequency interference can
cause errors or data corruption in external memory access.
• If the signal integrity of the address and data lines is not maintained, then it can cause
inaccurate data transfer between the microcontroller and the external memory device.
• The external memory devices require a stable and reliable power supply for proper
communication.
• The external memory devices used to interface with the 8051 microcontroller must be
compatible in terms of voltage, timing, and interface protocol specifications.
Conclusion
In conclusion, the 8051 microcontroller needs external memory interfacing for complex
applications that require additional memory for program and data storage. It allows
developers to expand the capabilities of the 8051 microcontroller by connecting external
memory devices.
Computers operate using binary code, a language made up of 0s and 1s. This binary code
forms the foundation of all computer operations, enabling everything from rendering videos
to processing complex algorithms. A single bit is a 0 or a 1, and eight bits make up a byte.
While some data, such as certain English characters, can be represented by a single byte,
other data types require multiple bytes. The concept of endianness is crucial in understanding
how these bytes are read and interpreted by computers.
What is Endianness?
Endianness refers to the order in which bytes are arranged in memory. Different languages
read their text in different orders. for example, English reads from left to right, while Arabic
reads from right to left. Endianness works similarly for computers. If one computer reads
bytes from left to right and another reads them from right to left, issues arise when these
computers need to communicate.
Endianness ensures that bytes in computer memory are read in a specific order. Each
computer system is internally consistent with its own data, but the advent of the internet has
led to more data sharing than ever before, and not all systems read data in the same order.
Endianness comes in two primary forms: Big-endian (BE) and Little-endian (LE).
• Big-endian (BE): Stores the most significant byte (the "big end") first. This means
that the first byte (at the lowest memory address) is the largest, which makes the most
sense to people who read left to right.
• Little-endian (LE): Stores the least significant byte (the "little end") first. This means
that the first byte (at the lowest memory address) is the smallest, which makes the
most sense to people who read right to left.
What is Big-endian?
In a big-endian system, the most significant byte (MSB) is stored at the lowest memory
address. This means the "big end" (the most significant part of the data) comes first. For
instance, a 32-bit integer 0x12345678 would be stored in memory as follows in a big-endian
system:
Address: 00 01 02 03
Data: 12 34 56 78
Here, 0x12 is the most significant byte, placed at the lowest address (00), followed by 0x34,
0x56, and 0x78 at the highest address (03).
What is Little-endian?
A little-endian system stores the least significant byte (LSB) at the lowest memory address.
The "little end" (the least significant part of the data) comes first. For the same 32-bit
integer 0x12345678, a little-endian system would store it as:
Address: 00 01 02 03
Data: 78 56 34 12
Here, 0x78 is the least significant byte, placed at the lowest address (00), followed
by 0x56, 0x34, and 0x12 at the highest address (03).
Significance of Most Significant Byte (MSbyte) in Little and Big Endian:
Understanding the concept of the Most Significant Byte (MSbyte) helps clarify endianness
further. Let's use a decimal number to illustrate.
Consider the decimal number 2,984. Changing the digit 4 to 5 increases the number by 1,
while changing the digit 2 to 3 increases the number by 1,000. This concept applies to bytes
and bits as well.
• Most Significant Byte (MSbyte): The byte that holds the highest position value.
• Least Significant Byte (LSbyte): The byte that holds the lowest position value.
In big-endian format, the MSbyte is stored first. In little-endian format, the MSbyte is stored
last.
When Might Endianness Be an Issue?
Endianness must be considered in various computing scenarios, particularly when systems
with different byte orders need to communicate or share data.
1. Unicode Characters: Unicode, the character set used universally across devices, uses
a special character byte sequence called the Byte Order Mark
(BOM). The BOM informs the system that the incoming stream is Unicode, specifies
which Unicode character encoding is used, and indicates the endian order of the
incoming stream.
2. Programming Languages: Some programming languages require specifying the byte
order sequence. For instance, in Swift, used for iOS development, you can define
whether data is stored in big-endian or little-endian format.
3. Network Protocols: Different protocols have emerged historically, leading to the
need for interaction. Big-endian is the dominant order in network protocols and is
referred to as network order. Conversely, most PCs use little-endian format. Ensuring
interoperability between these formats is critical in network communication.
4. Processor Design: Processors can be designed to be either little-endian, big-
endian, or bi-endian (capable of handling both). Consumer choice and the resulting
market trends have influenced what is considered "normal" in computer systems
today.
Why is Endianness an Issue?
Endianness becomes an issue primarily due to the interaction between different systems and
protocols. Historical protocol development led to varying byte order conventions,
necessitating data conversion for compatibility. In higher-level languages and abstracted
environments, endianness is often managed behind the scenes, reducing the need for
developer concern. However, understanding endianness remains crucial for low-level
programming, network protocol design, and data interoperability.
Conclusion
Endianness is how bytes are ordered in computer data. Big-endian and little-endian are two
ways to arrange bytes, each with advantages. Understanding endianness is very important for
developers dealing with low-level data, networking, and system interoperability. While little-
endian is common, both formats remain important as technology evolves. Strategies for
managing data across endian conventions will continue developing to ensure compatibility
and performance.
Module -2
Types of Microcontroller Instructions
Microcontroller instructions can be classified into several categories depending on their
functionality, they are −
• Data processing instructions
• Arithmetic instructions
• Logical instructions
• Multiply instructions
• Comparison instructions
• Move instructions
• Barrel shifter instructions
Each of these types of microcontroller instructions are explained below in detail.
Data Processing Instructions
As the name implies, those microcontroller instructions which are used for manipulating data
withing registers are referred to as data processing instructions. These instructions make the
processor capable to perform operations.
The following is a simple example of data processing instruction −
This is a simple subtraction instruction which subtracts the value stored in the
register r2 from a value stored in the register r1, and stores the result of subtraction in the
register r0.
Before execution of the instruction, we have,
r0 = 0x00000000; Register r0 is empty before execution of the instruction.
r1 = 0x00000005; Register r1 holds a value 5.
r2 = 0x00000002; Register r2 holds a value 2.
SUB r0, r1, r2; r0 = r1 r2
After execution of this instruction, we get,
r0 = 0x00000003;
This is the output of the instruction.
Arithmetic Instructions
Microcontroller instructions which are used to perform and handle basic mathematical
operations, i.e., addition, subtraction, and multiplication are termed as arithmetic instructions.
The following table highlights all the key arithmetic instructions used in microcontrollers −
Instruction Description Operation Expression
ORR Bitwise OR Rd = Rn | N
SMLAL Signed multiply accumulate long [RdHi, RdLo] = [RdHi, RdLo] + (Rm * Rs)
UMLAL Unsigned multiply accumulate long [RdHi, RdLo] = [RdHi, RdLo] + (Rm * Rs)
Let's understand multiply instructions in microcontrollers with the help of an example.
This example shows a simple multiply instruction of two registers namely, r1 and r2, and it
stores the result in another register r0.
Before execution of the instruction,
r0 = 0x00000000;
r1 = 0x00000005;
r2 = 0x00000002;
MUL r0, r1, r2; r0 = r1 * r2;
After execution of the instruction, we get,
r0 = 0x00000010;
Comparison Instructions
Comparison instructions in microcontrollers are used to test or compare values within a
register. They also update the cpsr flags in the status register of the processor, without
affecting other registers.
After setting up the flag bits, information can then be utilized for altering the flow of program
execution. Some common comparison instructions used in microcontrollers are given below
−
Instruction Description Operation
TEQ Test for quality of two 32-bit values Flags set as a result of Rn ^ N
RRX Rotate right extended xRRX (c flag << 31) | [(unsigned) x >> 1]
Here, x is the register being shifted and y is the shift amount.
Here is an example to explain the working of barrel shifter instructions in microcontrollers −
Before execution of instruction,
cpsr = nzcvqiFt_USER
r0 = 0x00000000;
r1 = 0x50000002;
MOVS r0, r1, LSL #1;
After execution of the instruction, we get,
cpsr = nzcvqiFt_USER
r0 = 0x00000005;
r1 = 0x50000002;
Advantages of Microcontroller Instruction Sets
The following are some key benefits of instruction sets of a microcontroller –
• Microcontroller instruction sets are efficient and enables fast execution or processing.
• Microcontroller instructions require low power to perform tasks, hence they are best
suited for embedded systems.
• Microcontroller instruction sets are versatile, as they support a wide range of
operations.
Disadvantages of Microcontroller Instruction Sets
Despite several advantages, the instruction sets of microcontrollers also have some
disadvantages, which are as follows −
• Microcontroller instruction sets offer limited flexibility. Thus, some operations need
more than one instruction.
• Microcontroller instruction sets are hardware dependent and offer compatibility
challenges.
Conclusion
In this chapter, we covered some essential types of instruction sets used in microcontrollers.
It is important to learn instruction sets for understanding the working of microcontrollers and
optimize their performance.
The instructions of 8051 Microcontroller can be classified into five different groups. These
groups are like below
• Data Transfer Group
• Arithmetic Group
• Logical Group
• Program Branch Group
• Bit Processing Group
•
This Bit-Processing group is also known as Boolean Variable Manipulation.
Like 8085, some instruction has two operands. The first operand is the Destination, and the
second operator is Source.
In the following examples, you will get some notations. The notations are like −
Rn = Any register from R0to R7
Ri = Either R0 or R1
d8 = Any 8-bit immediate data (00H to FFH)
d16 = 16-bit immediate data
a8 = 8-bit address
bit = 8-bit address of bit which is bit addressable
rel = 8-bit signed displacement. The range is -128 to 127. It is relative
Addressing Modes
In this section, we will see different addressing modes of the 8051 microcontrollers. In
8051 there are 1-byte, 2-byte instructions and very few 3-byte instructions are present.
The opcodes are 8-bit long. As the opcodes are 8-bit data, there are 256 possibilities.
Among 256, 255 opcodes are implemented.
The clock frequency is12MHz, so 64 instruction types are executed in just 1 µs, and rest
are just 2 µs. The Multiplication and Division operations take 4 µsto to execute.
In this Immediate Addressing Mode, the data is provided in the instruction itself. The
data is provided immediately after the opcode. These are some examples of Immediate
Addressing Mode.
MOVA, #0AFH;
MOVR3, #45H;
MOVDPTR, #FE00H;
In these instructions, the # symbol is used for immediate data. In the last instruction,
there is DPTR. The DPTR stands for Data Pointer. Using this, it points the external
data memory location. In the first instruction, the immediate data is AFH, but one 0 is
added at the beginning. So when the data is starting with A to F, the data should be
preceded by 0.
In the register addressing mode the source or destination data should be present in a
register (R0 to R7). These are some examples of RegisterAddressing Mode.
MOVA, R5;
MOVR2, #45H;
MOVR0, A;
In 8051, there is no instruction like MOVR5, R7. But we can get the same result by
using this instruction MOV R5, 07H, or by using MOV 05H, R7. But this two
instruction will work when the selected register bank is RB0. To use another register
bank and to get the same effect, we have to add the starting address of that register
bank with the register number. For an example, if the RB2 is selected, and we want to
access R5, then the address will be (10H + 05H = 15H), so the instruction will look like
this MOV 15H, R7. Here 10H is the starting address of Register Bank 2.
In the Direct Addressing Mode, the source or destination address is specified by using 8-
bit data in the instruction. Only the internal data memory can be used in this mode.
Here some of the examples of direct Addressing Mode.
MOV80H, R6;
MOVR2, 45H;
MOVR0, 05H;
The first instruction will send the content of registerR6 to port P0 (Address of Port 0 is
80H). The second one is forgetting content from 45H to R2. The third one is used to get
data from Register R5 (When register bank RB0 is selected) to register R5.
Register indirect addressing Mode
In this mode, the source or destination address is given in the register. By using register
indirect addressing mode, the internal or external addresses can be accessed. The R0
and R1 are used for 8-bit addresses, and DPTR is used for 16-bit addresses, no other
registers can be used for addressing purposes. Let us see some examples of this mode.
MOV0E5H, @R0;
MOV@R1, 80H
In the instructions, the @ symbol is used for register indirect addressing. In the first
instruction, it is showing that theR0 register is used. If the content of R0 is 40H, then
that instruction will take the data which is located at location 40H of the internal RAM.
In the second one, if the content of R1 is 30H, then it indicates that the content of port
P0 will be stored at location 30H in the internal RAM.
MOVXA, @R1;
MOV@DPTR, A;
In these two instructions, the X in MOVX indicates the external data memory. The
external data memory can only be accessed in register indirect mode. In the first
instruction if the R0 is holding 40H, then A will get the content of external RAM
location40H. And in the second one, the content of A is overwritten in the location
pointed by DPTR.
In the indexed addressing mode, the source memory can only be accessed from program
memory only. The destination operand is always the register A. These are some
examples of Indexed addressing mode.
MOVCA, @A+PC;
MOVCA, @A+DPTR;
The C in MOVC instruction refers to code byte. For the first instruction, let us consider
A holds 30H. And the PC value is1125H. The contents of program memory location
1155H (30H + 1125H) are moved to register A.
Implied Addressing Mode
In the implied addressing mode, there will be a single operand. These types of
instruction can work on specific registers only. These types of instructions are also
known as register specific instruction. Here are some examples of Implied Addressing
Mode.
RLA;
SWAPA;
These are 1- byte instruction. The first one is used to rotate the A register content to the
Left. The second one is used to swap the nibbles in A.