Javatpoint Logo
Javatpoint Logo

Difference between Memory-based and Register-based addressing modes

To learn the memory-based addressing mode and register-based addressing mode, we have to first learn about the addressing mode. After that, we will be able to understand the memory-based addressing mode and register-based addressing modes easily. The addressing mode is described as follows:

Addressing modes:

The addressing modes can be described as the field of operation, which can be used to specify various operations which we want to perform. With the help of some data, the operations will be executed. In the addressing mode, the memory or computer registers are used to store the data. On the basis of the addressing mode instruction, the way of choosing operands at the time of program execution is decided. The address field of instruction is modified or interpreted by the rule specified by the addressing mode before an operand is actually referenced.

In other terms, the addressing mode can be described as a mechanism used to specify the operands. The operands are defined as the reference of a given memory location or as a part of instruction. The value of the operand or address of the operand can be defined as the information contained in the instruction code. On the basis of the type of CPU organization, the addressing mode is very much dependent. The CPU organization is basically of three types, which are described as follows:

  • Single Accumulator Organization: The accumulator register is implicitly used in CPU organization to process all instructions of a program. The result of these instructions will be stored in the accumulator.
  • Stack Organization: The stack is a type of storage structure used to store the information in such a way that the item we stored in last will be the first item to retrieve. On the basis of LIFO, the stack organization is dependent. In most of the CPU, LIFO is known as the most popular access method.
  • General Register Organization: The general-purpose organization can be described as an organization where we use multiple general-purpose registers in the CPU organization in place of the single accumulator register. In this organization, the instruction format is represented with the help of only two or three address fields.

There are mainly two purposes of addressing mode. These purposes are also known as the advantages of addressing modes, which are described as follows:

  • The addressing mode provides various types of facilities to their users to provide them the programming versatility. These facilities are program relocation, pointers to memory, indexing of data, and counter for loop control.
  • In the addressing field of instruction, the number of bits can be reduced with the help of addressing mode.

For example, a machine needs to know how to get operands so that it can perform the task with the help of the operands. There is a word known as the effective address, which is used to define the address of an operand stored in the memory. We can obtain or define the effective address of these types of operands directly from the register with the help of a lot of methods. These types of approaches or methods are called 'modes of addressing'.

In the high-level language, the programmer can easily describe the variables and operations which will be performed on the variables. That's why, with the help of high-level language, the programmer usually writes the code. Later, low-level instruction is used to produce the computer code. The opcode and operands are contained by the low-level instructions. There is no operation or anything which can be performed by the addressing mode on the opcode option. The addressing modes only focus on presenting the address of opcode, which is present in the instruction.

Memory-based addressing mode

When the data is in memory, we are able to only access the data with the help of memory addressing mode. The EA (effective address) is always the memory address. In the operation code, the saved information is always the result or operand value. Here, the microprocessor is able to implement a specific task with the help of implementing the sequence of instructions saved in the memory.

In the register-based addressing mode, the operand will be saved in the register, and the CPU (central processing unit) is contained this register. With the help of registers, we will access the information, which will be processed within the register. In this mode, the register's address where the operand is stored will be contained by the instructions. The register-based addressing mode contains different types of base addresses. That's why the target segment base address will be held with the help of a base register.

The difference between memory-based addressing mode and register-based addressing mode is described as follows:

Memory-based Addressing Mode Register-based Addressing Mode
In this mode, the static variables will be accessed. The value of an operand is usually contained by the memory in the memory-based addressing mode. With the help of instruction itself, the address of an operand will be given. The memory-based addressing mode has the ability that it can properly use the memory address advantage. Single memory reference is needed in this mode. This type of mode is referred to as the direct addressing mode. The value of an operand is usually contained by the register in the register-based addressing mode. With the help of instruction, the register number is provided. The operand can be fetched with the help of the register number, which is present in the instruction. This mode is known as the Register mode.
In this mode, the pointers are implemented. With the help of memory, the effective address is stored in this mode. With the help of memory address which is specified in the instruction, will provide the address of EA. This mode requires two references in which the first one is used to get the effective address, and the second one is used to read or write the data. This mode is referred to as the Indirect addressing mode. The operand's address is contained by the register. The content of the register, which is given in instruction, will be delivered to the effective address. With the help of this mode, we are able to use the full advantages of registers. This mode is referred to as the Register Indirect mode.
The EA (effective address) can be obtained with the help of adding the address part of instruction and the content of a base register. There is always an assumption that the base register contains the base address, and the displacement relative to the base address is given by the address field of the instruction. This mode is referred to as the Addressing Mode, Base Register. Suppose we contain a table with a lot of data. If we want to one by one access all the values, in this case, we need any register that contains a base address or something that decrement the program counter. In this case, the register is decreased. That's why this mode is a register-based addressing mode. This mode is known as the auto decrement mode.
In this mode, the array will be implemented. In the form of sequential cells, the array elements will be stored in memory. In this mode, the index can be referred the elements of an array. The effective address can be obtained with the help of adding content of the index register into the address part of instruction. With the help of index mode, we can access an array that contains its elements in the successive memory locations. This mode requires the two parameters to access the array elements, i.e., base address and index. Here, the base address is the first element, which is able to store the address of an array. The index is the second element used to say the position of an array element. This mode is referred to as the Indexed addressing mode. Suppose we contain a table with a lot of data. If we want to one by one access all the values, in this case, we need any register that contains a base address or something that increment the program counter. In this case, the register is increased. This mode is referred to as the Auto-increment mode.
The effective address can be obtained with the help of adding content of the program counter into the address part of instruction. In this case, this address part usually shows a sign number that is either negative or positive. This mode is referred to as the Relative addressing mode. The register-based addressing mode is used to access the constant. The constant value is initialized to the registers with the help of instructions. With the help of address field of instruction, the data is saved in this mode. That's why the effective address does not need to access the data in this mode. We can use this mode in the form of source, but we can never use it in the form of destination because there is no storage capacity in the constant, and destination always needs storage space. This type of technique is very useful in our code or program. This mode is referred to as the Immediate addressing mode.






Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA