$\require{cancel}$
While not HALT
Fetch the next instruction from memory
Decode the instruction and decide what actions to take
Execute the instruction (or take the actions)
load RD, ADDRESS: load register RD from the data at address ADDRESS
store RS, ADDRESS: store the value at RS to the memory location ADDRESS
add RD, RS1, RS2: add the contents of register RS1 to the contents of register RS2 and store the result in RD
sub RD, RS1, RS2: subtract the contents of register RS2 from the contents of register RS1 and store the result in RD
jump ADDRESS: Set the value of the PC to ADDRESS
jumpz R, ADDRESS : If the contents of register R is 0, set the PC to ADDRESS
jumpn R, ADDRESS : If the contents of register R are less than 0, set the PC to ADDRESS
HALT stop the execution of the program.
| Address | Value |
|---|---|
| 0 | load R1, 10 |
| 1 | load R2, 9 |
| 2 | sub R3, R1, R2 |
| 3 | jumpn R3, 5 |
| 4 | load R1, 9 |
| 5 | store R1, 8 |
| 6 | halt |
| 7 | 0 |
| 8 | 0 |
| 9 | 23 |
| 10 | 35 |