CO - Module 1 - PPTtt2
CO - Module 1 - PPTtt2
Dr.Mamatha I
Associate Professor & Head
SMVITM, Bantakal
Declaration: Most of the slides are borrowed from the slides prepared by,
Dr.M. C. Hanumantharaju
Professor,Department of Electronics and Communication Engineering 1
BMS Institute of Technology and Management, Bengaluru
MODULE 3
▪ Basic Structure of Computers: Functional Units, Basic Operational Concepts, Bus
▪ Text book 2: 1.2, 1.3, 1.4, 1.6, 2.2, 2.3, 2.4, 2.5
2
A TYPICAL INSTRUCTION
▪ Add LOCA, R0
▪ Add the operand at memory location LOCA to the operand in a register R0 in the processor.
▪ R0 = R0 + [LOCA]
▪ Assume that the instruction is stored in memory location 1000, the value of R0 is 10 and LOCA is 2000.
LOCA (i.e2000) is transferred to MAR, PC ← 1000, MAR ← PC
▪ The content of MDR is added to R0 and place the sum into register R0.
▪ Assume that the instruction is stored in memory location 1000, the value of R0 is 10 and R1 is 20
▪ PC ← 1000
▪ MAR ← PC
4
SEPARATE MEMORY ACCESS AND ALU
▪ Load LOCA, R1
▪ Add R1, R0
▪ Whose contents will be overwritten?
5
TYPICAL OPERATING STEPS
▪ General-purpose register
▪ To general-purpose register
6
INTERRUPT
servicing.
▪ The normal execution of the current program must be interrupted–the device raises an
interrupt signal.
▪ Interrupt-service routine
7
BUS STRUCTURE
operational system.
▪ Bus refers a group of lines that serve as a connecting path for several devices
▪ Address/data/control
▪ The simplest way to connect the functional unit is to use the single bus architecture
8
BUS STRUCTURE
Single bus structure
▪ Single-bus : Bus can be used only for one transfer at a time, only two units can actively
use the bus at any given time.
▪ Multiple buses are used for better performance because parallelism in data transfer is
allowed
9
SPEED ISSUE
▪ If the speed of bus is bounded by the slowest device connected to it, the efficiency will be
very low.
▪ The Buffer Register when connected with the bus, carries the information during transfer.
▪ The Buffer Register prevents the high speed processor from being locked to a slow I/O device
10
PERFORMANCE
▪ The most important measure of a computer is how quickly it can execute programs.
▪ Hardware design
▪ Instruction set
▪ Compiler
11
PERFORMANCE
▪ The processor and a relatively small cache memory can be fabricated on a single
▪ Cost
▪ Memory management
▪ Processor Clock
▪ The execution of each instruction is divided in to several steps (Basic Steps),each of which
12
BASIC PERFORMANCE EQUATION
▪ T–processor time required to execute a program that has been prepared in high-level
language
▪ S–average number of basic steps needed to execute one machine instruction. Each step
completes in one clock cycle
▪ R–clock rate
▪ How to improve T?
▪ The value of S doesn’t have to be the number of clock cycles to execute one
instruction.
▪ Add R1, R2, R3 at the same time processor reads next instruction in memory.
14
PIPELINE AND SUPERSCALAR OPERATION
processor.
15
CLOCK RATE
▪ Increase clock rate
▪ Reduce the amount of processing done in one basic step (however, this may increase the
aspects of the processor’s operation equally except the time to access the main
memory.
16
CISC AND RISC
▪ Trade off between N and S
▪ S is close to 1 even though the number of basic steps per instruction may be considerably
larger
instruction sets
17
CISC AND RISC
18
COMPILER
▪ A compiler translates a high-level language program into a sequence of machine
instructions.
▪ To reduce N, we need a suitable machine instruction set and a compiler that makes
▪ Goal–reduce N×S
19
PERFORMANCE MEASUREMENT
▪ Is difficult to compute.
▪ Measure computer performance using benchmark programs.
▪ System Performance Evaluation Corporation(SPEC) selects and publishes representative
application programs for different application domains, together with test results for many
commercially available computers.
▪ Compile and run (no simulation)
▪ Reference computer
▪ Multicomputers
21
MACHINE
22
INSTRUCTIONS
AND PROGRAMS
OBJECTIVES
23
MEMORY LOCATIONS, ADDRESSES, AND
OPERATIONS
▪ Memory consists of many millions of storage cells, each of which can store1bit.
▪ Data is usually accessed in n-bit groups. n is called word length.
24
CONTINUED..
25
CONTINUED..
▪ To retrieve information from memory, either for one word or one byte (8-bit),
▪ A k-bit address memory has 2k memory locations, namely 0 –(2k-1), called memory
space.
▪ 1K(kilo)=210
▪ 1T(tera)=240
26
CONTINUED..
memory.
▪ Byte locations have addresses 0,1,2,…If word length is 32bits,then successive words are
27
BIG ENDIAN AND LITTLE ENDIAN ASSIGNMENTS
▪ Big-Endian: lower byte addresses are used for the most significant bytes of the word
▪ Little-Endian: opposite ordering. lower byte addresses are used for the less significant
28
MEMORY LOCATION, ADDRESSES, AND OPERATION
▪ Address ordering of bytes: Byte addressing
▪ Word alignment
▪ Words are said to be aligned in memory if they begin at a byte addr. that is a multiple of the
▪ 16-bitword:word addresses:0,2,4,….
▪ 32-bitword:word addresses:0,4,8,….
▪ 64-bitword:word addresses:0,8,16,….
29
MEMORY OPERATION
▪ Address –Load
30
INSTRUCTION
31
AND
INSTRUCTION
SEQUENCING
MUST PERFORM OPERATIONS
▪ I/O transfers
32
REGISTER TRANSFER NOTATION
33
REGISTER TRANSFER NOTATION
▪ Identify a location by a symbolic name standing for its hardware binary address
(LOC,R0,…)
▪ Contents of a location are denoted by placing square brackets around the name of the
location (R1←[LOC],R3←[R1]+[R2])
34
ASSEMBLY LANGUAGE NOTATION
▪ Move LOC, R1 => R1←[LOC] : Instruction that causes the transfer from memory location LOC to
processor register R1
▪ Add R1, R2, R3 => R3 ←[R1]+[R2] : Adding two numbers contained in processor registers R1
35
BASIC INSTRUCTION TYPES
36
37
38
39
40
CPU ORGANIZATION
▪ Single Accumulator
▪ General Register
▪ Register bookkeeping
▪ Stack
41
INSTRUCTION FORMATS
▪ Three-Address Instructions
▪ Two-Address Instructions
▪ One-Address Instructions
▪ Zero-Address Instructions
▪ RISC Instructions
42
INSTRUCTION FORMATS
▪ Example: Evaluate (A+B) * (C+D)
▪ Three-Address
43
INSTRUCTION FORMATS
▪ Example: Evaluate (A+B) * (C+D)
▪ One-Address
▪ 1.LOAD A; AC ← M[A]
▪ 4.LOAD C; AC ← M[C]
44
INSTRUCTION FORMATS
▪ Example: Evaluate (A+B) * (C+D)
▪ Zero-Address
▪ 3.ADD; TOS ← [A + B]
▪ 6.ADD; TOS ← [C + D]
45
INSTRUCTION FORMATS
▪ Example: Evaluate (A+B) * (C+D)
▪ RISC
▪ 1.LOAD A, R1 ; R1 ← M[A]
▪ 2.LOAD B, R2 ; R2 ← M[B]
▪ 3.LOAD C, R3 ; R3 ← M[C]
▪ 4.LOAD D, R4 ; R4 ← M[D]
46
USING REGISTERS
▪ Shorter instructions
▪ Potential speedup
▪ Minimize the frequency with which data is moved back and forth between the
47
USING REGISTERS
▪ Using accumulator (single address)
48
DATA TRANSFER INSTRUCTION
▪ Move instruction
equivalent to
▪ Store instruction
▪ In a processor if arithmetic operations are allowed only with the processor registers
49
CONTINUED..
▪ One operand in memory other in register
50
INSTRUCTION EXECUTION AND STRAIGHT-LINE
SEQUENCING
▪ Assumptions:
-One memory operand per instruction
-Has many processor registers
-32-bit word length
-Memory is byte addressable
▪ The three instructions of the program are
in successive word locations, starting at
location i. Since each instruction is 4
bytes long, the second, third, and fourth
instructions are at addresses i + 4, i + 8,
▪ Full memory address can be directly
specified in a single-word instruction
▪ Two-phase procedure
▪ -Instruction fetch
▪ -Instruction execute
51
STRAIGHT LINE SEQUENCING
▪ The processor contains a register called the program counter (PC), which holds the address of
▪ To begin executing a program, the address of its first instruction (i in our example) must be
▪ Then, the processor control circuits use the information in the PC to fetch and execute
▪ During the execution of each instruction, the PC is incremented by 4 to point to the next
instruction. Thus, after the Move instruction at location i + 8 is executed, the PC contains the
value i + 12, which is the address of the first instruction of the next program segment.
52
STRAIGHT LINE SEQUENCING
▪ Executing a given instruction is a two-phase procedure.
▪ In the first phase, called instruction fetch, the instruction is fetched from the memory location
whose address is in the PC.
▪ This instruction is placed in the instruction register (IR) in the processor.
▪ At the start of the second phase, called instruction execute, the instruction in IR is examined to
determine which operation is to be performed.
▪ The specified operation is then performed by the processor.
▪ This involves a small number of steps such as fetching operands from the memory or from
processor registers, performing an arithmetic or logic operation, and storing the result in the
destination location.
▪ At some point during this two-phase procedure, the contents of the PC are advanced to point to
the next instruction.
▪ When the execute phase of an instruction is completed, the PC contains the address of the next
instruction, and a new instruction fetch phase can begin.
53
BRANCHING
54
BRANCHING
▪ Assume that the number of entries in
the list, n, is stored in memory location
N, as shown.
▪ Register R1 is used as a counter to
determine the number of times the
loop is executed.
▪ Hence, the contents of location N are
loaded into register R1 at the
beginning of the program.
▪ Then, within the body of the loop, the
instruction Decrement R1is executed,
reduces the contents of R1 by 1 each
time through the loop.
55
CONTINUED..
▪ Execution of the loop is repeated as long as the contents of R1
are greater than zero.
Branch instructions.
▪ This type of instruction loads a new address into the program
counter.
▪ As a result, the processor fetches and executes the instruction at
this new address, called the branch target, instead of the
instruction at the location that follows the branch instruction
in sequential address order.
▪ A conditional branch instruction causes a branch only if a
specified condition is satisfied.
▪ If the condition is not satisfied, the PC is incremented in the
normal way, and the next instruction in sequential address
order is fetched and executed.
56
CONTINUED..
▪ Branch>0 LOOP is a conditional branch instruction that causes a branch to location
value of zero in R1, and, hence, branching does not occur. Instead, the Move
instruction is fetched and executed.
▪ It moves the final result from R0 into memory location SUM.
57
CONDITION CODES
▪ Processor keeps track of information about the results of various operations for use by
subsequent conditional branch instructions
▪ Accomplished by recording the required information in individual bits, called condition code
flags
▪ Flags grouped together in a special purpose register called condition code register or status
register.
▪ Individual condition code flags are set to 1 or cleared to 0 depending on the outcome of the
operation
▪ Condition code flags (bits)
59
CONDITIONAL BRANCH INSTRUCTIONS
60
STATUS BITS
61
62
ADDRESSING
MODES
GENERATING MEMORY ADDRESSESS
▪ Can we give the memory operand address directly in a single Add instruction in the
loop?
▪ Use a register to hold the address of NUM1; then increment by 4 on each pass through
the loop.
63
ADDRESSING MODES
▪ The different ways in which the location of an operand is specified in an instruction are
64
EFFECTIVE ADDRESSES
▪ In the addressing modes that follow, the instruction does not give the operand or its
65
ADDRESSING MODES
▪ Implied
▪ AC is implied in “ADD M[AR]” in “One-Address” instr.
▪ TOS is implied in “ADD” in “Zero-Address” instr.
▪ Immediate
▪ The use of a constant in “MOV 5, R1”
▪ or “MOV #5, R1”i.e. R1 ← 5
▪ Direct Address
▪ Use the given address to access a memory location
▪ E.g. Move NUM1, R1
Move R0, SUM
66
INDIRECT ADDRESSING
▪ ADD (R1), R0
67
INDIRECT ADDRESSING
▪ Indirect addressing through a memory addressing.
▪ Indicate the memory variable(e.g.A) that holds the address of the variable(e.g.B) that holds
the operand
▪ ADD(A),R0
68
INDIRECT ADDRESSING EXAMPLE
69
EXAMPLE
70
EXAMPLE
71
EXAMPLE
72
EXAMPLE
73
EXAMPLE
74
EXAMPLE
75
ADDRESSING MODES-INDEXING AND ARRAYS
register.
76
INDEXING AND ARRAYS
▪ Index mode –the effective address of the operand is generated by adding a constant
▪ Index register
▪ X(Ri): EA = X + [Ri]
77
INDEXING AND ARRAYS
▪ In general, the Index mode facilitates access to an operand whose location is defined
relative to a reference point within the data structure in which the operand appears.
▪ 2D Array
▪ 3D Array
78
ADDRESSING MODES-INDEXING AND ARRAYS
79
ADDRESSING MODES –INDEXING AND ARRAYS
▪ Array
▪ E.g. List of students marks
80
ADDRESSING MODES
▪ Base Register
81
ADDRESSING MODES-INDEXING AND ARRAYS
82
ADDRESSING MODES
▪ Indexed
83
ADDRESSING MODES-RELATIVE ADDRESSING
▪ Relative mode– the effective address is determined by the Index mode using the
▪ Branch>0 LOOP
▪ This location is computed by specifying it as an offset from the current value of PC.
▪ Branch target may be either before or after the branch instruction, the offset is given as
a singed num.
84
RELATIVE ADDRESSING
▪ Relative address
85
ADDITIONAL ADDRESSING MODES
▪ Auto increment mode –the effective address of the operand is the contents of a
register specified in the instruction. After accessing the operand, the contents of this
register are automatically incremented to point to the next item in a list.
▪ (Ri)+. The increment is 1 for byte-sized operands, 2 for 16-bit operands, and 4 for 32-bit
operands.
86
Thank You
87