2019 20 3a

Computer Organization and Architecture2019-2010 marksProcessor organization, general registers organization, stac

Describe in detail the different kinds of addressing modes with an example.

Describe in detail the different kinds of addressing modes with an example.

Quick answer

The addressing mode tells the CPU how to find the operand of an instruction from the address field. An instruction has an opcode and an address field. The mode decides whether the address field itself is the operand, or a memory address, or a register number. The final address of the operand in memory is called the effective address (EA).

Main addressing modes

In the implied mode, the operand is fixed by the opcode. For example, "complement accumulator" works on AC without any address field. Stack instructions such as ADD also use this mode.

In the immediate mode, the address field contains the operand itself. No memory access is needed to get it, so it is fast. It is used for constants. For example, ADD #5 adds the number 5.

In the register mode, the operand is inside a CPU register named in the instruction. For example, ADD R1 uses the value in R1. It is very fast and needs few bits.

In the register indirect mode, the register holds the memory address of the operand. So $EA = (R1)$. This is useful for pointers.

In the autoincrement or autodecrement mode, the register works as in register indirect, but its value is increased (or decreased) automatically after (or before) the access. It is used to walk through an array.

In the direct mode, the address field is the effective address. So $EA = A$. One memory access reaches the operand.

In the indirect mode, the address field gives the location where the real address is stored. So $EA = M[A]$. It needs two memory accesses and allows pointers.

In the relative mode, the address field is added to the program counter. So $EA = PC + A$. It is used for branches and makes code position independent.

In the indexed mode, the address field is added to an index register. So $EA = A + (XR)$. It is used to access array elements.

In the base register mode, a base register holds the starting address of a block, and the address field is an offset from it. So $EA = (BR) + A$. It is used to move programs in memory.

Example

Take an instruction at address 200 whose address field (at 201) is 500. Let $R1 = 400$ and $XR = 100$. The PC has already moved to 202 after fetching.

ModeEffective addressCalculation
Direct500A
Register indirect400(R1)
Relative702202 + 500
Indexed600500 + 100
Immediatenoneoperand is 500
Registernoneoperand is in R1

The table shows that the same address field gives different operands in different modes. Modes make a program shorter, more flexible and easier to relocate, at the cost of more complex hardware and extra memory accesses for some modes.

Short on time? The 1, 5 and 10 mark versions of this answer, flashcards and practice sets come with a program pass.

Up nextDiscuss stack Organization. Explain the following in details- (i) Register stack (ii) Memo