Download as pdf or txt
Download as pdf or txt
You are on page 1of 14

Module 3

Basic computer organization and design:


✓ Instruction codes
✓ Computer registers
✓ Computer instructions
✓ Instruction types
✓ Timing and control
✓ Instruction cycle
✓ Memory reference instructions
✓ Input, output and interrupt design of basic computer
✓ Design of accumulator logic

Format of Instruction
• The format of an instruction is depicted in a rectangular box symbolizing the bits of an
instruction.
• Basic fields of an instruction format are given below:

1. An operation code field that specifies the operation to be performed.


2. An address field that designates the memory address or register.
3. A mode field that specifies the way the operand of effective address is determined.

• Computers may have instructions of different lengths containing varying number of


addresses.
• The number of address field in the instruction format depends upon the internal
organization of its registers.

Computer instruction
• A computer instruction is a binary code that specifies a sequence of micro operations
for a computer.
• A program is a set of instruction that specify the operations, operands and the
sequence by which processing has to occur.
• The computer reads each instruction from memory and places it in a control register.
• Every computer has its own unique instruction set.

1
• The basic computer has three instruction code formats. The Operation
code (opcode) part of the instruction contains 3 bits and remaining 13 bits
depends upon the operation code encountered.
• There are three types of formats:
1. Memory Reference Instruction
• It uses 12 bits to specify the address and 1 bit to specify the addressing mode (I). I is
equal to 0 for direct address and 1 for indirect address.

2. Register Reference Instruction


• These instructions are recognized by the opcode 111 with a 0 in the left most bit of
instruction. The other 12 bits specify the operation to be executed.

3. Input-Output Instruction
These instructions are recognized by the operation code 111 with a 1 in the left most bit of
instruction. The remaining 12 bits are used to specify the input-output operation.

Note:
o The three operation code bits in positions 12 through 14 should be equal to 111.
Otherwise, the instruction is a memory-reference type, and the bit in position 15 is
taken as the addressing mode I.
o When the three operation code bits are equal to 111, control unit inspects the bit in
position 15. If the bit is 0, the instruction is a register-reference type. Otherwise, the
instruction is an input-output type having bit 1 at position 15.

2
Instruction Set Completeness
• A set of instructions is said to be complete if the computer includes a sufficient number
of instructions in each of the following categories:

o Arithmetic, logical and shift instructions


o A set of instructions for moving information to and from memory and processor
registers.
o Instructions which controls the program together with instructions that check status
conditions.
o Input and Output instructions

• Arithmetic, logic and shift instructions provide computational capabilities for


processing the type of data the user may wish to employ.
• Program control instructions such as branch instructions are used change the
sequence in which the program is executed.
• Input and Output instructions act as an interface between the computer and the
user. Programs and data must be transferred into memory, and the results of
computations must be transferred back to the user.

Instruction code
• An instruction code is a group of bits that tells the computer to perform a specific
operation part.
• It is usually divided into parts, each having its own particular interpretation.
• The most basic part of an instruction code is its operation part.
• The operation code of an instruction is a group of bits that define operations such as
add, subtract, multiply, shift and compliment.
• The number of bits required for the operation code depends upon the total number of
operations available on the computer.
• The operation code must consist of at least n bits for a given 2^n operations.
• The operation part of an instruction code specifies the operation to be performed.

Relationship between a computer operation and a micro


operation
• An operation is part of an instruction stored in computer memory.it is a binary code
that tells the computer to perform a specific operation.
• The control unit receives the instruction from memory and interprets the operation
code bits.it then issues a sequence of control signals to initiate microoperations in
internal computer register.
• An operation code is sometimes called a micro operations.
• The operation part of an instruction code specifies the operation to be performed.
• Computers with a single processor register is known as Accumulator (AC). The
operation is performed with the memory operand and the content of AC.

3
• Computer that have a single processor register usually assign to it the name
accumulator and label it AC (it is a register in which intermediate arithmetic and logic
results are stored.it act as a temporary storage which holds an intermediate value in
mathematical and logical calculations).

