Background information:
|
Initial situation:
Notice that: the values of the variables x, y and z are stored in the memory
Suppose that the the variables x, y and z are stored in memory addresses 200, 204 and 206, respectively
Step 1: the CPU fetch the value from variable x into a (general purpose) register
The CPU will issue a read command to read the value in memory at address 200
The value on the data bus will be stored in one of the general purpose register (in example: register R0)
Step 2: the CPU fetch the value from variable y into another (general purpose) register
The CPU will issue a read command to read the value in memory at address 204
The value on the data bus will be stored in a different general purpose register (in example: register R1)
Step 3: the CPU can now perform the addition operation with the data in its registers
The result of the operation will be stored in a general purpose register
Notice that: the variable z in the memory has not yet been updated (it's value = 0, which is not equal to 9 !!!)
Step 4: update the variable z in memory
The CPU will issue a write command to update the value in memory at address 206
Notice that: only after this step is the variable z in the memory updated !!