Professional Documents
Culture Documents
Assembly Language
Lecture
Basic Concepts & Top-level View of Computer Functio
Dr Hashim Al
Fall - 2021
1
2
Introduction
Chapter - 1.1, 1.
Computer Organization Architecture — William Stallings
2
2
3
r
• Organizational attributes include those hardware details which are transparent to the
programmer, such as
• Control signals, interfaces between computer and peripherals and the memory technology
used
• The Organizational decision may be based on the anticipated frequency of the use of the
multiply instruction, the relative speed of two approaches, and the cost and physical size of a
special multiply unit.
4
.
fi
What is Computer Architecture?
• Computer Architecture is the set of pre-de ned rules and methods that describes the
functionality of computer system
• In other words, a computer consists of both hardware and software and using some rules and
methods for the interaction of both hardware and software of a computer is known as computer
architecture
• Hardware consists of parts like CPU, hard drives, various circuit chips and
• Integrating their functionality with the software that is, the programs (code) to make a
computer system work is the main objective an
• this is done by Computer Architects and designers and coders
5
.
fi
d
• Harvard Architectur
• John Von-Neumann Architecture
7
e
fi
.
Harvard Architecture
• “Harvard Mark I” was the name of a computer which
stored instructions on a punched tapes
9
.
10
.
Structural View
1$
2
+
2
&0
3-
(%
./
,*&
%,
#,$
)(
-4
5,
-(
+
COMPUTER
Peripherals Computer
• I/O – moves data between the
Central
computer and its external Processing
Main
Memory
Unit
environment Computer
Systems
11
COMPUTER
System
Bus
Registers ALU
• Arithmetic and Logic Unit (ALU) — Performs Internal
the computer’s data processing function Bus
Control
Unit
• Registers — Provide storage internal to the CONTROL
CPU Sequencing
UNIT
Logic
a) Data processin
b) Data storag
c) Data movemen
d) Control
13
e
(a) (b)
Movement Movement
Control Control
• The data may take a wide variety of forms, and (c) (d)
(c) (d)
14
Figure 1.2 Possible Computer Operations
.
Operations (2/4)
Movement Movement
(b) Data Storag
(a) (b)
15
Movement Movement
e
Operations (3/4)
Movement
(c) Data Movemen
16
Movement
t
Operations (4/4)
(d) Contro
17
.
A Top-Level Vie
of
Computer Function and Interconnection
Chapter - 3.1, 3.2, 3.3, 3.
Computer Organisation Architecture — William Stallings
18
19
fi
.
fi
.
21
U
1- CPU Component
Abstract Level View
• CPU exchanges data with memory, using
two internal registers
• Memory Address Register (MAR) —
for instruction addres
• Memory Buffer Register (MBR) — for
dat
22
a
Computer Function
• The basic function performed by a computer is execution of a program
• A program consists of a set of instructions stored in memory
23
.
24
e
Fetch Cycle
• At the beginning of each instruction cycle the processor fetches an instruction
from Instruction Memory
• The Program Counter (PC) holds the address of the instruction to be fetched
next
• The processor increments the PC after each instruction fetch so that it will fetch
the next instruction in sequenc
• The processor interprets the instruction and performs the required action
(actions are explained in next slide)
25
.
• Data processing
• The processor may perform some arithmetic or logic operation on data
• Control
• An instruction may specify that the sequence of execution be altered.
For example, the processor may fetch an instruction from location 149, which speci es that the next instruction be from
location 182. The processor will remember this fact by setting the program counter to 182. Thus, on the next fetch cycle, the
instruction will be fetched from location 182 rather than 150
26
.
27
:
Example
Program Execution
28
—
• The execution cycle for a particular instruction may involve more than one reference to
memory. Also, instead of memory references, an instruction may specify an I/O operation
• The gure (state diagram) provides more detailed look at the basic instruction cycle.
29
fi
Description of States
• Instruction Address Calculation (IAC): Determine the address of the next instruction to be executed.
• For example, if each instruction is 16 bits long and memory is organised into 16-bit words, then
add 1 to the previous address. If, instead, memory is organised as individually addressable 8-bit
bytes, then add 2 to the previous address
• Instruction Fetch (IF): Read instruction from its memory location into the processor
• Instruction Operation Decoding (IOD): Analyse instruction to determine type of operation to be
performed and operand(s) to be used
• Operand Address Calculation (OAC): If the operation involves reference to an operand in memory or
available via I/O, then determine the address of the operand
• Operand Fetch (OF): Fetch the operand from memory or read it in from I/O
• Data Operation (DO): Perform the operation indicated in the instruction
• Operand Store (OS): Write the result into memory or out to I/O.
30
Classes of Interrupts
• Virtually all computers provide a mechanism by which other modules (I/
O, memory) may interrupt the normal processing of the processor
• Table lists the most common classes of interrupts.
Program Generated by some condition that occurs as a result of an instruction
execution, such as arithmetic overflow, division by zero, attempt to
execute an illegal machine instruction, or reference outside a user's
allowed memory space.
Timer Generated by a timer within the processor. This allows the operating
system to perform certain functions on a regular basis.
I/O Generated by an I/O controller, to signal normal completion of an
operation, request service from the processor, or to signal a variety of
error conditions.
Hardware failure Generated by a failure such as power failure or memory parity error.
31
Interrupts
• Interrupts are a mechanism for peripherals (I/O) to signal to the computer
processor (CPU) that they require attention
• Dedicated wires are used to connect with all of the peripherals connected to
the computer
• When a peripheral requires attention, it sends a unique signal to the CPU for
it to stop what it is doing and service the peripheral
• Once the CPU has identi ed the peripheral that requires attention, control of
the processor is passed to a small program, called an Interrupt Handler or
Interrupt Service Routine (ISR), which deals with the peripheral.
32
.
fi
Sequence of Events in case of Interrupt
The sequence of events are
• Interrupt is raised
• Current CPU instruction is completed
• Contents of internal registers are stored in (pushed in) stack
• The memory address of the ISR is found and transfer control
• ISR is run
• Internal register contents are restored (popped out) from the stack
• Original process continues from where it was stopped.
33
.
• For example, most external devices are much slower than the processor.
Suppose that the processor is transferring data to a printer using the
instruction cycle scheme. After each write operation, the processor must
pause and remain idle until the printer catches up. The length of this pause
may be on the order of many hundreds or even thousands of instruction
cycles that do not involve memory
34
fi
.
36
Transfer of Control via Interrupts
• From the view point of user program,
an interrupt is an interruption of the
normal sequence of execution
37
• To accommodate interrupts, an interrupt cycle is added to the instruction cycle, as shown in Figure
• In the interrupt cycle, the processor checks to see if any interrupts have occurred, indicated by the
presence of an interrupt signal. If no interrupts are pending, the processor proceeds to the fetch
cycle and fetches the next instruction of the current program.
38
Instruction Cycle With Interrupts (2/2)
• If an interrupt is pending, the processor does the following
• It suspends execution of the current program being executed and saves its context.
This means saving the address of the next instruction to be executed (current
contents of the program counter) and any other data relevant to the processor’s
current activity
• It sets the program counter to the starting address of an interrupt handler routine
• The processor now proceeds to the fetch cycle and fetches the rst instruction in the
interrupt handler program, which will service the interrupt
• The interrupt handler program is generally part of the operating system. Typically, this
program determines the nature of the interrupt and performs whatever actions are
needed.
39
.
Program Timing
Short I/O Wait
• The gure is to visualise the gain in ef ciency
(in terms of time)
40
fi
fi
fi
.
fi
Program Timing:
Long I/O Wait
• The more typical case, especially for a slow device such
as a printer, is that the I/O operation will take much
more time then executing a sequence of user
instructions
41
fi
.
fi
.
42
Transfer of Control with Multiple Interrupts (1/2)
Two approaches can be taken to dealing with
multiple interrupts
1. Disable Interrupt
• Disable interrupts while an interrupt is
being processed
• If an interrupt occurs during this time, it
generally remains pending and will be
checked by the processor after the processor
has enabled interrupts
• After the interrupt handler routine
completes, interrupts are enabled before
resuming the user program, and the
processor checks to see if additional
interrupts have occurred.
43
.
• A second approach is to de ne
priorities for interrupts and to
allow an interrupt of higher
priority to cause a lower-priority
interrupt handler to be itself
interrupted
44
y
fi
Time Sequence of Multiple Interrupts
Occurrence of
ISR Execution
I/O Device Priority Interrupt
Tme
(in time)
Printer 2 10 10
Communication 5 15 10
Disk 4 25 10
ISR (Priority)
2 - Lowest Priorit
Disk (4)
5 - Highest Priority
Communication (5)
Printer (2)
Time
0 5 10 15 20 25 30 35 40 45
45
2- I/O Function
• I/O module can exchange data directly with the processor
• In some cases it is desirable to allow I/O exchanges to occur directly with memor
• The processor grants to an I/O module the authority to read from or write to
memory so that the I/O memory transfer can occur without tying up the processor
• The I/O module issues read or write commands to memory relieving the processor
of responsibility for the exchange
• This operation is known as direct memory access (DMA).
46
fi
fi
.
Interconnection Structure
Computer Modules
47
O
Types of Transfers
• Memory to Processor
• The processor reads an instruction or a unit of data from memory
• Processor to Memory
• The processor writes unit of data to memory
• Processor to I/O
• The processor reads data from an I/O device via and I/O module
• I/O to Processor
• The processor sends data to the I/O device
48
:
49 :
Bus Interconnection
• A bus is a communication pathway connecting two or more device
• A key characteristic of a bus is that it is a shared transmission medium
• A bus consists of multiple pathways or lines
• Each line is capable of transmitting signal representing binary digit (1 or 0)
• For example, an 8-bit unit of data can be transmitted over eight bus lines
50
Bus Structure
• A system bus consists of 50-100 lines
51
s
fi
.
Data Lines
• Data lines that provide a path for moving data among system modules
• These lines, collectively, are called the data bus
• The data bus typically consist of 32, 64, 128, or more separate lines, the
number of lines is referred to as the width of the data bus
• Each line carry only 1 bit at a time, the number of lines determines how
many bits can transferred at a time - overall system performance.
• For example, if the data bus is 32 bits wide and each instruction is 64 bits long, then
the processor must access the memory module twice during each instruction cycle.
52
Address Lines
• Used to designate the source or destination of the data on the data bus
• If the processor wishes to read a word of data from memory it puts the address of
the desired word on the address lines
• For example, on an 8-bit address bus, address 01111111 and below might reference
locations in a memory module (module 0) with 128 words of memory, and address
10000000 and above refer to devices attached to an I/O module (module 1).
53
54
.
56
s