UNIT-1 Computer - Instruction - PDF
UNIT-1 Computer - Instruction - PDF
Architecture
BCA-303
by
prof.(dr.) rattan rana
2
Computer Instructions
Computer instructions are a set of machine language instructions that a particular processor
understands and executes. A computer performs tasks on the basis of the instruction provided.
An instruction comprises of groups called fields. These fields include
▪ The Operation code (Opcode) field which specifies the operation to be performed
▪ The Address field which contains the location of the operand, i.e., register or memory location.
▪ The Mode field which specifies how the operand will be located
Computer Instructions (Contd.)
✓The remaining 12 bits are used to specify the type of input-output operation or
test perfomed.
Computer Instructions (Contd.)
Instruction Cycle
The basic function of CPU is the execution of program and program contains the set of
instructions.
✓ The sequence of instructions is executed by the CPU
✓ The instruction cycle is the time period during which one instruction is fetched from
memory and executed when a computer is given an instruction in machine language.
✓ There are typically five stages of an instruction cycle that the CPU carries out
Instruction Cycle (Contd.)
Instruction Cycle
1. Fetch : fetching the instruction from the memory, it loads the instruction into IR. So
that the instruction can be decoded.
2. Decode: The instruction is decoded
3. Read: it reads the effective address from memory if the instruction has an indirect
address
4. Execute: The instruction is executed
5. Write: It write back the result into register
An instruction cycle is also called as machine cycle.
Instruction Cycle (Contd.)
Instruction Cycle
Instruction Cycle (Contd.)
Fetch Cycle:
The first step CPU carries out is to fetch some data and instructions from the main memory then
store them in its own internal temporary memory area (Registers). This is called the fetch part
of the cycle. For this to happen CPU uses the vital hardware path called the address bus.
✓ The CPU places the address of next item to be fetched on the address bus.
✓ Data from the address bus then moves from main memory into the CPU
✓ The next step is for CPU is to make sense of the instruction it has just fetched. This process is
called ‘decode’
✓ The CPU decodes the instruction and process various areas within the chip in readiness of
next step
Instruction Cycle (Contd.)
Fetch Cycle:
The sequence of event in fetching an instruction can be summarized as follow:
✓ The contents of PC are loaded into MAR register
✓ The value of PC is incremented by one.
✓ As a result of memory read operation, the instruction is loaded into the register MDR
✓ The content of MDR are loaded int the register IR
Instruction Cycle (Contd.)
Execute Cycle:
This is the part of the cycle when data processing actually takes place. The result of this
processing is stored in yet another register. Once the execution stage is complete, the CPU sets
itself to begin another cycle once more
For example Add R1, R2, R3
This instruction add the content of R1 and R2 then store the result in R3
✓ The Register R3, R2, R2 are extracted from the IR
✓ The contents of R1 and R2 are passed to the ALU for addition
✓ The output of the ALU is transferred to R3
Performance
❑ The speed with which a computer executes programs is affected by
the design of its hardware and its machine language instructions
➢ Let the length P of one clock cycle, its inverse is the clock rate,
R=1/P
❑ Multiprocessor computer
➢ Execute a number of different application tasks in parallel
➢ Execute subtasks of a single large task in parallel
➢ All processors have access to all of the memory – shared-memory multiprocessor
➢ Cost – processors, memory units, complex interconnection networks
❑ Multicomputers
➢ Each computer only have access to its own memory
➢ Exchange message via a communication network – message-
passing multicomputers