Coal 1
Coal 1
Organization and
Assembly Language
Lecture 1
4
Course Objectives
• To understand organization of a computer system
• To gain an insight knowledge about the internal architecture and
working of microprocessors.
• To understand working of memory devices, interrupt controllers and
I/O devices.
• To learn Assembly Language
• To understand how low level logic is employed for problem solving
by using assembly language as a tool.
5
Structure
• Structure is the way in which components relate to each other
6
Difference in Peripherals &
Communication Lines
• When data is received from or delivered by a device that is
directly connected to the computer, process is called Input-
Output (I/O).
• When data are moved over longer distance, to or from a
remote device, the process is known as Data Communication.
7
Structure - Top Level
Peripherals Computer
Central Main
Processing Memory
Unit
Computer
Systems
Interconnection
Input
Output
Communication 8
lines
Structure – Top Level Contd..
• Four main structural components:
• CPU: controls the operation of the computer and performs its data
processing functions; often referred as processor.
• Main Memory: stores data
• I/O: moves data between the computer and its external environment.
• System Interconnections: Mechanism for communication among CPU,
memory, and I/O.
9
Structure - The CPU
CPU
Computer Arithmetic
Registers and
I/O Login Unit
System CPU
Bus
Internal CPU
Memory Interconnection
Control
Unit
10
Structure – The CPU
• Control Unit: controls the operation of CPU and hence
the computer.
• Arithmetic and logic unit: performs the computer’s data
processing functions.
• Registers: provides storage internal to CPU.
• CPU interconnection: Mechanism that provides for
communication among the control unit, ALU, and
registers.
11
Structure - The Control Unit
Control Unit
CPU
Sequencing
ALU Logic
Control
Internal
Unit
Bus
Control Unit
Registers Registers and
Decoders
Control
Memory 12
Structure - The Control Unit
• Sequencing Logic: sequential logic is a type of logic circuit whose
output depends not only on the present value of its input signals but
on the past history of its inputs. This is in contrast to combinational
logic, whose output is a function of only the present input
• Control Memory: Any computer that involves microprogrammed
control consists of two memories. They are the main memory and the
control memory. A control memory is a part of the control unit. This is
a small, specialized memory used to store the microprogram (a
sequence of microinstructions).Microprogrammed control contain
microinstructions that specify the internal control signals required to
execute register micro-operations (ROM).
13
Structure - The Control Unit
• Control Memory: Microprogramming is a method used to control
the internal operations of a microprocessor. It involves breaking down
the instructions that a processor executes into simpler, more
elementary operations called microinstructions. These
microinstructions are stored in a special memory called control
memory or microprogram memory and are used to generate the
control signals needed to execute each instruction
• How Microprogramming Works:
• Fetch ins.Decode ins.Execute ins.Store instruction
• Control Unit Registers: Normally two registers are control
address register and control data register
14
Function
• Function is the operation of individual components as part of the
structure.
• Main functions performed by a computer system are:
• Process Data
• Store Data
• Move Data
• Control the above three functions
15
Functional View of Computer
16
Possible Operations
Data movement device Data storage device (read/write)
17
Digital Computer
Computer system has two functional components:
Software: instructions and data that computer manipulate for data processing
System software are those group of softwares whose sole purpose is to control
and effectively use the computer hardware resources e.g. OS
Application softwares are for the facilitation of user not for system
19
Digital Computer
CPU contains:
Memory of computer contains storage for instructions and data called RAM
Random access memory as CPU can access any location on memory within a fixed
interval of time
21
COMPUTER ORGANIZATION
&
ARCHITECTURE
22
Computer Architecture
Computer architecture refers to
• Attributes of a system visible to designer
• Study of computer system in designer’s point of view
• Study of computer system in hardware point of view
• How system is implemented?
• Attributes that have a direct impact on the execution of programs
• How processor or memory implemented?
• Those attributes that have direct impact on logical execution of a program.
Attributes
• Instruction set
• Data representation (no. of bits used to represent various data types)
• I/O mechanisms
• Addressing techniques
23
• Example: Architectural design issue whether a computer will have multiply
instruction or not.
Computer Organization
Study of computer system in user’s point of view
Study of computer system in software point of view
Attributes of a system visible to programmers
How overall system is describe?
Organization refers to operational units and their interconnections that realize the
architectural specifications.
The way the hardware components operate and the way they are connected
What is processor and its types? What is memory and its types?
27
MICRO PROCESSOR
APPLICATION
4 8 16 32 64…..
EE CS
ROM RAM
Hardware Software
28
HARDWARE
USER
APPLICATION
SOFTWARE (High level
Languages c,c++)
SYSTEM
SOFTWARE(Mnemonics
ADD,MUL)
HARDWARE (Machine
codes 01010101010)
29
BASIC COMPUTER
ARCHITECTURE
• A computer system comprises of a processor, memory, and I/O
devices.
• I/O is used for interfacing with the external world, while memory is
the processor’s internal world.
• Processor is the core in this picture and is responsible for
performing operations.
• The operation of a computer can be fairly described with processor
and memory only.
• Whole working of the computer is performing an operation by the
processor on data, which resides in memory.
• The scenario that the processor executes operations and the
memory contains data elements requires a mechanism for the
processor to read that data from the memory. 30
Basic Computer Organization
Processor Memory
I/O(extended Mem.)
31
Basic Computer Organization
32
BASIC COMPUTER
ARCHITECTURE
• Data must be explained to the memory which is a dumb
device.
• Just like a postman, who must be told the precise
address on the letter.
• If we only want to read the data, then there must be a
mechanism to inform the memory that we are interested
in reading data only.
• There must be a mechanism to inform memory that we
want to read precisely which element
• A bus is a connection between components or devices
connected to a computer. 33
BASIC COMPUTER
ARCHITECTURE
• A bus carries data between a CPU and the
system memory via the motherboard.
• Think of a computer bus like public transportation.
• These types of buses are capable of transporting people
from one destination to another destination.
• Like these buses, a computer bus transmits data from
one location or device to another location or device.
• A computer bus maintains a strict schedule, "picking up"
data and "dropping it off" at a regular interval.
• For example, if a bus operates at a frequency of
200 MHz, it completes 200 million data transfers per 34
second.
WHY BUSES?
• 1. Data sharing - All types of buses found in a computer transfer
data between the computer peripherals connected to it. The buses
transfer or send data either in the serial or parallel method. This
allows for the exchange of 1, 2, 4 or even 8 bytes of data at a time.
Buses are classified depending on how many bits they can move at
the same time, which means that we have 8-bit, 16-bit, 32-bit or
even 64-bit buses.
• 2. Addressing - A bus has address lines, which match those of the
processor. This allows data to be sent to or from specific memory
locations.
• 3. Power - A bus supplies power to various peripherals connected to
it.
• 4. Timing - The bus provides a system clock signal to synchronize the
peripherals attached to it with the rest of the system. 35
WHY BUSES?
• The Computer bus helps the various parts of the PC
communicate.
• If there was no bus, you would have a bulky number of
wires connecting every part to every other part.
• It would be like having separate wiring for every light
bulb and socket in your house.
36
BASIC COMPUTER
ARCHITECTURE
• There must be a mechanism to transfer data element from memory to
processor
• The group of bits that the processor uses to inform the memory about
which element to read or write is collectively known as the address bus.
• The length of the address bus determines the amount of memory a
system can address. Such as a system with a 32-bit address bus can
address 2^32 memory locations..
• Another important bus called the data bus is used to move the data from
the memory to the processor in a read operation and from the processor
to the memory in a write operation.
• The third group consists of miscellaneous independent lines used for
control purposes.
37
BASIC COMPUTER
ARCHITECTURE
• For example, one line of the bus is used to inform the memory
about whether to do the read operation or the write operation.
• These lines are collectively known as the control bus.
• These three buses are the eyes, nose, and ears of the processor.
• It uses them in a synchronized manner to perform a meaningful
operation.
• The width of the data bus is directly related to the largest number
that the bus can carry, such as an 8 bit bus can represent 2 to the
power of 8 unique values, this equates to the number 0 to 255.A 16
bit bus can carry 0 to 65535.
• Although the programmer specifies the meaningful operation, but to
fulfill it the processor needs the collaboration of other units and
peripherals.
38
• This collaboration is made available using the three buses.
BASIC COMPUTER
ARCHITECTURE
• The address bus is unidirectional and address always travels from
processor to memory.
• This is because memory is a dumb device and cannot predict which
element the processor at a particular instant of time needs.
• Data moves from both, processor to memory and memory to processor, so
the data bus is bidirectional.
• Control bus is special and relatively complex, because different lines
comprising it behave differently.
• Some take information from the processor to a peripheral and some take
information from the peripheral to the processor.
• There can be certain events outside the processor that are of its interest.
• To bring information about these events the data bus cannot be used as it
is owned by the processor and will only be used when the processor
39
grants permission to use it.
Basic Computer Organization
Address Bus
Data Bus
Processor Memory
Control Bus
40
BASIC COMPUTER
ARCHITECTURE
• We take an example to explain the collaboration of the
processor and memory using the address, control, and
data buses.
• Consider that you want your uneducated servant to bring
a book from the shelf.
• You order him to bring the fifth book from top of the
shelf.
• We told the servant to “bring a book” and the one which
is “fifth from top,” precise location even for the servant.
• The servant follows the steps one by one and the book is
in your hand as a result. 41
BASIC COMPUTER
ARCHITECTURE
• If however you just asked him for a book or you named the book,
your uneducated servant will not be able to do so.
• In this simple example, mathematics is there, “fifth from top.”
• Without a number the servant would not be able to locate the book.
• Then you tell him to put it with the seventh book on the right shelf.
• Precision is involved and only numbers are precise in this world.
• So we tell in the form of a number on the address bus which cell is
needed out of say the 2000 cells in the whole memory.
• A binary number is generated on the address bus, fifth, seventh,
eighth, tenth; the cell which is needed.
• So the cell number is placed on the address bus.
• A memory cell is an n-bit location to store data, normally 8-bit also
called a byte. 42
BASIC COMPUTER
ARCHITECTURE
• The number of bits in a cell is called the cell width.
• The two dimensions, cell width and number of cells, define the
memory completely
• For memory we define two dimensions.
• The first dimension defines how many parallel bits are there in a
single memory cell.
• The memory is called 8-bit or 16-bit for this reason and this is also
the word size of the memory.
• In general the memory cell cannot be wider than the width of the
data bus.
• Best and simplest operation requires the same size of data bus and
memory cell width.
43
Dimensions of Memory
Horizontal Dimensions = Width of Memory Cell
00000000
Binary 00000001
Vertical
Addresses Dimensions
Of
=
Memory
Cells Size of
00100011 Memory
00100100
44
00100101
BASIC COMPUTER
ARCHITECTURE
• Control bus carries the intent of the processor that it wants to read or to
write.
• Memory changes its behavior in response to this signal from the
processor. It defines the direction of data flow.
• If processor wants to read but memory wants to write, there will be no
communication or useful flow of information.
• Both must be synchronized, like a speaker speaks and the listener
listens.
• If both speak simultaneously or both listen there will be no
communication.
• This precise synchronization between the processor and the memory is
the responsibility of the control bus.
• Since the memory never wants to listen or to speak of itself.
45
• Then why is the control bus bidirectional.
BASIC COMPUTER
ARCHITECTURE
• Consider that the servant went to fetch the book and find that the
drawing room door is locked.
• Now the servant can wait there indefinitely keeping us waiting or
inform us about the situation so that we can act accordingly.
• Synchronization is still important, as a result of our orders either we
got the desired cell or we came to know that the memory is locked
for the moment.
• Such information cannot be transferred via the address or the data
bus.
• For such situations when peripherals want to talk to the processor
when the processor wasn’t expecting them to speak, special lines in
the control bus are used.
• The control bus ensures that the correct data is transferred at the 46
right time and that all components operate in sync.
BASIC COMPUTER
ARCHITECTURE
47
Microprocessors
Characteristics
• These are the most important defining
characteristics of a microprocessor −
• Clock speed
• Instruction set
• Word size
48
Microprocessors
Characteristics
• Every microprocessor has an internal clock that
regulates the speed at which it executes instructions
and also synchronizes it with other components.
• The speed at which the microprocessor executes
instructions is called clock speed.
• Clock speeds are measured in MHz or GHz where 1
MHz means 1 million cycles per second whereas 1
GHz equals to 1 billion cycles per second.
• Here cycle refers to single electric signal cycle.
• Currently microprocessors have clock speed in the 49
range of 3 GHz and also few can attain 8.4 GHZ or
may be even more.
Microprocessors
Characteristics
• Number of bits that can be processed by a processor in a
single instruction is called its word size.
• Word size determines the amount of RAM that can be
accessed at one go and total number of pins on the
microprocessor.
• Total number of input and output pins in turn determines
the architecture of the microprocessor.
• First commercial microprocessor Intel 4004 was a 4-bit
processor. It had 4 input pins and 4 output pins.
• Number of output pins is always equal to the number of
input pins.
50
• Currently most microprocessors use 32-bit or 64-bit
architecture
Microprocessors
Characteristics
• A command given to a digital machine to perform an
operation on a piece of data is called an instruction.
• Basic set of machine level instructions that a
microprocessor is designed to execute is called
its instruction set.
• These instructions do carry out these types of operations
• Data transfer
• Arithmetic operations
• Logical operations
• Control flow
51
• Input/output and machine control
Microprocessor Components
• CPU
• BUS
• MEMORY
52
Microprocessor Components
• Instruction register − It holds the instruction to be
executed.
• Decoder − It decodes (converts to machine level
language) the instruction and sends to the ALU
(Arithmetic Logic Unit).
• ALU − It has necessary circuits to perform arithmetic,
logical, memory, register and program sequencing
operations.
• Register − It holds intermediate results obtained during
program processing. Registers are used for holding such
results rather than RAM because accessing registers is 53
almost 10 times faster than accessing RAM.
Microprocessor Components
• Data Bus − Lines that carry data to and from memory are
called data bus. It is a bidirectional bus with width equal
to word length of the microprocessor.
• Address Bus − It is a unidirectional responsible for
carrying address of a memory location or I/O port from
CPU to memory or I/O port.
• Control Bus − Lines that carry control signals like clock
signals, interrupt signal or ready signal are called control
bus. They are bidirectional. Signal that denotes that a
device is ready for processing is called ready signal.
Signal that indicates to a device to interrupt its process is
54
called an interrupt signal.
Microprocessor Components
• RAM − Random Access Memory is volatile memory that
gets erased when power is switched off. All data and
instructions are stored in RAM.
• ROM − Read Only Memory is non-volatile memory
whose data remains intact even after power is switched
off. Microprocessor can read from it any time it wants
but cannot write to it. It is preprogrammed with most
essential data like booting sequence by the
manufacturer.
55