Lecture 15 - Addressing Modes
Lecture 15 - Addressing Modes
The availability of the addressing modes gives the experienced assembly language programmer
flexibility for writing programs that are more efficient with respect to the number of instructions
and execution time. To understand the various addressing modes to be presented in this section, it
is imperative that we understand the basic operation cycle of the computer. The control unit of a
computer is designed to go through an instruction cycle that is divided into three major phases:
There is one register in the computer called the program counter or PC that keeps track of the
instructions in the program stored in memory. PC holds the address of the instruction to be
executed next and is incremented each time an instruction is fetched from memory. The decoding
done in step 2 determines the operation to be performed, the addressing mode of the instruction,
and the location of the operands. The computer then executes the instruction and returns to step 1
to fetch the next instruction in sequence.
In some computers the addressing mode of the instruction is specified with a distinct binary code,
just like the operation code is specified. Other computers use a single binary code that designates
both the operation and the mode of the instruction. Instructions may be defined with a variety of
addressing modes, and sometimes, two or more addressing modes are combined in one instruction.
An example of an instruction format with a distinct addressing mode field is shown in Fig
Although most addressing modes modify the address field of the instruction, there are two modes
that need no address field at all. These are the implied and immediate modes.
2. Immediate Mode
In this mode the operand is specified in the instruction itself. In other words, an immediate-mode
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 instruction. Immediate-mode
instructions are useful for initializing registers to a constant value.
3. Register Mode
In this mode the operands are in registers that reside within the CPU. The particular register is
selected from a register field in the instruction. A k-bit field can specify any one of 2k registers.
The CPU register used in the computation may be the program counter, an index register, or a base
register. In either case we have a different addressing mode which is used for different application.
To clarify with an example, assume that the program counter contains the number 825 and the
address part of the instruction contains the number 24. The instruction at location 825 is read from
memory during the fetch phase and the program counter is then incremented by one to 826. The
effective address computation for the relative address mode is 826 + 24 = 850. This is 24 memory
locations forward from the address of the next instruction.