Professional Documents
Culture Documents
Module 3 Coa
Module 3 Coa
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:
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.
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:
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.
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).
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.
Only 3 bits of the instruction are used for the operation code
Instruction types
• Different assembly language instructions are mainly catogories into the following
4
o Move data from memory to registers,from registers to registers,from registers to
memory.
2) Input/output instruction
a) Arithmetic instruction
c) Shift instructions
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)
• Arithmetic
• Shift
• Logical
• 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)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
Disadvantages
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.
For Example: ADD R1, 4000 - In this the 4000 is effective address of operand.
NOTE: Effective Address is the location where operand is present.
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.
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.
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.
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.
12
• The cycle is then repeated by fetching the next instruction. Thus in this way the
instruction cycle is repeated continuously.
Ie,once the sum has been determined, it is written to the main memory or to another
register.
13
14