How to recognize type of instruction


• It is recognized by the computer control from the four bits in positions 12 through 15
of the instruction.

1) If the 3 opcode bits in the position 12 through 14 are not equal to 111,then the
register is a memory-reference type. and bit in position 15 is taken as the addressing
mode I.
2) If the 3 bit opcode is equal to 111,control then inspects the bit in position 15.

Ie, if this bit is 0,the instruction is a register-reference type.

If the bit is 1,the instruction is an input-output type.

Only 3 bits of the instruction are used for the operation code

Instruction types
• Different assembly language instructions are mainly catogories into the following

1) Data transfer instruction

4
o Move data from memory to registers,from registers to registers,from registers to
memory.

Eg:-move, load, store, push, pop, exchange

2) Input/output instruction

o Input : transfers data fron a device or port to either memory or a register.


o Output: transfers data from a register or memory to a specific port or a device.

3) Data manipulation instruction

a) Arithmetic instruction

(add, subtract, multiply, divide, increment, decrement, negate)

b) Logical and bit manipulation instruction

c) Shift instructions

4) Program control instructions

Alter the normal sequence of program excecution.

Program control instructions change or modify the flow of a program. The most basic
kind of program control is the unconditional branch or unconditional jump.

5
Typical operations

• Data movement

Load(from memory)

Store (to memory)

Memory to memory move

Register to register move

Input (from I/O device)

Output( to I/O device)

Push, pop(to / from stack)

• Arithmetic

Add, subtract, multiply, divide

• Shift

Shift left/right, rotate left/right

• Logical

Not, and, or, set, clear

• Control(jump/branch)

Unconditional, conditional

• Subroutine linkage

Call, return

• String

6
Search, translate

Addressing Modes
• The operation field of an instruction specifies the operation to be performed.
• This operation will be executed on some data which is stored in computer registers or the main
memory. The way any operand is selected during the program execution is dependent on the
addressing mode of the instruction. The purpose of using addressing modes is as follows:

1. To give the programming versatility to the user.

2. To reduce the number of bits in addressing field of instruction.

Types of Addressing Modes


Below we have discussed different types of addressing modes one by one:

1)Immediate Mode
• In this mode, the operand is specified in the instruction itself.
• An immediate mode instruction has an operand field rather than the address field.
For example: ADD 7, which says Add 7 to contents of accumulator. 7 is the operand here.

2)Register Mode
• In this mode the operand is stored in the register and this register is present in CPU. The
instruction has the address of the Register where the operand is stored.

Advantages

• Shorter instructions and faster instruction fetch.

• Faster memory access to the operand(s)

Disadvantages

• Very limited address space

• Using multiple registers helps performance but it complicates the instructions.

7
3) Register Indirect Mode
• In this mode, the instruction specifies the register whose contents give us the address of operand
which is in memory.
• Thus, the register contains the address of operand rather than the operand itself.

4) Auto Increment/Decrement Mode


• In this the register is incremented or decremented after or before its value is used.

5) Direct Addressing Mode


In this mode, effective address of operand is present in instruction itself.

• Single memory reference to access data.

• No additional calculations to find the effective address of the operand.

For Example: ADD R1, 4000 - In this the 4000 is effective address of operand.
NOTE: Effective Address is the location where operand is present.

5) Indirect Addressing Mode


• In this, the address field of instruction gives the address where the effective address is stored in
memory.
• This slows down the execution, as this includes multiple memory lookups to find the operand.

8
6) Displacement Addressing Mode
• In this the contents of the indexed register is added to the Address part of the instruction, to
obtain the effective address of operand.

• EA = A + (R), In this the address field holds two values, A(which is the base value) and R(that
holds the displacement), or vice versa.

7) Relative Addressing Mode


• It is a version of Displacement addressing mode.
• In this the contents of PC(Program Counter) is added to address part of instruction to obtain the
effective address.
• EA = A + (PC), where EA is effective address and PC is program counter.
• The operand is A cells away from the current cell(the one pointed to by PC)

