Difference between Memory based and Register based Addressing Modes
Prerequisite – Addressing Modes
Addressing modes are the operations field specifies the operations which need to be performed. The operation must be executed on some data which is already stored in computer registers or in the memory. The way of choosing operands during program execution is dependent on addressing modes of instruction. “The addressing mode specifies a rule for interpreting or modifying the address field of the instruction before the operand is actually referenced. “Basically how we are interpreting the operand which is given in the instruction is known as addressing mode.
Addressing mode very much depends on the type of CPU organization. There are three types of CPU organization:
- Single Accumulator organization
- General register organization
- Stack organization
Addressing modes is used for one or both of the purposes. These can also be said as the advantages of using addressing mode:
- To give programming versatility to the user by providing such facilities as pointers to memory, counter for loop control, indexing of data, and program relocation.
- To reduce the number of bits in the addressing field of the instruction.
There is a number of addressing modes available and it depends on the architecture and CPU organization which of the addressing modes can be applied.
Difference between Memory based and Register based Addressing Modes:
|Memory Based Addressing Modes||Register Based Addressing Modes|
|The operand is present in memory and its address is given in the instruction itself. This addressing mode is taking proper advantage of a memory address, e.g., Direct addressing mode||An operand will be given in one of the registers and the register’s number will be provided in the instruction. With the register number present in instruction, an operand is fetched, e.g., Register mode |
|The memory address specified in the instruction may give the address where the effective address is stored in the memory. In this case, an effective memory address is present in the memory address which is specified in the instruction, e.g., Indirect Addressing Mode||The register contains the address of the operand. The effective address can be derived from the content of the register specified in the instruction. The content of the register might not be the effective address. This mode takes full advantage of registers, e.g., Register indirect mode |
|The content of the base register is added to the address part of the instruction to obtain the effective address. A base register is assumed to hold a base address and the address field of the instruction gives displacement relative to the base address, e.g., Base Register Addressing Mode.||If we are having a table of data and our program needs to access all the values one by one we need something which decrements the program counter/or any register which has a base address. Though in this case register is basically decreased, it is register-based addressing mode, e.g., In Auto decrements mode.|
|The content of the index register is added to the address part that is given in the instruction to obtain the effective address. Index Mode is used to access an array whose elements are in successive memory locations, e.g., Indexed Addressing Mode||If we are having a table of data and our program needs to access all the values one by one we need something which increments the program counter/or any register which has a base address, e.g., Autoincrement mode|
|The content of the program counter is added to the address part of the instruction in order to obtain the effective address. The address part of the instruction, in this case, is usually a signed number that can be either positive or negative, e.g., Relative addressing mode||Instructions generally used for initializing registers to a constant value are register-based addressing mode, and this technique is a very useful approach, e.g., Immediate mode. |
Memory-based addressing modes are mostly relying on Memory address and content present at some memory location. Register-based addressing modes are mostly relying on registers and content present at some register whether it is data or some memory address.