Addressing Modes
Addressing Modes
Addressing Modes
Addressing modes are techniques used by the CPU to identify the location of
the operand(s) needed for executing an instruction. They provide rules for
interpreting the address field in an instruction, helping the CPU fetch
operands correctly.
1. Immediate Addressing
In this mode the operand is specified in the instruction In other words, an
immediate-mode instruction has an operand field rather than an address field.
This instruction has an operand field rather than an address field. The operand
field contains the actual operand to be used in conjunction with the operation
specified in the
2
These
instructions are useful for initializing register to a constant value; For example MVI
B, 50H
In Immediate Mode, the operand is part of the instruction itself.. …The operand is
actual value to be used.
2. Direct Addressing
In this mode the effective address is equal to the address part of the instruction.
The operand resides in memory and its address is given directly by the address
field of the instruction.
In Direct Mode, the memory address of the operand is specified directly as part of
the instruction.
3
If the instruction is LDD 1 then the value stored at address 1 will sent to the
accumulator.
3. Indirect Addressing
In this mode the address field of the instruction gives the address where the
effective address is stored in memory.
Control unit fetches the instruction from the memory and uses its address part to
access memory again to read the effective address.
In Indi
r ect
Mode,
the
address that points to another memory location holding the effective address of
the operand.
The operand is the address of the address to be used. This is similar to direct, but
with one more hop in the process.
4.
Indexed Addressing
In this mode the content of an index register (XR) is added to the address part of
the instruction to obtain the effective address.
The index register is a special CPU register that contains an index value.
Note: If an index-type instruction does not include an address field in its format,
the instruction is automatically converted to the register indirect mode of
operation.
Indexed Mode works by adding a constant value to a register to get the effective
memory [Link] mode is typically used to index an array in memory, and it is
also useful in executing loops.
The operand plus the contents of the Index Register is the address of the value to
be used.
5. Relative Addressing
In this mode the content of the program counter (PC) is added to the address part
of the instruction in order to obtain the effective address.
The address part of the instruction is usually a signed number (either a +ve or a –
ve number).
When the number is added to the content of the program counter, the result
produces an effective address whose position in memory is relative to the address
of the next instruction.
Effective Address (EA) = PC + A
The operand is the offset from the current address of the value to be used.
6
So……
o Immediate: Operand is part of the instruction.
o Direct: Instruction contains the memory address of
the operand.
o Indirect: Instruction contains the address that holds
the effective address.
o Indexed: Address is calculated by adding an offset
to a base register.
o Relative: Address is relative to the current program
counter.