Back to the 2022 paper

Module 3: Instruction Set and Programming

20227m

Explain the indexed addressing and relative addressing in 8051 micro-controller.

Worked SolutionAI Assisted

Indexed & Relative Addressing in 8051

1. Indexed Addressing: EA = Base + Index. Base is DPTR or PC, index is Accumulator. Instructions: MOVC A,@A+DPTR and MOVC A,@A+PC. Used for table look-up, e.g., fetch byte from code memory table whose base address in DPTR plus offset in A. Example:

MOV DPTR,#TABLE
MOV A,R2 ; offset 2
MOVC A,@A+DPTR ; A = TABLE[2]
TABLE: DB 10H,20H,30H

Also MOVX with DPTR indirect is variant.

2. Relative Addressing: EA = PC + signed 8-bit offset (2's complement, -128 to +127). Used by jumps: SJMP rel, JC/JNC/JZ/JNZ/DJNZ/CJNE rel. Offset relative to next instruction's first byte. Example: SJMP LOOP assembles to -X offset. Allows relocatable code and short jumps within 256-byte range.

Similar questions

Official AppAndroid App

PYQDeck for Android

Solve BEU previous-year exam papers anywhere, anytime. Fast search, offline paper viewing, and step-by-step solutions designed specifically for your phone.