8) Base Register Addressing Mode


• It is again a version of Displacement addressing mode. This can be defined as EA = A +
(R), where A is displacement and R holds pointer to base address.

9) Stack Addressing Mode

• In this mode, operand is at the top of the stack.

9
• For example: ADD, this instruction will POP top two items from the stack, add them, and will
then PUSH the result to the top of the stack.

Timing and control


• The timing for all registers in the basic computer is controlled by a master clock
generator.
• The clock pulses are applied to all flip-flops and registers in the system, including the
flip-flops and registers in the control unit.
• The clock pulses do not change the state of a register unless the register is enabled
by a control signal.
• The control signals are generated in the control unit.

Design of control unit


• Control unit generates timing and control signals for the operations of the computer.
• The control unit communicates with ALU and main memory.
• It also controls the transmission between processor, memory and the various
peripherals.
• It also instructs the ALU which operation has to be performed on data.
• Control unit can be designed by two methods which are given below:

Hardwired Control Unit


• It is implemented with the help of gates, flip flops, decoders etc. in the hardware.
• The inputs to control unit are the instruction register, flags, timing signals etc. This
organization can be very complicated if we have to make the control unit large.
• If the design has to be modified or changed, all the combinational circuits have to be
modified which is a very difficult task.

Microprogrammed Control Unit

10
• It is implemented by using programming approach.
• A sequence of micro operations is carried out by executing a program consisting of
micro-instructions.
• In this organization any modifications or changes can be done by updating the micro
program in the control memory by the programmer.

Difference between Hardwired Control and Microprogrammed Control


Hardwired Control Microprogrammed Control

Technology is circuit based. Technology is software based.

It is implemented through flip-flops, Microinstructions generate signals to control the


gates, decoders etc. execution of instructions.

Variable instruction format (16-64 bits per


Fixed instruction format.
instruction).

Instructions are register based. Instructions are not register based.

ROM is not used. ROM is used.

It is used in RISC. It is used in CISC.

Faster decoding. Slower decoding.

Difficult to modify. Easily modified.

Chip area is less. Chip area is large.

Example of control timing signals

11
Instruction cycle
• An instruction cycle, also known as fetch-decode-execute cycle is the basic
operational process of a computer.
• This process is repeated continuously by CPU from boot up to shut down of
computer.

In a basic computer, each instruction cycle consists of the following phases:

1. Fetch instruction from memory.


2. Decode the instruction.
3. Read the effective address from memory.
4. Execute the instruction.

1. Fetch the Instruction


• The instruction is fetched from memory address that is stored in PC(Program
Counter) and stored in the instruction register IR.
• At the end of the fetch operation, PC is incremented by 1 and it then points to the
next instruction to be executed.

2. Decode the Instruction


• The instruction in the IR is executed by the decoder.

3. Read the Effective Address


• If the instruction has an indirect address, the effective address is read from the
memory. Otherwise operands are directly read in case of immediate operand
instruction.

4. Execute the Instruction


• The Control Unit passes the information in the form of control signals to the
functional unit of CPU.
• The result generated is stored in main memory or sent to an output device.

12
• The cycle is then repeated by fetching the next instruction. Thus in this way the
instruction cycle is repeated continuously.

Design of accumulator logic


• An accumulator is a register for short-term, intermediate storage of arithmetic and
logic data in a computer's CPU (central processing unit).
• The most elementary use for an accumulator is adding a sequence of numbers.
• The numerical value in the AC increases as each number is added,exactly as it
happens in a simple desktop calculator.

Ie,once the sum has been determined, it is written to the main memory or to another
register.

• The term "accumulator" is used in a wide variety of noncomputing applications and


activities, such as electrical engineering (an energy storage device such as a
rechargeable battery or ultracapacitor), hydraulics (a mechanical energy storage
device).
• Without a register like an accumulator, it would be necessary to write the result of
each calculation(addition, multiplication, shift etc…)

13
14

You might also like