Proof: BEQ Instruction Example
Let's prove the following theorem:
if the following are true:
- instruction #0 is
beq left=1 right=2 imm=2
- the PC at time 0 = 0
- value of cell 1 at time 0 = 2
- value of cell 2 at time 0 = 2
then the PC at time 1 = 3
The following example shows that when the value stored in the left cell (cell #1) is equal to the value in the right cell (cell #2), the PC is incremented by imm (2) + 1.
Instructions
Memory Cells |
---|
Program Counter | Time |
---|---|
0 | 0 |
LW Computer Simulator
Proof:
Given
1 | instruction #0 is beq left=1 right=2 imm=2 |
---|---|
2 | the PC at time 0 = 0 |
3 | value of cell 1 at time 0 = 2 |
4 | value of cell 2 at time 0 = 2 |
# | Claim | Reason |
---|---|---|
1 | value of cell 1 at time 0 = value of cell 2 at time 0 | if value of cell 1 at time 0 = 2 and value of cell 2 at time 0 = 2, then value of cell 1 at time 0 = value of cell 2 at time 0 |
2 | the PC at time (0 + 1) = (0 + 1) + 2 | if instruction #0 is beq left=1 right=2 imm=2 and the PC at time 0 = 0 and value of cell 1 at time 0 = value of cell 2 at time 0, then the PC at time (0 + 1) = (0 + 1) + 2 |
3 | 0 + 1 = 1 | 0 + 1 = 1 |
4 | (0 + 1) + 2 = 3 | (0 + 1) + 2 = 3 |
5 | the PC at time (0 + 1) = 3 | if the PC at time (0 + 1) = (0 + 1) + 2 and (0 + 1) + 2 = 3, then the PC at time (0 + 1) = 3 |
6 | the PC at time (0 + 1) = the PC at time 1 | if 0 + 1 = 1, then the PC at time (0 + 1) = the PC at time 1 |
7 | the PC at time 1 = 3 | if the PC at time (0 + 1) = the PC at time 1 and the PC at time (0 + 1) = 3, then the PC at time 1 = 3 |
Comments
Please log in to add comments