0% found this document useful (0 votes)
6 views4 pages

Lecture 6

The document explains the structure and function of computer instructions, detailing the components of instruction formats including opcode, operands, and addressing modes. It describes the instruction cycle, which consists of fetching, decoding, executing, and optional memory access and write back steps. Examples illustrate the calculation of bits for various instruction parts and the maximum number of instructions a processor can implement based on memory size and register count.

Uploaded by

nqt978v2qz
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views4 pages

Lecture 6

The document explains the structure and function of computer instructions, detailing the components of instruction formats including opcode, operands, and addressing modes. It describes the instruction cycle, which consists of fetching, decoding, executing, and optional memory access and write back steps. Examples illustrate the calculation of bits for various instruction parts and the maximum number of instructions a processor can implement based on memory size and register count.

Uploaded by

nqt978v2qz
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Instruction format and cycle

An instruction is an order given to a computer processor by a computer program. At the lowest


level, each instruction is a sequence of 0s and 1s that describes a physical operation the computer
is to perform (such as "Add") and, depending on the particular instruction type, the specification
of special storage areas called registers that may contain data to be used in carrying out the
instruction, or the location in computer memory of data.

A computer program is a set of instructions that describe the steps to be performed for carrying
out a computational task.

Instruction Format

An instruction format defines the different components of an instruction. The main components of
an instruction are opcode (which instruction to be executed) and operands (data on which
instruction to be executed).

An opcode field: operation code that specifies the operation to be performed.

Opcode=log2(No. of instructions).

An operand field that designates a memory address or a processor register.

Address=log2(size of memory without data) =log2(2k)


Register= log2(No. of registers).

Figure 1 instruction format

Mode field: determines the addressing modes of operands.


Mode= log2(No. of addressing modes).

1
Example 1: A computer uses a memory unit 16k words of 32 bits each. A binary instruction code
is stored in one word of memory. The instruction has four parts:, an operation code, mode to
determine one of 8 address modes, a register code part to specify one of 30 registers, and an address
part.

a- Draw the instruction word format and indicate the number of bits in each part.

b- How many maximum numbers of instructions can be implemented by this processor?

c- How many bits are there in the data and address inputs of the memory?
Solution:

a- Opcode=log2(no. of instructions)
Mode=log2(no. of addressing modes) =log2(8) =log2(23) =3
Register=log2(no. of registers) =log2(30) =log2(25) =5

Address =Log2(size of memory without data) =


log2(16k) =log2(24*210) =log2(214) =14
length of instruction=32 bits (because is stored in one word and word =32 bits)
opcod=32-(3+5+14) =10 bits.

b- Maximum No. of instructions=210=1024 instructions.

c- Size of memory =2k*n= 214*32 →address bits=14, data bits=32

2
Example 2: A computer uses a memory unit of 512 K words of 32 bits each. A binary instruction
code is stored in one word of the memory. The instruction has four parts: an addressing mode field
to specify one bit, an operation code, a register code part to specify one of the 256 registers and an
address part. How many bits are there in addressing mode part, opcode part, register code part and
the address part?

Data:
Memory unit = 512 K words
1 word = 32 bits = 4 B
Binary instruction code stored in 1 word of memory.
Instruction divided as follows,
Addressing mode Operation code Register code Address part

Calculation:
Addressing mode = 1 bit for direct or indirect
Register=log2(no. of registers) =log2(256) =log2(28) =8
Since registers are already addressed, only memory needs to be addressed.
Address =Log2(size of memory without data) =
log2(512k) =log2(29*210) =log2(219) =19
Operation mode = 32 – 1 – 8 – 19 = 4 bits

3
Instruction Cycle

• The instruction cycle (also known as the Fetch–Decode–Execute cycle or the fetch-execute
cycle) is the basic operational process of a computer system.
• The time taken for the execution of an instruction is known as Instruction Cycle.
• It is the process by which a computer retrieves a program instruction from its memory,
determines what actions the instruction describes, and then carries out those actions.
• This cycle is repeated continuously by a computer's central processing unit (CPU), from
boot-up until the computer has shut down.

An instruction cycle involves four steps:

Figure 2: Instruction Cycle


1. Fetching: The processor fetches the instruction from the memory. The fetched instruction is
placed in the Instruction Register. Program Counter holds the address of next instruction to be
fetched and is incremented after each fetch.

2. Decoding: The instruction that is fetched is broken down into parts or decoded. The instruction
is translated into commands so that they correspond to those in the CPU’s instruction set. The
instruction set architecture of the CPU defines the way in which an instruction is decoded.

3. Executing: The decoded instruction or the command is executed. CPU performs the operation
implied by the program instruction. For example, if it is an ADD instruction, addition is performed.

4. (Optional: Memory Access): Some instructions involve reading/writing memory — so this


step may happen after decoding or executing.

5. (Optional: Write Back): The result of execution (especially for arithmetic or data movement)
is written back to a register or memory.

You might also like