Curious
Curious

Reputation: 63

Query regarding addressing modes

What is the primary difference between index addressing mode and displacement mode? Both seem to be same as they both have offset and a base register and Effective address is calculated by adding contents of the register with the offset.

Upvotes: 0

Views: 67

Answers (1)

user555045
user555045

Reputation: 64904

In MIPS there are always two parts to an address, one is constant (16bit sign extended) and the other is a value from a register.

The difference between index mode and displacement mode is which of the parts is used for what: in index mode the constant part refers to the base of something and the register is an offset/index into the thing, while for displacement mode the register points to the base of something and the constant is an offset into the thing.

So this:

Both seem to be same as they both have offset and a base register and Effective address is calculated by adding contents of the register with the offset.

Is true. They are the same, and it's also the same as the indirect and absolute modes which are just syntactic constructs: there are still two parts in the address calculation, but the register can be $0 or the constant can be 0 and the assembler allows you to omit that part (some primitive assemblers actually don't support that). It's just about using the two parts of the final address differently. There is really no restriction (apart from the constant being somewhat narrow) so it can be even wilder, with both parts having no "nice" meaning individually but still summing to the address you want.

Upvotes: 1

Related Questions