626 views
0 votes
0 votes
(a)difference between register and direct addressing mode(2) register indirect and simply indirect addressing

1 Answer

1 votes
1 votes

Register Addressing

In this addressing mode, a register contains the operand. Depending upon the instruction, the register may be the first operand, the second operand or both.

For example,

MOV DX, TAX_RATE   ; Register in first operand
MOV COUNT, CX	   ; Register in second operand
MOV EAX, EBX	   ; Both the operands are in registers

As processing data between registers does not involve memory, it provides fastest processing of data.

Direct Memory Addressing

When operands are specified in memory addressing mode, direct access to main memory, usually to the data segment, is required. This way of addressing results in slower processing of data. To locate the exact location of data in memory, we need the segment start address, which is typically found in the DS register and an offset value. This offset value is also called effective address

 

Indirect Memory Addressing

This addressing mode utilizes the computer's ability of Segment:Offsetaddressing. Generally, the base registers EBX, EBP (or BX, BP) and the index registers (DI, SI), coded within square brackets for memory references, are used for this purpose.

Indirect addressing is generally used for variables containing several elements like, arrays. Starting address of the array is stored in, say, the EBX register.

Register-Indirect Addressing

Register-Indirect addressing is perhaps the simplest of ARM's addressing modes.

Register-indirect addressing in action

To load a value from memory into a register using register-indirect addressing, we use a second register, known as the base register. This base register holds the actual memory address that the program is interested in. The LDR instruction inspects the base register, interprets its value as the memory address, fetches the value stored at that memory location, and then loads it into a destination register.

LDR r0, [r1] ; r0 receives the value held at the memory address pointed to by r1
    ; r0 is the destination register, r1 is the base register

To store a value to memory from a register using register-indirect addressing, a base register is again employed to hold the actual memory address. The STR instruction inspects the base register, interprets its value as a memory address location, and places the value held in the source register into the memory location.

STR r0, [r1] ; the memory location pointed to by r1 receives the value held in r0
    ; r0 is the source register, r1 is the base register