Store Instruction Property
The store (STORE) instruction copies the value at memory cell #src to memory cell #destination, where destination is the value in memory cell #addr + imm. More formally:
if the following are true:
- instruction #i is
store src=src addr=addr imm=imm
- the PC at time t = i
then value of cell ((value of cell addr at time t) + imm) at time (t + 1) = value of cell src at time t
A simple copy instruction would just copy the value in cell #src to cell #addr. But instead of using addr as the destination, this uses the value stored in cell #addr as the destination. You can also add a constant value to offset the destination address.
This is best illustrated by examples. Take a look at the following:
Memory Cells |
---|
Program Counter | Time |
---|---|
0 | 0 |
Initially, the PC is 0, so instruction #0 is executed. Instruction #0 is a STORE instruction. The source value is at memory cell #5, which is 9. Now let's look up the destination cell number. addr is 1, so look in cell #1, which is 3. Since imm is 0, it does not affect the destination. Thus, the destination cell number is 3 (not 1!).
Thus, computer will store 9 in memory cell #3. This example can be expressed as:
if the following are true:
- instruction #0 is
store src=5 addr=1 imm=0
- the PC at time 0 = 0
then value of cell ((value of cell 1 at time 0) + 0) at time (0 + 1) = value of cell 5 at time 0
Comments
Please log in to add comments