Monday, December 2, 2013

Define addressing mode. Classify different types of addressing mode.

Addressing Mode

The addressing mode specifies a rule for interpreting or modifying the address field of the instruction before the operand is actually referenced. Computers use addressing mode techniques for the purpose of accommodating one or both of the following provision:
a.    Togive programming versatility to the user by providing such facilities as pointers to memory, counter for ioop control, indexing of data, and program relocation.
b.    To reduce the number of bits in the addressing field of the instruction.
There are following addressing modes given below:
1.    Immediate Addressing mode : In this mode the operand is specified in the instruction itself. In other words, an immediate mode instruction has an operand field rather an address field. The operand field contain the actual operand to be used in conjunction with operations-specified in instruction. Immediate mode instructions are useful for initialising registers to a constant value.
2.    Register mode: In this mode, the operands are in registers that reside within the CPU. The particular register is selected from register field in instruction. A k-bit field can specify any one of 2k register.
3.    Register indirect mode : In this mode the instruction specifies a register in the CPU whose contents give the address of the operand in memory. In other words, the selected register contains the address of operand rather than operand itself. Before using a register indirect mode instruction, the programmer must ensure that the memory address of the operand is placed in processor register with a previous instruction.
4.    Auto increment or Auto decrement mode : This is similar to register indirect mode except the register is incremented or decremented after (or before) its value is used to access memory. When the address stored in register refer to a table of data in memory, it is necessary to increment or decrement the register after every access to the table. This can be achieved by using the increment to decrement instruction.
5.    Direct address mode: 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 instruction. In a branch type instruction the address field specifies the actual branch address. The effective address in these modes is obtained from the following computation: 
Effective address= address part of instruction + content of CPU register.
6.    Relative address mode: In this mode, the content of program counter is added of address part of the instruction in order to obtain the effective address. The address part of instruction is usually a signed number which can be either positive or negative. When this number is added to the content of program counter, the result produces an effective address whose position in memory is relative to the address of the next instruction.
7.    Indexed addressing mode: In this mode, the content of an index register is added to the address part of the instruction to obtain the effective address. The index register is special CPU register that contain an index value. The address field of instruction defines the beginning address of a data array in memory. Each operand in array is stored in memory relative to the beginning address. The distance between the beginning address and the address of the operand is the index value stored in the index register.
8.    Base register addressing mode : In this mode, the content of a base register is added to address part of instruction to obtain the effective address. This is similar to the indexed addressing mode except that the register is now called a base register instead of an index register.

No comments:

Post a Comment