←Back to Subject
Notes
Notes
Study material and explanations
Diagrams
Diagrams
Visualize concepts easily
Mnemonics
Mnemonics
Tricks to remember faster
One Night Prep
One Night Prep
Short and focused revision
Revision
Revision
Quick summary and key points
Important Questions
Important Questions
Practice most relevant questions
Notes

Addressing Modes, Instruction Formats & Panini's Grammar

Study material and explanations for Unit 3

Addressing Modes, Instruction Formats, and Formal Instruction Design

What is an Addressing Mode? (In Simple Words)

When the CPU executes an instruction like ADD, it needs to know: Where is the number to be added?

  • Is the number written directly inside the instruction?
  • Is it sitting inside a fast CPU register like R₁?
  • Is it saved in RAM memory?
  • Is it an item inside a large C-language array?

The way the CPU calculates the actual memory location of the data (called the Effective Address - EA) is known as an Addressing Mode.


1. Primary Addressing Modes

Common Addressing Modes and Effective Address (EA)
Immediate Mode
Operand = Value inside instruction
Data is right there (e.g. ADD #25)
Direct Mode
EA = Address
Instruction gives the exact RAM address (e.g. LDA 2000)
Indirect Mode
EA = M[Address]
Instruction points to a memory pointer that holds the real address
Register Mode
Operand = Register
Data is stored inside a fast CPU register (R₁)

Detailed Breakdown of Modes:

1. Implied (Implicit) Mode

  • No address is needed! The opcode itself tells what to do.
  • Example: CMA (Complement Accumulator) or CLC (Clear Carry).

2. Immediate Mode

  • The actual number is written right inside the instruction.
  • Example: ADD 5 (Adds the constant 5 directly to the Accumulator).
  • Advantage: Super fast because the CPU does not need to search RAM memory.

3. Register Mode

  • The number is kept inside an internal CPU register.
  • Example: ADD R1 (Adds contents of register R₁ to Accumulator).
  • Advantage: Very fast; accessing CPU registers takes under a nanosecond.

4. Register Indirect Mode

  • The instruction names a register, but that register doesn’t hold data—it holds the RAM address of the data!
  • Formula: EA = [R]
  • Example: MOV A, @R1 (Fetch data from the RAM address saved inside R₁).

5. Direct Addressing Mode (Absolute)

  • The instruction gives the exact RAM address of the operand.
  • Formula: EA = Address
  • Example: LDA 4500 (Loads the data stored at RAM memory address 4500 into AC).

6. Indirect Addressing Mode

  • The address in the instruction points to a memory box that stores another address where the real data lives!
  • Formula: EA = M[Address]
  • Use: Used in programming for pointers and passing parameters by reference.

Offset & Indexing Modes (Displacement Modes)

7. Relative Addressing Mode (PC-Relative)

  • The address field contains an offset number that is added to the Program Counter (PC).
  • Formula: EA = PC + Address Offset
  • Use: Used for if-else jumps and loops (JMP +10). It allows programs to run from any part of RAM (code relocation).

8. Indexed Addressing Mode

  • An Index Register (XR) value is added to a base address.
  • Formula: EA = XR + Address Offset
  • Use: Perfect for scanning through Arrays in C or Java loops (e.g., arr[i]).

9. Base Register Addressing Mode

  • A Base Register (BR) holds a starting address, added to an offset.
  • Formula: EA = BR + Offset
  • Use: Used by the Operating System (Windows/Linux) when loading programs into different sections of memory.

2. Indian Heritage: Pāṇini’s Formal Rules and Computer Instruction Sets

In the DAVV BCA syllabus, students study how ancient Indian grammar parallels modern computer architecture:

💡 Cultural & Technical Connection:
Around 2,500 years ago in ancient India, the scholar Pāṇini composed the Aṣṭādhyāyī.
It contained 3,959 formal rules (sūtras) that systematically generated every correct word in Sanskrit.

World-renowned computer scientists (like Donald Knuth) consider Pāṇini’s work to be the world’s first formal rule-based grammar system—predating Backus-Naur Form (BNF) by thousands of years!

Direct Parallels to Computer Instructions:

  1. Opcodes and Operands: Pāṇini defined base root words (dhātus) transformed by strict modifier rules (anubandhas). Similarly, CPU instruction sets define base opcodes modified by addressing mode bits.
  2. Rule Priority (Metarules): When two grammar rules clashed, Pāṇini used strict priority rules (later rule takes precedence). Modern CPU instruction decoders use identical logic rules to resolve conflicting control signals!

💡 DAVV Exam Preparation Tips

5-Mark Question: “Differentiate between Direct, Indirect, and Immediate addressing modes with numerical examples.”

  • Define Effective Address (EA).
  • Draw a simple memory diagram showing:
    • Immediate: Operand is inside the instruction (ADD 5).
    • Direct: Instruction points straight to operand address (LDA 2000).
    • Indirect: Instruction points to a memory pointer that holds the real address.

10-Mark Question: “What is an addressing mode? Explain any six addressing modes with formulas, diagrams, and practical programming use-cases.”

  • Cover: Immediate, Direct, Indirect, Register Indirect, Relative, and Indexed modes.
  • Write down the EA formula for each:
    • Direct: EA = Address
    • Indirect: EA = M[Address]
    • Relative: EA = PC + Offset
    • Indexed: EA = XR + Offset
  • Explain why Indexed addressing is used for arrays, and Relative addressing for loop jumps.