Song Liu

# Different Memory Addressing ( Examples by LOAD )

## Immediate Operand

The simplest way for an instruction to specify an operand is for the address part of the instruction actually to contain the sperand itself rather than an address or other information describing where the operand is. Such an operand is called an immediate operand because it is automatically fetched from memory at the same time the instruction itself is fetched. It is immediately available for use.
```Ex:   LOAD R1, =100	Load the number 100 to register R1.
```

Direct addressing is a scheme in which the address specifies which memory word or register contains the operand.

For example:

```1) LOAD R1, 100	  Load the content of memory address 100 to register R1.

2) LOAD R1, R2	  Load the content of register R2 to register R1.
```

Indirect addressing is a scheme in which the address specifies which memory word or register contains not the operand but the address of the operand.
```
For example:

1) LOAD R1, @100	Load the content of memory address stored at memory
address 100 to the register R1.

R1	M[100]		M[200]

-	200		10
LOAD R1,@100		10	200		10

2) LOAD R1, @R2		Load the content of the memory address stored at

register R2 to register R1.
```

Addresses have two parts: the number of an index register and a constant. The address of the operand is the sum of the constant and the contents of the index register. It contains indexed (direct) addressing, indexed immediate addressing and indexed indirect addressing.
```For example:

1) LOAD R1, 100(R2)	Load the content of the memory address which is
the sum of 100 and the content of register R2 to
register R1.

R1	R2	M[100]	M[110]

-	10	200	150
LOAD R1, 100(R2)	150	10	200	150

2) LOAD R1, =100(R2)	Load the sum of 100 and the value of register R2
to register R1.

3) LOAD R1, @100(R2)	Load the content of the memory address stored at
the memory address which is the sum of 100 and
the number in register R2 to the register R1.

R1	R2	M[100]	M[110]	M[150]

-	10	200	150	300
LOAD R1, @100(R2)	300	10	200	150	300

```