0
589views
Describe addressing modes of MSP430 or ARM7TDMI.
1 Answer
0
2views

Addressing Modes for Data Processing Operands (i.e. op1)

There are two method for addressing these operands :

1. Unmodified value

In this addressing mode, the register or a value is given unmodified i.e. without any shift or rotation.

Examples:

MOV R0, # 1234 H

This instruction will move the immediate constant value (1234)10 into register R0.

MOV R0, R1

This instruction will move the value in the register R1 into the register R0

2. Modified value

In this addressing mode, the given value or register is shifted or rotated. These are different shift and rotate operations possible as listed below with examples.

(i) Logical shift left

This will take the value of a register and shift the value towards most significant bits, by n bits.

Example:

MOV R0, R1, LSL # 2

After the execution of this instruction R0 will become the value of R1 shifted by 2 bits.

(ii) Logical shift right

This will take the value of a register and shift the value towards right by n bits.

Example:

MOV R0, R1, LSR R2

After the execution of this instruction R0 will have the value of R1 shifted right by R2 times. R1 and R2 are not altered.

(iii) Arithmetic shift right

This is similar to logical shift right, except that the MSB is retained as well as shifted for arithmetic shift operation .

Example:

MOV R0, R1, ASR #2

After the execution of this instruction R0 will have the value of R1 Arithmetic shifted right by 2 bits.

(iv) Rotate right

This will take the value of a register and  rotate it right by n bits

Example:

MOV R0, R1, ROR R2

After the execution of this  instruction R0 will have the value of R1 rotated right for R2 times.

(v) Rotate right extended

This is similar to Rotate right by one bit, with the carry flag moved into the MSB, i.e. it is similar to rotate right through carry

Example:

MOV R0, R1 RRX

After the execution of this instruction R0 will have the value of register R1 rotated right through carry by 1 bit

Addressing Modes for Memory Access Operands

Load and store instructions are used to access memory. The different memory access addressing modes are

  1. Register indirect addressing mode
  2. Relative register indirect addressing mode
  3. Base indexed indirect addressing mode
  4. Base with scale register addressing mode.

Each of these addressing modes have offset addressing, pre-index addressing and post-index addressing as explained in the examples for each addressing mode

(i) Register indirect addressing mode

In this addressing mode, a register is used to give the address of the memory location to be accessed.

Example:

LDR R0, [R1]

This instruction will load the register R0 with the 32-bit word at the memory address held in the register R1

(ii) Relative register indirect addressing mode

In this addressing mode the memory address is generated by an immediate value added to a register. Pre index and post index are supported in this addressing mode.

Examples:

a) LDR R0, [R1, #4]

This instruction will load the register R0 with the word at the memory address calculated by adding the constant value 4 to the memory address contained in the R1 register

b) LDR R0, [R1, #4]!

This is a pre-index addressing. This instruction is same as that in e. g. (a) this instruction also places the new address in  R1 i.e. R1 ¬ R1 + 4.

c) LDR, [R1], #4

This is post-index addressing. This instruction will load register R0 with the word at memory address given in register R1. It will then calculate the new address by adding 4 to R1 and place this new address in R1

(iii) Base indexed indirect addressing mode

In this addressing mode the memory address is generated by adding the values of two registers.

Pre-index and post-index are supported also in this addressing mode.

Examples:

a) LDR R0, [R1, R2]

This instruction will load the register R0 with the word at memory address calculated by adding register R1 to register R2.

b) LDR R0, [R1, R2]!

This is pre-index addressing. This instruction is same as that in example (a). This instruction also places the new address in R1 i. e. R1 ¬ R1 + R2.

c) LDR R0, [R1], R2

This is a post-index addressing. This instruction will load register R0 with the word at memory address given in register R1. It will then calculate the new address by adding the value in register R2 to register R1 and place this new address in R1.

(iv) Base with scaled register addressing mode

In this addressing mode the memory address is generated by a register value added to another register shifted left. Pre-index and post-index are supported in this addressing mode.

Examples:

a) LDR R0, [R1, R2, LSL #2]

This instruction will load the register R0 with the word at the memory address calculated by adding register R1with register R2 shifted left by 2 bits.

b) LDR R0,[R1, R2, LSL #2]!

This is pre-indexed addressing. This instruction will load the register R0 with the word at the memory address calculated by adding register R1 with register R2 shifted left by 2 bits. The new address is placed in register R1 i. e. R1 ¬ R1 + R2 << 2.

c) LDR R0, [R1], R2, LSL #2.

This is a post-indexed addressing. This instruction will load the register R0 with the word at memory address contained in register R1. It will then calculate the new address by adding register R1 with register R2 shifted left by two bits. The new address is placed in register R1.

Please log in to add an answer.