How to read this figure below ?
Notes :
- Program Counter (PC) = Address of Instruction
- Instruction Register (IR) = Instruction being Executed
- Accumulator (AC) = Temporary Storage
Steps :
- First, PC contains 300 where it is gotten from first address instruction that given from memory. As figure above, the value of this instruction is 1940 (hexadecimal). This instruction with hexadecimal form (1940), is loaded into IR and the PC is incremented.
- Second, after IR contains 1940, this case indicates AC need to be loaded by value which has address 940. Why the address should be 940 ? Why not other address, for example 572, 563,450, and so on ?
AC will indicate the hexadecimal of IR (1940), AC will load 3 last digits of the IR hexadecimal, it is 940 (1940). And than AC will take the value of address 940, it is 0003.
- Third, the next instruction (5941) is fetched from address 301. This step is almost same with first step, so the hexadecimal of address 301 will be loaded into IR and the PC is incremented.
- Fourth, this step is the old AC value will be added by new AC value. The new AC value will be taken from address 941, it is 0002. The old AC value (0003) will be added by the new AC value (0002), so the result is 0005.
Why AC is added ? Because AC is only temporary storage so that the value will be added until the program execution finished.
- Fifth, the next instruction (2941) is fetched from address 302. The hexadecimal of address 302 (it is 2941) will be loaded into IR and the PC is incremented.
- Sixth, AC will be unchanged because it is end of the program execution. The last step is moving the value of AC to memory address 941.