LOAD Instruction Property
The load (LOAD) instruction copies the value at memory cell #source to memory cell #dst, where source is
(value in memory cell #addr) + imm
More formally:
if the following are true:
- instruction #i is
load dst=dst addr=addr imm=imm
- the PC at time t = i
then value of cell dst at time (t + 1) = value of cell ((value of cell addr at time t) + imm) at time t
A simple copy instruction would just copy the value in cell #addr to cell #dst. But instead of using addr as the source, this uses the value stored in cell #addr as the source. You can also add a constant value to offset the source address.
Here is an example:
Memory Cells |
---|
Program Counter | Time |
---|---|
0 | 0 |
Initially, the PC is 0, so instruction #0 is executed. Instruction #0 is a LOAD instruction. The destination is memory cell #5. Now lets compute the source cell number. addr is 1, so first look in cell #1, which contains 3. Then add the imm, which is 1.
3 + 1 = 4
Thus, the source is cell #4, which is 9. 9 is copied to the destination, which is cell #5. This example can be expressed as:
if the following are true:
- instruction #0 is
load dst=5 addr=1 imm=1
- the PC at time 0 = 0
then value of cell 5 at time (0 + 1) = value of cell ((value of cell 1 at time 0) + 1) at time 0
Comments
Please log in to add comments