Lect02 1 SmallComp-1 PDF
Lect02 1 SmallComp-1 PDF
Lect02 1 SmallComp-1 PDF
Each instruction consists of sixteen bits divided into four 4-bit fields.
The leftmost field contains the opcode and the other three fields
contains the operand or address of operand (s), as shown in next
Figure.
opcode oprand
Figure: Format and different instruction types
During the execute phase, the instruction is executed and the results
are placed in the appropriate memory location or the register.
Once the third phase is completed, the control unit starts the cycle
again, but now the PC is pointing to the next instruction. The process
continues until the CPU reaches a HALT instruction.
An example
Let us show how our simple computer can add two
integers A and B and create the result as C.
5.8
Storing program and data
We can store the five-line program in memory starting from
location (00)16 to (04)16.
Cycles
Our computer uses one cycle per instruction. If we have a small
program with five instructions, we need five cycles. We also
know that each cycle is normally made up of three steps: fetch,
decode, execute.
Assume for the moment that we need to add 161 + 254 = 415.
The numbers are shown in memory in hexadecimal as, (00A1)16,
(00FE)16, and (019F)16.
Figure Status of cycle 1
Figure Status of cycle 2
Figure: Status of cycle 3
Figure: Status of cycle 4
Figure: Status of cycle 5