BIS302 DDCO Module 3 - Notes
BIS302 DDCO Module 3 - Notes
Semester: 03 Credits: 04
Number of Hours/Week: 04 IA Marks: 50
Total Number of Hours: 50 Exam Marks: 50
MODULE – III
Basic Structure of Computers
Basic Operational Concepts
Bus Structures
Performance
Processor Clock
Basic Performance Equation
Clock Rate
Performance Measurement
Types of Computers:
Personal Computer: It is a type of desktop computer consisting of processing and storage units,
visual display, and audio output units, keyboard. It is used in homes,schools, business offices.
Notebook Computer: It is a compact version of a Desktop Computer where everythingis packed
together into a single unit, the size of a thin briefcase.
Workstations: These have high resolution graphics input/output capabilities, have significantly
more processing power than personal computers. These are used in engineering applications for
interactive design work like animation.
Enterprise system/Servers (low end)
Servers contain sizeable database and serve large volumes of requests to access the data. The
request and theresponse are usually transported over internet.
Super Computers(high end)
These are large computers used for data intensive processing ex weather forecasting,aircraft
design
Mainframes: Used for business data processing inmedium and large corporation that needs more
computing power and storage capacity than workstation.
Primary Memory
o It is a fast memory where programs are stored when they are being executed.
o It is made of large number of storage cells where each cell stores one bit.
o The memory is organized into chunks of m bits called words. Data is read /written from
memory in terms of words.
o Each memory location is associated with an address. This needs to be specified while doing
a read/write operation.
o The length of word determines the type of machine. The length could be 16 bits, 32 bits or
64 bits etc.
o The primary memory is also called random access memory(RAM).The time required to
access one word is called memory access time. This memory access time ranges from few
nanoseconds(ns) to 100ns
o Hierarchy of RAM
Cache: small and fast RAM units. These are highly coupled to processors and are part
of the same processor chip.
Main Memory: This is largest and slowest unit.
Secondary Storage
o Primary storage is expensive hence large amount of data and programs are stored in
nonvolatile memory called secondary storage.
o For example: magnetic disks,tapes, optical disks(CD-ROMs)
Summary
The computer accepts information in the form of programs and data through an input unit and stores
it in memory.
Information stored in memory is fetched under program control into an arithmetic and logic unit,
where it is processed.
Processed information leaves the computer through an output unit.
All activities inside the machine are directed by control unit.
In the above instruction contents of memory location “LOCA” are added to that of R0once the sum is
stored in Register R0.
The above instruction is generally done in two steps.
Load LOCA, R1
Add R1, R0
Step 1: The first line of code needs to be executed, so the address where the line of code
resides is placed in MAR.
Step 2: Read control signal is issued a line of code (ex: Move LOC, R1) is copied into MDR.
Step 3: The contents of MDR are moved to IR.
So, by Step3 the instruction that needs to be executed has been fetched and stored in IR, now
this instruction needs to be executed.
Let “Add LOC, R1” be the instruction. Let’s see how this is executed.
Step 4: If the instruction involves memory access, the address of operand (ex: address of LOC)
is stored in MAR.
Step 5: Then read signal is issued and the contents of memory (i.e. value stored in LOC) are
copied to MDR.
Step 6: The value in MDR is passed to ALU to perform the operation (Add in the above
example)
Step 7: If the result needs to be stored back in memory then the output is put back in MDR and
the location of memory is placed in MAR and “write” signal is executed to write back the result
to memory.
Interrupt:
There are scenarios when normal execution needs to be interrupted to handle situation that needs
immediate attention. In such a scenario an interrupt signal is generated and an appropriate routine
called interrupt service routine is executed.
Since an interrupt, interrupts normal execution of a program, the current values of PC, registers and
control information(flags) are backed up/ saved before executing an interrupt service routine (ISR).
When the ISR execution is over the values of PC, registers and control information are restored.
In single bus architecture all devices are connected to a single bus. So, at any point only two
units/devices can communicate with each other.
Each device operates at its own speed. Electromechanical devices like keyboard, printer
operate at low speeds compared to magnetic and optical disks. Optical disks and magnetic
disks are slower compared to memory and processor speeds.
However, all these operate over common bus. Hence a control/synchronization mechanism is
required to coordinate these devices that operate at varying speeds.
Generally, buffers are used to manage the devices operating at different speeds. Ex:when the
processor needs to print a character on printer, first the character is placed in printer buffer. This
frees up the bus and processor to perform its operation. The printer reads the character from the
buffer and prints it.
1.5Performance
The performance of a computer is how quickly it can execute programs. In this section performance of
process, we consider only those periods of time when the processor is active.This is also called
processor time.This processor time depends on the hardware that is involved in execution of machine
instructions. The pertinent/relevant parts that impact the processor time are in fig 1.5.
When execution of program is about to begin, the program is loaded to memory(main memory)
One instruction at a time is moved from main memory into the process via bus.
A copy of it is stored in cache. When the instruction is being executed operands are read from
memory(ex: LOC) and placed in register. A copy of it is stored in cache for possible re-reading for
future instruction.
Hence, “cache memory” speeds up the program execution.Since it is within the processor, access
time to cache is much less compared to memory(main memory) access.
00 0 0 1 0 1 1 0 1
01 0 1 1 0 1 1 0 1
10 0 0 0 1 0 0 0 1
Dept. of ISE, RNSIT11 0 1 1 0 0 1 0 0 8
MODULE – III BIS302: DDCO
So, to access the numbers”00010001”, we access the address location 10. This memory has
only 4 location & hence it is a 2-bit addressing system.
A 4-bit system has 24 locations 0-15, So 16 words can be stored.
Similarly, a 24-bit system has 2 24 locations in memory i.e.: 16,777,216 locations and each
could store a byte or a word. We can also call 224 locations as 16 M of memory
Similarly, a 32-bit system has an address space of 4G (4 Giga) locations. Each location could
store 8 bits or 32-bit word.
0 1 0 0 0 0 0 0 0
0 1 0 0 0 0 0 0 1
0 1 0 0 0 0 0 1 0
0 0 0 0 0 0 0 0 0
1 1 1 0 0 0 0 0 0
0 0 1 2 3
4 4 5 6 7
8 8 9 10 11
12 12 13 14 15
b) LITTLE ENDIAN
In this system, the lower byte of memory stores the lower order byte(byte 3). We can
visualize it as below:
To manage the instruction as well as data, two basic operations involving memory are needed:
i. Load
Load operation transfers a copy of a memory (instruction or data) to the processor. The contents
of memory do not change (only a copy of it is transferred to processor).
To perform the load operation, the processor sends the memory address and the data to be
readfrom the memory.
ii. Store
Store operation transfers an item of information from processor to a specific memory location.
The previous content of that memory location is over written.
To perform the store operation, the processor sends the memory address and the data to be
written to the memory.
Note:
i. An information item that is transferred between a memory location & a processor could be either
a word or a byte.
ii. A processor contains registers with each register size equal to the length of the word. Hence,
when a load or store operation is done, content of these registers are operated upon.
A memory location could be identified by a symbolic name like LOC and a register could be
identified by names like R0, R5.
I/O register may be identified by names like DATAIN, OUTSTATUS.
Ex: R1 [LOC], this expression means the content of location “LOC” is copied to R1.
Ex: R3 [R1] + [R2], this expression means add the contents of R1 register and contents of R2
register and store it in R3.
This notation is called Register Transfer Notation(RTN).
Note: Right hand side of notation is always a value and left hand side of notation is a
location(register/memory).
Value of a location/register is represented by []. Forexample, [R1] means value stored in register
R1.
To represent the machine instructions, we use another notation called “assembly language”.
Generally, a “C” program is first converted to assembly language
In ‘C’ program when we perform some operation like C = A + B, we are trying to add the contents of
A & B & store it in C.
This can be represented in RTN as C [A] + [B].
The corresponding assembly language instruction is Add A, B, C.
An instruction that works with two operands is called a two address instruction
Ex: RTN Assembly Instruction
C<- [B] Move B, C
A three address operation like Add A,B,C can be represented in multiple two address instructions as
below:
Assembly Instruction RTN
Move B, C C [B]
Add A, C C [A] + [C]
We first move the control of B to C. Then the value in C we add the value of A. This is same as Add
A, B, C.
We can do the 3-instruction operation. Add A,B,C using multiple one Address instruction as below:
RTN Description
In case of one address instruction, based on the operation being done, a memory location could be
a source location or destination location. For example:
Load A : A is a source location
Store C : C is a destination location
Some CPUs/Processors have the luxury of many registers. These registers (R1, R2, …. Rn) are
closest to the processor, so if an operation involves registers it will be very fast.
Ex: Add Ri, Rj Rj [Ri] + [Rj]
Will execute very fast because all operands are registers.
Instruction to transfer content is of two types “Move” & “Load”. If one of the operands is a register,
then it’s better to use “Move” rather than “Load”
In some processors operations can be performed only on registers. In such processor the content
from memory is first moved to registers. Before performing the operation.
Ex: If we want to do C <= A + B with only registers it is done as:
These instructions are stored in the RAM before they are executed on the processor as shown below:
Program that does the addition is stored in 3 contiguous word locations, named as program
segment.
The program uses memory locations A, B and C, which are again stored in the Data part of the
program.
Each instruction is assumed to occupy one word of 32 bits (that’s why the instruction starts at i, i+4
& i+8).
Note:
All these steps are for one operand like Add B, R0. When phase 2 is going on PC moves to the next
word (i.e. say from “i” to “i+4”). So by the time phase 2 is done, PC would have moved to next
instruction and phase 1 & phase 2 are repeated for the next instruction.
This method of executing one instruction after another from start to finish is called straight line
sequence. (The other method of execution is branching, discussed in the next section).
1.8.5 Branching
Let us assume that we need to add “n” numbers NUM1 to NUMn and store the result in a variable
SUM, the code and corresponding data can be written as shown below:
The variable N stores the number of times SUM operation needs to be performed (i.e. n)
Register “R0” stores the intermediate sum as it keeps getting added. Final result is stored in SUM.
The looping block is shown in the brace “{“. In the looping block the next “NUM” is fetched from
memory & added to Register “R0”. The variable R1 is then decremented by 1.
A special instruction is executed called “Branch >0 Loop”, what this instruction means is that, if the
result of the instruction above it (i.e. Decrement R1) resulted in a value> 0 then go back to “Loop”,
else go to next instruction, i.e. “Move R0,SUM”.
So, this special instruction is called a “branch instruction” and the place where we branch i.e. “Loop”
is called “branch target”. Since branching is based on a condition that R1 > 0, the branching is also
called “conditional branching”.
Flag Description
N(negative) set to 1 if result is negative, otherwise cleared to 0
Z(zero) set to 1 if result is 0, otherwise cleared to 0
V(overflow) set to 1 if arithmetic overflow occurs, otherwise cleared to 0.
C(Carry) set to 1 if a carryout results for the operation, otherwise cleared to 0.
So, addition of two +ve numbers results in a negative number, because there was an overflow into the
MSB bit. As soon as this overflow occurs, the overflow bit in this special “condition code register”
becomes 1 to indicate that overflow occurred.Programmer can check this bit and add special code to
handle overflow. A special instruction “Branch If Overflow” is provided to handle this.
Carry (C)
Suppose, we add two numbers as below:
1001 (-7)
1111 (-1) Both numbers in 2’s complement
11000 (-8) overflow occurred
The last bit was an overflow. There is no space for this bit. This bit is stored in the “carry bit of
special register” (condition code register). Again, the programmer can check this bit and handle the
bit accordingly.
Zero (Z)
This bit gets set, if the result of an arithmetic operation is 0.
Ex: If “LOC” memory location had 1.
Move LOC,R1
Decrement R1
When we execute “Decrement R1”, the value of R1 becomes 0, at this point the zero flag in the
special register becomes 1.
Now, how is this helpful? Let’s take an example.
Let LOC be a memory location that store 2
Initially, LOC has 2 and this is copied to location R1. Then, decrement R1 reduces the value by 1.
So, R1 = 1. When the instruction “Branch > 0” is executed; it checks the “zero flag” in the special
register. Since, it has not been set it jumps back to “LOOP” & “Decrement R1” is executed again.
Now, R1 becomes 0. At this point the “zero flag” has been set. So, we do NOT jump to loop,instead
“<Next instruction>” is executed.
It is like coming out of “for” loop in a C program.
N(negative):
If an arithmetic or logical operation results in a negative answer, this flag bit in special register is set.
Programmer can test for this flag and handle the scenario of negative answer.
Let’s take an example. Consider, LOC variable to hold value 0, then
MOV LOC,R1
Loop Decrement R1
Branch > 0 Loop
<next instruction>
Initially R1 has 0. When “decrement R1” is done, the value of R1 becomes “-1”. At this point, the
negative bit (N) is set to 1 in the special register. So, when “Branch > 0 Loop” instruction is executed,
it checks the “zeroflag” AND “negative flag”. Since negative flag is set, it will NOT jump to loop,instead
“Next instruction” is executed.
Move B,R1
Add #6,R1 // Immediate Mode
Move R1,A
The add operation uses immediate mode to add number “6” to the value of B.
In the first case “5” is stored in R1 which is directly added to Register R0. Similarly, in 2 nd case “5” is stored
in memory and it is added directly to R0.
But what if “R1” stores address to a memory location that has the value “5” in it. The Instruction to
represent this is as below. Register R1 stores the address of memory location B which had the value “5”
stored in it. This method of accessing data is called “Indirect Mode”
Add (R1), R0
Indirect mode can occur through memory location as well as shown below. The below instruction means
that the memory location “A” contains the address of memory location “B” and the value at memory location
“B” is added to register R0.
Add (A), R0
Indirect Mode definition: The effective address of the operand is the contents of a register or a memory
location whose address appears in the instruction.
Note: Parenthesis is used to refer operands accessed that are accessed in indirect mode.
Note: The register or memory location that contains the address of an operand is called a pointer.
Example 1:
Let us see an example of adding n numbers using a pointer:
In the above program, Add (R2), R0 will add the contents of memory pointed to by register R2 withthe
register R0, and the instruction “Add #4,R2” is executed, then R2 points to next location which has next
number to be added to R0 (provided the index in R1 has not reached 0).
Example 2: In a “C” program, the instruction A = *B, copies the value pointed to by pointer B into variable
A. The above can be done in assembly language in two ways:
Method 1:
Move B, R1
Move (R1), A
Method 2:
Move (B), A
Note: Method 2 seems simple but it is rarely used. Method 1 is generally preferred by processor designers,
apparently it is faster.
In this case, we shall add the value stored at location 1020 with the value in Register R2. Register R1
contains the offset 20.
Hence, when Add 1000(R1), R2 instruction is executed, then the following steps happen:
Example 3: We have a student database with following fields: Student ID, Test 1 marks, Test 2 marks and
Test 3 marks as shown below:
Calculate the total of Test 1, calculate Total of Test 2 and calculate Total of Test 3.
Solution: The aim is to separately add all the Test 1 score, Test 2 score & Test 3 score.
If there are “n” students in the class, let us list the student details for all students one after the other in the
memory as shown below:
Note: Another improvisation is that to the two register notation, we could add a constant value. This is
represented as X (Ri,Rj).
Relative Mode: The effective address is determined by the index mode using the program counter in place
of the general purpose register Ri, that is the relative mode is similar to index mode
discussed previously, but here the base address is specified by program counter (PC)
instead of some register Ri.
In a “C” program, when we do “ptr++”, the pointer “ptr” jumps 4 bytes to point to the next integer (assuming
1 integer is 4 bytes). Similarly, there is an addressing mode that increments 1 byte, 2 (16-bit operands) or 4
bytes (32-bit operands).
The instruction is shown as (Ri)+, if Ri register points to an operand which is 32-bit, then (Ri)+ will move the
pointer by 4 bytes to the next word.
1) List the steps needed to execute the machine instruction “Add LOCA, R0” in terms of transfers
between the components shown in Figure (Connection between processor and memory) and some
simple control commands. Assume that the instruction itself is stored in the memory at location INSTR
and that this address is initially in register PC. The first 2 steps are expressed as:
Remember to include the steps needed to update the contents of PC from INSTR to INSTR+1 so that the
next instruction can be fetched.
Solution:
Solution:
First three steps are the same as in Problem 1
Transfer contents of R1 and R2 to the ALU
Perform addition of two operands in the ALU and transfer answer into R3
Last two steps are the same as in Problem 1
3) A) Give a short sequence of machine instructions for the task: “Add the contents of memory location A
to those of location B, and place the answer in location C”. Instructions “Load LOC,Ri” and “Store
Ri,LOC” are the only instructions available to transfer data between the memory and GPR Ri. Do not
destroy the contents of either location A or B.
Solution:
Load A, R0
Load B, R1
Add R0, R1
Store R1, C
B) Suppose that Move and Add instructions are available with the format “Move/Add Location1,
Location2”. These instructions move or add a copy of the operand at the first location to the second
location, overwriting the original operand at the second location. Location i can be in either the memory
or the processor register set. Is it possible to use fewer instructions to accomplish the task in Part A? If
Yes, Give the sequence.
Solution:
Move B, C
Add A, C
4) A) Program Execution Time, T is to be examined for a certain high-level language program. The
program can be run on a RISC or a CISC computer. Both computers use pipelined instruction
execution, but pipelining in the RISC machine is more effective than in the CISC machine. Specifically,
the effective value of S in the T expression for the RISC machine is 1.2, but it is only 1.5 for the CISC
machine. Both machines have the same clock rate, R. What is the largest allowable value for N, the
number of instructions executed on the CISC machine, expressed as percentage of the N value for the
RISC machine, if time for execution on the CISC machine is to be no longer than that on the RISC
machine?
Solution:
Let TR = (NR * SR) / RR and TC = (NC * SC) / RC be execution times on the RISC and CISC processors,
respectively. Equating execution times and clock rates, we have
1.2 * NR = 1.5 * NC
Then
NC / NR = 1.2 / 1.5 = 0:8
Therefore, the largest allowable value for NC is 80% of NR.
B) Repeat Part A if the clock rate, R, for the RISC machine is 15 percent higher than that for the CISC
machine.
Solution:
In this case
1.2*NR / 1.15 = 1.5*NC / 1.00
Then
NC / NR = 1.2 / (1.15 * 1.5) = 0:696
Therefore, the largest allowable value for NC is 69.6% of NR.
5) A) Consider the concept of processor cache. Suppose the execution time for a program is directly
proportional to instruction access time and that access to an instruction in the cache is 20 times faster
than access to an instruction in the main memory. Assume that a requested instruction is found in the
cache with probability 0.96, and also assume that if an instruction is not found in the cache, it must be
first fetched from the main memory to the cache and then fetched from the cache to be executed.
Compute the ratio of program execution time with the cache. This ratio is usually defined as the
speedup factor resulting from the presence of the cache.
Solution:
Let cache access time be 1 and main memory access time be 20. Every instruction that is executed
must be fetched from the cache, and an additional fetch from the main memory must be performed for
4% of these cache accesses. Therefore,
6) How the performance of a computer is measured? Assuming that the reference computer is Ultra
SPARC10 workstation with 300MHz Ultra SPARC –III processor. A company has to purchase 500 new
computers, hence ordered testing of a new computer with SPEC2000 (run on reference as well as new
computer). Following observations were made.
The company’s system manager will place the orders for purchasing new computers only if the overall
SPEC rating is at least 12. After the said test, will the system manger place order for the purchase of
new computers?
Solution:
SPECi = Runtime on the reference computer / Runtime on the computer under test
SPEC2= 75/4=18.75
SPEC3= 60/6=10
SPEC4= 30/3=10
= 11.70
Since the rating is 11.7 which is less than the benchmark rating 12, the purchase orders will not be
issued.
7. Write 1-address, 2-address & 3-address instructions for the following expressions:
a. Z = A + BCx + D
b. Y = Ax2 + Bx + C
Ans: (a)
One Address Two Address Three Address
(b)
One Address Two Address Three Address
2.3 Given a binary pattern in some memory location, is it possible to tell whether this pattern represents a
machine instruction or a number?
Ans: No; any binary pattern can be interpreted as a number or as an instruction.
2.4 A memory byte location contains the pattern 00101100. What does this pattern represent when
interpreted as a binary number? What does it represent as an ASCII code?
Ans: The number 44 and the ASCII punctuation character “comma”.
2.5 Consider a computer that has a byte-addressable memory organized in 32-bit words according to the
big-endian scheme. A program reads ASCII characters entered at a keyboard and stores them in
successive byte locations, starting at location 1000. Show the contents of the two memory words at
locations 1000 and 1004 after the name “Johnson” has been entered.
Ans:
Byte contents in hex, starting at location 1000, will be 4A, 6F, 68, 6E, 73, 6F, 6E.
The two words at 1000 and 1004 will be 4A6F686E and 736F6EXX, Byte 1007 (shown as XX) is
unchanged.
Word
Byte Address
Address
1000 J o h n Write the hexadecimal values for each.
1004 S o n
Word
Byte Address
Address
1000 4A 6F 68 6E
1004 73 6F 6E XX
2.8 Write a program that can evaluate the expression A x B + C x D in a single-accumulator processor.
Assume that the processor has Load, Store, Multiply, and Add instructions, and that all values fit in the
accumulator.
Ans:
Load A
Multiply B
Store RESULT
Load C
Multiply D
Add RESULT
Store RESULT
2.13 Registers R1 and R2 of a computer contain the decimal values 1200 and 4600. What is the effective
address of the memory operand in each of the following instructions?
(a) Load 20 (R1), R5
(b) Move #3000, R5
(c) Store R5, 30 (R1, R2)
(d) Add – (R2), R5
(e) Subtract (R1)+, R5
Ans:
(a) 1220
(b) Part of the instruction
(c) 5830 (4600+1200+30)
(d) 4599 (BYTE ADDRESSABLE)
(e) 1200 (POST INCREMENT)