S16-8051 Addressing Modes
S16-8051 Addressing Modes
1. Course Description: This course aims to teach students the fundamentals of microprocessor and
microcontroller systems. The student will be able to incorporate these concepts into their electronic designs
for other courses where control can be achieved via a microprocessor/controller implementation. Upon
gaining the fundamental knowledge of microprocessor and microcontroller architecture and programming,
the students will be able to design systems for embedded applications like home appliances, consumer
electronics, and the telephone industry and in the field of instrumentation control.
2. Aim
This topic aims to teach students the Addressing modes of 8051microcontroller.
Apply the architecture and Programming Concepts of the 8051 microcontroller and analyze the
programming concepts
5. Module Description:
The 8051 microcontroller is a popular and versatile microcontroller that has been used in a wide variety
of applications. Some of the common applications of the 8051 microcontrollers are:
1. Embedded Systems: The 8051 microcontroller is widely used in embedded systems because of its
low power consumption, small size, and easy interfacing with other devices.
2. Robotics: The 8051 microcontroller is used in robotics to control the movement of the robot, the
sensors, and other devices.
3. Automotive Applications: The 8051 microcontroller is used in automotive applications to control
various systems such as the engine, transmission, brakes, and suspension.
4. Industrial Automation: The 8051 microcontroller is used in industrial automation to control various
machines and processes.
5. Home Automation: The 8051 microcontroller is used in home automation to control various
systems such as lighting, temperature, security, and entertainment.
6. Medical Devices: The 8051 microcontroller is used in medical devices such as blood glucose meters,
blood pressure monitors, and pulse oximeters.
7. Consumer Electronics: The 8051 microcontroller is used in consumer electronics such as
televisions, washing machines, and refrigerators to control various functions.
8. Security Systems: The 8051 microcontroller is used in security systems such as door locks, access
control systems, and alarms.
9. Instrumentation: The 8051 microcontroller is used in instrumentation systems to control various
sensors and measure different parameters.
10. Communication Systems: The 8051 microcontroller is used in communication systems such as
modems, routers, and wireless devices.
Unit Structure:
Microcontroller: 8051 Architecture, Pin Diagram, addressing modes, Instruction sets, Programs
involving Arithmetic and Logical Instructions, 8051- Timers/Counters, Interrupts & Serial port Assembly
level programming.
6. Session Introduction
The term addressing modes refers to the way in which the operand of an instruction is specified. The
addressing mode specifies a rule for interpreting or modifying the address field of the instruction before the
operand is executed.
7. Session description
The addressing mode determines how the operand byte is selected. The direct and indirect addressing modes
are used to distinguish between the SFR (Special Function Register) space and data memory space. The
relative instructions are based on the value of the program counter. The absolute instructions operate in the
same manner. Indexed instructions use a calculation to generate the address used as part of the instruction.
The direct addressing modes specifies actual memory address (hexadecimal format) as operand or by using
abbreviated names (eg.P3)
Example: MOV A, 20H; Transfer the content of memory location 20H to accumulator.
In indirect addressing mode the effective address is indirectly mentioned by a pointer register. R0, R1 and
DPTR are used as pointer registers. R0, R1 holds 8-bit address and DPTR holds 16-bit address. Indirect
addressing is used for upper data memory area.
Memory address.
In the Indirect Addressing mode, a register is used to hold the effective address of the operand. This register,
which holds the address, is called the pointer register and is said to point to the operand. Only registers R0,
R1 and DPTR can be used as pointer registers. R0 and R1 registers can hold an 8-bit address whereas DPTR
can hold a 16-bit address. DPTR is useful in accessing operands which are in the external memory.
In immediate addressing mode the data is specified as part of the effective address itself. Data is either 8-bit
or 16-bit constant value. The destination register should hold same data size as specified by the source
operand.
Examples: ADD A, #050H; Add 8-bit value 50 to the contents of accumulator which is of
8-bit register.
MOV DPTR, #0FE00H; Move 16-bit data constant to 16-bit Data Pointer Register.
In the Immediate Constant Addressing mode, the source operand is an 8- or 16-bit constant value. This
constant is specified in the instruction itself (rather than in a register or a memory location). The destination
register should hold the same data size which is specified by the source operand.
This mode of addressing is used for jump instruction Short (SJMP) and conditional Jumps (JNZ).It transfers
the control from one part of the program to the other. Since 8-bit offset is used the destination address must
be within -128 and +127 bytes.
The Relative Addressing mode is used with some type of jump instructions like SJMP (short jump) and
conditional jumps like JNZ. This instruction transfers control from one part of a program to another.
Two instructions associated with this mode of addressing are ACALL and AJMP instructions
These are 2-byte instructions where the 11-bit absolute address is specified as the operand
The upper 5 bits of the 16-bit PC address are not modified. The lower 11 bits are loaded from this
instruction. So, the branch address must be within the current 2K byte page of program memory (211 = 2048).
64 K bytes program memory
Example:
ACALL PORT_INIT
In Absolute Addressing mode, the absolute address, to which the control is transferred, is specified
by a label. Two instructions associated with this mode of addressing are ACALL and AJMP instructions.
These are 2-byte instructions
This mode of addressing is used with the LCALL and LJMP instructions
It is a 3-byte instruction and the last 2 bytes specify a 16-bit destination location where the program
branches
The program will always branch to the same location no matter where the program was previously
Example:
Operand;
This mode of addressing is used with the LCALL and LJMP instructions. It is a 3-byte instruction and the
last 2 bytes specify a 16-bit destination location where the program branches to. It allows use of the full 64K
code space.
The Indexed addressing is useful when there is a need to retrieve data from a look-up table
A 16-bit register (data pointer) holds the base address and the accumulator holds an 8-bit displacement or
index value
The sum of these two registers forms the effective address for a JMP or MOVC instruction
Example:
MOVC A,@A+DPTR ; Gets target value from the table start address
After the execution of the above instructions, the program will branch to address 1F08H (1F00H+08H) and
transfer into the accumulator the data byte retrieved from that location (from the look-up table)
The Indexed addressing is useful when there is a need to retrieve data from a look-up table (LUT). A 16-bit
register (data pointer) holds the base address and the accumulator holds an 8-bit displacement or index
value. The sum of these two registers forms the effective address for a JMP or MOVC instruction.
9. Examples &contemporary extracts of articles/ practices to convey the idea of the session
Q3. The address register for storing the 16-bit addresses can only be
a)Stack Pointer
b) data pointer
c) instruction register
d) accumulator
Q4. The instruction, ADD A, R7 is an example of
a) register instruction
b) register specific instruction
c) indexed addressing
d) None of these
Q5. The Symbol ‘addr 16’represents the 16-bit address which is used by the instruction to specify the
a) destination address of CALL
b) source address of JUMP
c) destination address of CALL or JUMP
d) Source address of CALL or JUMP
Q6. The addressing mode that is used in unconditional branch instructions is
a. intrasegment direct and indirect addressing mode
b. intersegment direct addressing mode
c. intrasegment direct addressing mode
d. intrasegment indirect addressing mode
Q7. The instruction, ADD A, #100 performs
a) 100(decimal) is added to contents of address register
b) 100(decimal) is subtracted from the accumulator
c) 100(decimal) is added to contents of an accumulator
d) none
Q8. Which of the following addressing method does the instruction, MOV AX,[BX] represent?
a) register indirect addressing mode
b) direct addressing mode
c) register addressing mode
d) register relative addressing mode
Q9. What is the word length of an 8-bit microprocessor?
a) 8-bits – 64 bits
b) 4-bits – 32 bits
c) 8-bits – 16 bits
d) 8-bits – 32 bits
Q10 When data required for instruction is present inside the register of a microprocessor then which of the
following addressing mode is used?
a) Indexed
b) Register
c) Relative
d) Direct
Q11. Which of the following is a register-indirect addressing mode instruction set?
a) LDA 2700H
b) ADI 36H
c) DAA
d) LDAX B
Q12. The address register for storing the 16-bit addresses can only be
a) stack pointer
b) data pointer
c) instruction register
d) accumulator
Q13. The address register for storing the 8-bit addresses can be
a) R0 of the selected bank of register
b) R1 of the selected bank of register
c) Stack pointer
d) All of the mentioned
Q14. The instruction, ADD A, R7 is an example of
a) register instructions
b) register specific instructions
c) indexed addressing
d) none
Q15.Linear and random accessing of array elements are allowed in base indexed addressing
a)True
b)False
Q16.Direct addressing mode does not allow static and global variables.
a)True
b)false
Q17.What is the addressing mode specified in PUSH A operation
a)Register Indirect
b)Register
c)Direct
d)Immediate
Q18.In which addressing mode the address of the data is not defined in the given instruction
a)Indirect addressing mode
b)Direct addressing mode
c)Implicit addressing mode
d)Register addressing mode
Q19.Identify the type of addressing mode involved in the following instruction
MOV R1,#03H, MOV@DPTR,A,SWAP, MOV @A+PC
a) Register, Register Indirect,Implied, Indexed
b) Implied,Indexed,Register,Register Indirect
c) Register,Register Indirect,Indexed,Implied
d) Indexed,Register Indirect,Register,Implied
Q20. MOVC in 8051 indicates
a) Moves byte from code memory to accumulator
b) Moves data from register to memory
c) Copy byte between two registers
d) Copy data between two memory
11. Summary
8051 microcontroller uses addressing modes as register addressing mode, direct, indirect addressing mode,
immediate ,indexed and relative addressing mode for referring the address of the operand involved in the
machine instruction.8051 uses registers as A, DPTR, Register bank, internal memory RAM for storing and
retrieving the operand address.
12. Terminal Questions
Q1: What are the addressing modes supported by the 8051 microcontroller?
A1: The 8051 microcontroller supports several addressing modes, including immediate addressing, direct addressing,
indirect addressing, register addressing, and indexed addressing.
Digital Voltmeter:
Case Study: Develop a digital voltmeter using the 8051 microcontroller. Connect an analog-to-digital
converter (ADC) to the microcontroller and program it to convert the analog voltage input into a digital
value. Display the measured voltage on an LCD screen. This case study showcases how the 8051
microcontroller can be utilized in measurement and instrumentation applications.
15. Glossary
Von Neumann Architecture: A computer architecture in which program instructions and data share the same
memory space. The 8051 microcontroller follows the Von Neumann architecture for internal memory
organization.
Harvard Architecture: A computer architecture that uses separate memory spaces for program instructions
and data. The 8051 microcontroller uses a Harvard architecture for its external memory.
Program Memory: The memory space in the microcontroller where program instructions are stored. The
8051 microcontroller typically has up to 64 KB of program memory.
1. Mazidi & McKinley “The 8051 Micro controller and Embedded systems: using assembles andC,2nd
edition, 2007.
Reference Books :
Web Links
https://www.youtube.com/@ElectronicsforYoututorials
Classifications of Addressing Modes - YouTube