Coam2 - ST
Coam2 - ST
1
Contents of Module 2
Instruction types, Formats, Instruction cycles and sub cycles.
By Dr Pawan Singh Mehra
5
Data Transfer Instruction
By Dr Pawan Singh Mehra
6
Arithmetic Instruction
By Dr Pawan Singh Mehra
Logical Shift Right SHR It shifts the contents of the specified register 1-bit
position towards right and fills the vacant bit with
zero
Logical Shift Left SHL It shifts the contents of the specified register 1-bit
position towards left and fills the vacant bit with zero
Arithmetic Shift Right ASHR It shifts the contents of the specified register 1-bit
position towards right and fills the vacant bit with
previous sign bit
Arithmetic Shift Left ASHL It shifts the contents of the specified register 1-bit
position towards left and fills the vacant bit with zero
Rotate Left ROL It rotates (circular shifts) left the contents of the
specified register
Rotate Right ROR It rotates (circular shifts) right the contents of the
specified register
9
Program Control Instruction
By Dr Pawan Singh Mehra
10
Input/Output Instruction
By Dr Pawan Singh Mehra
11
Instruction Format
A Computer instruction is often divided into two parts
An opcode (Operation Code) that specifies the operation for that instruction
By Dr Pawan Singh Mehra
An address that specifies the registers and/or locations in memory to use for that
operation
In the Basic Computer, since the memory contains 4096 (= 212) words, we need 12 bit
to specify which memory address the instruction will use
In the Basic Computer, bit 15 of the instruction specifies the addressing mode (0:
direct addressing, 1: indirect addressing)
Since the memory words, and hence the instructions, are 16 bits long, that leaves 3 bits
for the instruction’s opcode
Instruction Format
15 14 12 11 0
I Opcode Address
Addressing
mode
12
Addressing Modes
The address field of an instruction can represent either
Direct address: it has the address of the operand (direct access to operand)
By Dr Pawan Singh Mehra
Indirect address: It is the address in memory from which the address of the operand can be fetched.
Direct addressing Indirect addressing
300 1350
457 Operand
1350 Operand
+ +
AC AC
14
By Dr Pawan Singh Mehra
15
By Dr Pawan Singh Mehra
16
Common Bus System
Three control lines, S2, S1, and S0 control which register the bus selects as its input
By Dr Pawan Singh Mehra
Either one of the registers will have its load signal activated, or the memory will have its read signal
activated
Will determine where the data from the bus gets loaded
The 12-bit registers, AR and PC, have 0’s loaded onto the bus in the high order 4 bit positions
When the 8-bit register OUTR is loaded from the bus, the data comes from the low order 8 bits on
the bus
17
Basic Computer Instruction Format
By Dr Pawan Singh Mehra
18
Basic Computer Instructions
By Dr Pawan Singh Mehra
19
Control Unit of Basic Computer
By Dr Pawan Singh Mehra
20
By Dr Pawan Singh Mehra
Timing Signal
21
Instruction Cycle
In Basic Computer, a machine instruction is executed in the following
cycle:
By Dr Pawan Singh Mehra
After an instruction is executed, the cycle starts again at step 1, for the
next instruction
Note: Every different processor has its own (different) instruction cycle
22
Elements of Instruction
Operation Code(OPCODE)
By Dr Pawan Singh Mehra
23
Instruction Cycle
By Dr Pawan Singh Mehra
Fetch
Decode
Execute
24
Fetch Cycle
The address of next instruction is fetched from the program counter
and stored in address register.
By Dr Pawan Singh Mehra
AR PC
IR M[AR], PC PC+1
25
Decode Cycle
In decode operation processor decode the instruction which
is fetched from memory
By Dr Pawan Singh Mehra
26
Execute Cycle
After decoding the instruction, the third timing signal is active.
By Dr Pawan Singh Mehra
27
Execute Cycle
If D=0 and IR(15)=0, that means memory reference instruction is direct
By Dr Pawan Singh Mehra
address instruction.
28
Register Reference Instructions
Register Reference Instructions are identified when
- D7 = 1, I = 0
By Dr Pawan Singh Mehra
Operation
Symbol Symbolic Description
Decoder
AND D0 AC AC M[AR]
ADD D1 AC AC + M[AR], E Cout
LDA D2 AC M[AR]
STA D3 M[AR] AC
BUN D4 PC AR
BSA D5 M[AR] PC, PC AR + 1
ISZ D6 M[AR] M[AR] + 1, if M[AR] + 1 = 0 then PC PC+1
30
Input Output Instructions
D7IT3 = p => Input Output Instruction
By Dr Pawan Singh Mehra
IR(i) = Bi, i = 6, …, 11
p: SC 0 Clear SC
INP pB11: AC(0-7) INPR, FGI 0 Input char. to AC
OUT pB10: OUTR AC(0-7), FGO 0 Output char. from AC
SKI pB9: if(FGI = 1) then (PC PC + 1) Skip on input flag
SKO pB8: if(FGO = 1) then (PC PC + 1) Skip on output flag
ION pB7: IEN 1 Interrupt enable on
IOF pB6: IEN 0 Interrupt enable off
31
Instruction Types(on the basis of addresses)
Stack type organization
By Dr Pawan Singh Mehra
0-Address instruction
Accumulator type organization
1-Address Instructions
General Register Organization
2-Address instructions
3-Address instructions
32
Zero Address Instruction
All addresses implicit, e.g. ADD
By Dr Pawan Singh Mehra
33
1- Address Instruction
One address instruction use an implied accumulator (AC) register for all data manipulation
now we see the same example
By Dr Pawan Singh Mehra
X= (A+B)*(C+D)
LOAD A
ADD B
STORE T
LOAD C
ADD D
MUL T
STORE X
All operation are done between the AC register and a memory operand
T is the address of a temporary memory location for storing intermediate result
34
2- Address Instructions
One address is used as operand and result both.
Most common in commercial in computers . Each address field can specify either a
By Dr Pawan Singh Mehra
X= (A+B)*(C+D)
MOV R1, A
ADD R1, B
MOV R2, C
ADD R2, D
MUL R1,R2
MOV X, R1
Reduces length of instruction
Requires some extra work , temporary storage
MOV instruction moves or transfers the operand to and from memory and processor
registers.
First symbol listed in an instruction is assumed to be both a source and destination . 35
3-Address Instructions
Computer with three address instructions formats can use each address field to specify
either a processor register or a memory operand .
By Dr Pawan Singh Mehra
X= (A+B)*(C+D)
ADD R1,A,B
ADD R2,C,D
MUL X,R1,R2
36
Instances for instructions
By Dr Pawan Singh Mehra
37
Execution of Complete Instruction
ADD (R3) R1
Fetch the instruction from memory-IR
By Dr Pawan Singh Mehra
STEP ACTION
1 PCout, MARin, Read, Select Constant 1, Add, Zin
2 Zout, PCin, Yin ,WMFC
3 MDRout, IRin
4 R3out, MARin, Read
5 R1out, Yin, WMFC
6 MDRout, select Y, Add, Zin
7 Zout, R1in, END
38
Unconditional Branch
By Dr Pawan Singh Mehra
STEP ACTION
1 PCout, MARin, Read, Select Constant 1, Add, Zin
2 Zout, PCin, Yin ,WMFC
3 MDRout, IRin
4 Offset-field-of-IRout, Add, Zin
5 Zout, PCin, END
39
Multiple Bus Organisation
By Dr Pawan Singh Mehra
40
Generation of Control Signal
Two categories:
Hardwired Control
Micro-programmed control
41
By Dr Pawan Singh Mehra
Hardwired Control
42
Hardwired Control
The control unit uses fixed logic circuits to interpret instructions and
By Dr Pawan Singh Mehra
43
Hardwired Control Signal Example
• Zin = T1 + T6 • ADD + T4 • BR + …
By Dr Pawan Singh Mehra
44
Micro-programmed Control
By Dr Pawan Singh Mehra
45
Micro-programmed Control
CONTROL MEMORY
By Dr Pawan Singh Mehra
The micro routines for all the instructions in the instruction set of a
computer are stored in a special memory called the Control
Memory/Store
CONTROL WORD
It is a word whose individual bits represent the various control signals.
MICRO-ROUTINE
A sequence of control words corresponding to the control sequence of
a machine instruction constitutes the micro-routine for that instruction.
MICRO-INSTRUCTION
The individual control words in the micro-routine are referred to as
micro-instruction
46
Micro-programmed Control
By Dr Pawan Singh Mehra
47
Difference between Hardwired and Micro-programmed Control
48
Micro Instruction
A straightforward way to structure microinstructions is to assign one bit
By Dr Pawan Singh Mehra
49
Partial Format for Micro Instruction
By Dr Pawan Singh Mehra
50
Micro Instruction types
The grouping of control signals can be done in one of the two ways
By Dr Pawan Singh Mehra
Vertical Micro-programming
Each micro-instruction specifies single (or few) micro-operations to be
performed.
Horizontal Micro-programming
Each micro-instruction specifies many different micro-operations to
be performed in parallel.
51
Difference between Horizontal & Vertical Microprogramming
Ability to express a high degree of parallelism Limited ability to express parallel micro-operations
52
Addressing Modes
Specifies a rule for interpreting or modifying the address field of
the instruction (before the operand is actually referenced)
By Dr Pawan Singh Mehra
53
Types of Addressing Modes
Implied Addressing Mode
Immediate Addressing Mode
By Dr Pawan Singh Mehra
55
Immediate Addressing Mode
Instead of specifying the address of the operand, operand itself
is specified
By Dr Pawan Singh Mehra
opcode operand
56
Register Addressing Mode
Address specified in the instruction is the register address
- Designated operand need to be in a register
By Dr Pawan Singh Mehra
57
Register Indirect Addressing Mode
Instruction specifies a register which contains the memory
address of the operand
By Dr Pawan Singh Mehra
58
Autoincrement/Autodecrement Addressing Mode
When the address in the register is used to access memory, the
value in the register is incremented or decremented by 1
By Dr Pawan Singh Mehra
automatically
Example:
Autoincrement: Load R1, (R2)+ is interpreted as R1 ← [[R2]]
followed by R2 ← [R2] + d where d is step size(step size is
dependent on size of operand).
Autodecrement: Load R1, -(R2) is interpreted as R2 ← [R2] – d
followed by R1 ← [[R2]] where d is step size size(step size is
dependent on size of operand)
59
Direct Addressing Mode
Instruction specifies the memory address which can be used
directly to access the memory
By Dr Pawan Singh Mehra
60
Indirect Addressing Mode
The address field of an instruction specifies the address of a
memory location that contains the address of the operand
By Dr Pawan Singh Mehra
61
Relative Addressing Mode
The address field of an instruction specifies the part of the address
(abbreviated address) which can be used along with a designated
By Dr Pawan Singh Mehra
63
Micro-Programmed Sequencing
If all micro-programs require only straightforward sequential execution of
microinstructions except for branches, letting a μPC governs the
By Dr Pawan Singh Mehra
64
Micro-Program for Add src Rdst
By Dr Pawan Singh Mehra
65
Wide Branch Addressing
Generating branch addresses becomes more difficult as the number of
branches increases.
By Dr Pawan Singh Mehra
66
Micro Instruction with Next Address Field
The micro-program requires several branch microinstructions, which
By Dr Pawan Singh Mehra
68
Micro Instruction with Next Address Field
By Dr Pawan Singh Mehra
69
Implementation of Micro-routine using next Micro-instruction address field
By Dr Pawan Singh Mehra
70
Prefetching Microinstructions
The disadvantage of micro-programmed control is that it results slower
By Dr Pawan Singh Mehra
71
Complex Instruction Set Computer(CISC)
A computer system with large number of instructions.
By Dr Pawan Singh Mehra
72
Reduced Instruction Set Computer(RISC)
It has relatively few instructions.
By Dr Pawan Singh Mehra
74