- Asked 4/19
- 2071 Magh · 4 marks
- 2072 Magh · 4 marks
- 2075 Baisakh · 4 marks
- 2079 Asoj · 4 marks
Addressing modes of 8051
Short answer
The 8051 uses five data addressing modes: immediate (#data), register (R0-R7, A), direct (RAM/SFR address), register indirect (@R0/@R1, @DPTR for MOVX), and indexed (MOVC with A+DPTR or A+PC). It also supports bit addressing on bit-addressable RAM and SFRs.
Explain the addressing modes used in 8051 microcontroller (with example).
The addressing mode tells the CPU where the operand of an instruction is. The 8051 has five addressing modes for data, plus bit addressing.
| Mode | Operand is | Example | Meaning |
|---|---|---|---|
| Immediate | a constant in the instruction, marked with # | MOV A,#25H | A = 25H |
| Register | in a register R0-R7 of the active bank (or A, B) | MOV A,R3 | A = R3 |
| Direct | at an 8-bit internal RAM or SFR address | MOV A,30H; MOV P1,A | A = RAM[30H]; P1 = A |
| Register indirect | at the RAM address held in R0 or R1 | MOV A,@R0 | A = RAM[R0] |
| Indexed | in code memory at base + offset | MOVC A,@A+DPTR | A = ROM[DPTR + A] |
Details
- Immediate: the data is part of the instruction, e.g.
MOV R2,#10andMOV DPTR,#4000H(16-bit). Used to load constants. - Register: short and fast (one byte).
ADD A,R5adds R5 to A. The bank is chosen by bits RS1:RS0 in the PSW. - Direct: the address is in the instruction, e.g.
MOV 40H,#5orMOV A,P1(P1 is the SFR at 90H). This is the only way to reach the SFRs. - Register indirect: the register works as a pointer; with
INC R0the same code walks through an array. External RAM usesMOVX A,@DPTRorMOVX A,@R0. Only R0 and R1 (and DPTR for MOVX) can be pointers. - Indexed: used for look-up tables in ROM:
MOVC A,@A+DPTRorMOVC A,@A+PC; alsoJMP @A+DPTR. - Bit addressing:
SETB P1.0,CLR CandJB P2.1,LABELoperate on single bits of the bit-addressable RAM (20H-2FH) and SFRs.
Example (look-up table):
MOV DPTR,#TABLE
MOV A,#3
MOVC A,@A+DPTR ; A = 9 (4th table entry, index 3)
HERE: SJMP HERE ; stop, so the table is not executed as code
TABLE: DB 0,1,4,9,16
✓ Answer checked by Claude Opus 5.5 (high effort)
Related questions
- Microprocessor vs microcontroller; 8051 addressing · Embedded System, chapter 9
- Microcontroller vs microprocessor; 8051 features · Embedded System, chapter 9 · asked 2×
- Why 8051 / its operational features · Embedded System, chapter 9 · asked 2×
- Addressing modes in given instructions · Computer Organization and Architecture, chapter 2
- Addressing modes with examples · Computer Organization and Architecture, chapter 2 · asked 10×
- Instruction and data format, addressing modes · Microprocessor, chapter 2 · asked 2×
- Addressing modes of 8086 · Microprocessor, chapter 3 · asked 2×