Proof: LOAD Instruction Example 2
Let's prove the following theorem:
if the following are true:
- instruction #0 is
load dst=5 addr=1 imm=0
- the PC at time 0 = 0
- value of cell 1 at time 0 = 3
- value of cell 3 at time 0 = 9
then value of cell 5 at time 1 = 9
The following example shows that when a LOAD instruction with dst = 5, addr = 1, and imm = 0 is executed, the computer looks up memory cell #1 and finds 3, then copies the value memory cell #3 (9) to memory cell #5. imm is 0 so the source address is unchanged.
Instructions
Memory Cells |
---|
Program Counter | Time |
---|---|
0 | 0 |
LW Computer Simulator
Proof:
Given
1 | instruction #0 is load dst=5 addr=1 imm=0 |
---|---|
2 | the PC at time 0 = 0 |
3 | value of cell 1 at time 0 = 3 |
4 | value of cell 3 at time 0 = 9 |
# | Claim | Reason |
---|---|---|
1 | value of cell 5 at time (0 + 1) = value of cell ((value of cell 1 at time 0) + 0) at time 0 | if instruction #0 is load dst=5 addr=1 imm=0 and 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) + 0) at time 0 |
2 | (value of cell 1 at time 0) + 0 = 3 + 0 | if value of cell 1 at time 0 = 3, then (value of cell 1 at time 0) + 0 = 3 + 0 |
3 | 3 + 0 = 3 | 3 + 0 = 3 |
4 | (value of cell 1 at time 0) + 0 = 3 | if (value of cell 1 at time 0) + 0 = 3 + 0 and 3 + 0 = 3, then (value of cell 1 at time 0) + 0 = 3 |
5 | value of cell ((value of cell 1 at time 0) + 0) at time 0 = value of cell 3 at time 0 | if (value of cell 1 at time 0) + 0 = 3, then value of cell ((value of cell 1 at time 0) + 0) at time 0 = value of cell 3 at time 0 |
6 | value of cell ((value of cell 1 at time 0) + 0) at time 0 = 9 | if value of cell ((value of cell 1 at time 0) + 0) at time 0 = value of cell 3 at time 0 and value of cell 3 at time 0 = 9, then value of cell ((value of cell 1 at time 0) + 0) at time 0 = 9 |
7 | value of cell 5 at time (0 + 1) = 9 | if value of cell 5 at time (0 + 1) = value of cell ((value of cell 1 at time 0) + 0) at time 0 and value of cell ((value of cell 1 at time 0) + 0) at time 0 = 9, then value of cell 5 at time (0 + 1) = 9 |
8 | 0 + 1 = 1 | 0 + 1 = 1 |
9 | value of cell 5 at time (0 + 1) = value of cell 5 at time 1 | if 0 + 1 = 1, then value of cell 5 at time (0 + 1) = value of cell 5 at time 1 |
10 | value of cell 5 at time 1 = 9 | if value of cell 5 at time (0 + 1) = value of cell 5 at time 1 and value of cell 5 at time (0 + 1) = 9, then value of cell 5 at time 1 = 9 |
Comments
Please log in to add comments