COMP-261 Computer Organization and Assembly Language: Course Overview
COMP-261 Computer Organization and Assembly Language: Course Overview
Assembly Language
Course Overvie
Dr Hashim Al
Fall - 2021
1
i
• Lab Engineer
• Engr. Shahbaz Khan (ra .ullah@paf-iast.edu.pk
• Course Material
• MS Teams (class join invitation has been sent.)
2
:
fi
Course Management [2/4]
• Text Book/s
• William Stallings, "Computer Organization and Architecture", 10th edition, Pearson,
2016, ISBN: 978-0134101613
• Kip Irvine, “Assembly Language for x86 Processors”, 7th edition, Pearson, 2014, ISBN:
978-013376940
• Laboratory Softwares
• Intel 8086/88 Emulator (For Assembly Language)
• Logisim (http://www.cburch.com/logisim/) (For Digital Circuit Simulation)
• Microsoft Of ce and Visio (For documentation)
3
:
fi
1
• Lectures
• Monday 10:00 — 11:3
• Tuesday 10:00 — 11:3
• Of ce Hours
• Friday 02:00 — 03:3
• Venue
• Lecture Hall: A1-30
• Laboratory: A1-301
4
fi
:
• Late Work
• Laboratory reports must be submitted at the end of each lab
• The penalty for any late work is 20% OFF for the rst date and an additional 30% OFF for the second day. No work will be accepted
thereafter.
5
:
fi
.
Course Goals
• Course Objective
• To introduce the internal working and organization of various building blocks of a digital computer as
well as simple assembly language programming techniques. Upon completion of this course, the
student will have basic understanding of computer system architecture including CPU design, memory
subsystem design and performance enhancement techniques
6
:
fi
Course Outline
• Difference between Architecture and Organizatio
• Introduction to superscalar processors (RISC, CISC
• Introduction to MIPS Assembl
• Design of various parts of computer system and component
• CPU Architecture (Instruction Set Architecture—ISA
• AND, OR, ADD, SUB, ANDi, ORi, ADDi, SUBi, SLT, BEQ, Jump etc
• Processor Design — Single Cycle, Multi-cycl
• Functional Blocks (PC, IR, CU, ALU, Memory etc.
• Instruction set design (Register-to-Register, Memory-reference, Control
• Addressin
• Control structures (BEQ, J
• Memory hierarchies and its managemen
• Design of Cache memory syste
• Interrupts and I/O Structure
• Pipelining — Issues, hurdles, exception handling, branch prediction etc
• Introduction to parallel processing
7
g
Lecture
Digital Logic Design — Revie
Dr Hashim Al
Fall - 2021
8
1
Lecture Outline
• Number System • Computer Arithmeti • Digital Logi
• The Decimal Syste • The Arithmetic and • Boolean Algebr
• Positional Number Logic Uni • Gate
Syste • Integer • Combinational
• The Binary Syste Representation (Sign- Circuit
• Conversion between magnitude, 2’s • Sequential Circuit
Binary and Decima Complement • Programmable Logic
• Hexadecimal • Integer Arithmetic Devices
Notation
Homework
CH-9,10,11 William Stallings
9
s
Digital Systems
• The General-Purpose Digital Computer is the best-known example of a digital systems
• The major parts of a computer are a memory unit, a central processing unit, and input-output units.
Control Unit
Instruction
Program Program
Input Unit Memory Unit Output Unit
Data Result
Data
ALU Unit
10
Typical System Architecture
• Most large digital systems consist of
• Datapat
• Arithmetic units (adders, multipliers
• Data-steering (multiplexers
• Memor
• Places to store data across clock cycle
• Memories, register les, etc
• Contro
• Interacting nite state machine
• Direct how the data moves through the datapath
11
l
fi
fi
.
12
Computer Arithmetic
Chapter — 10
13
Arithmetic & Logic Unit
• Part of the computer that actually performs arithmetic and logical
operations on data
• All of the other elements of the computer system are there mainly to bring
data into the ALU for it to process and then to take the results back out
• Based on the use of simple digital logic devices that can store binary digits
and perform simple Boolean logic operations.
14
.
Control
Signals Flags
ALU
Operand Result
Registers Registers
15
Integer Representation
• In the binary number system arbitrary numbers can be represented
with:
• The digits zero and on
• The minus sign (for negative numbers
• The period, or radix point (for numbers with a fractional
component
16
fi
Add additional bit positions to the left and ll in with the value of
Expansion of Bit Length
the original sign bit.
If two numbers with the same sign (both positive or both negative)
Over ow Rule are added, then over ow occurs if and only if the result has the
opposite sign.
To subtract B from A, take the twos complement of B and add it to
Subtraction Rule
A.
17
fl
fl
fi
Addition — with Over ow Discard carry
5+4=? (-7) + (-6) = ?
0101 = 5 1001 = -7
+ 0100 = 4 + 1010 = -6
1001 = Over ow 1 0011 = Over ow
18
fl
fl
Subtraction — with Over ow
7 - (-7) = ? -6-4=?
Minuend (M) = 7 = 0111 Minuend (M) = 1010 = -6
Subtrahend (S) = -7 = 1001 Subtrahend (S) = 0100 = 4
Negation (-S) = 0111 Negation (-S) = 1100
Discard carry
0111 = 7 1010 = -6
+ 0111 = 7 + 1100 = -4
1110 = Over ow 1 0110 = Over ow
Complementer
SW
OF Adder
OF = overflow bit
SW = Switch (select addition or subtraction)
21
Boolean Algebra
• Mathematical discipline used to design and analyse the behaviour of the digital
circuitry in digital computers and other digital systems
• Is a convenient tool
• Analysi
• It is an economical way of describing the function of digital circuitry
• Desig
• Given a desired function, Boolean algebra can be applied to develop a
simpli ed implementation of that function.
22
n
fi
s
23
An interconnected set of
gates whose output at any
24
Boolean Function of Three Variables
A B C F
0 0 0 0
0 0 1 0
0 1 0 1
0 1 1 1
1 0 0 0
1 0 1 0
1 1 0 1
1 1 1 0
Table 11.3 A Boolean Function of Three Variables
25
Product-of-Sums Implementation
A
B
C
A
B
C
A
B F
C
A
B
C
A
B
C
26
Sum-of-Products Implementation
27
Algebraic Simpli cation
• Involves the application of the identities to reduce the Boolean expression
to one with fewer elements.
A
C
F
B
28
NAND and NOR Implementations
A
B
B
C
29
Multiplexers
• connect multiple inputs to a single output
D0
D1 4-to-1
multiplexer F
D2
D3
S2 S1
30
Decoders A
B
000
D0
001
D1
100
D4
101
D5
110
D6
111
D7
32
s
F
F
F
F
fi
.
fi
:
33
)
34
4-Bit Adder
A3 B3 A2 B2 A1 B1 A0 B0
Overflow
signal C3 Cin C2 Cin C1 Cin C0 Cin 0
S3 S2 S1 S0
35
Construction of a 32-Bit Adder Using 8-Bit Adders
A31 B31 A31 B31 A23 B23 A16 B16 A15 B15 A8 B8 A7 B7 A0 B0
C23 C15 C7
Cout 8-bit 8-bit 8-bit 8-bit Cin
adder adder adder adder
36
Sequential Circuit
Current output
depends not only
on the current
input, but also on
the past history
of inputs
Sequential
Circuit
Makes use of
combinational
circuits
37
Flip-Flops
• Simplest form of sequential circui
• There are a variety of ip- ops, all
of which share two properties
• The ip- op is a bistable device.
It exists in one of two states and,
in the absence of input, remains
in that state. Thus, the ip- op
can function as a 1-bit memory
• The ip- op has two outputs,
which are always the
complements of each other.
38
fl
fl
fl
fl
fl
fl
fl
fl
:
S Q S
Truth Table
R Qn+1
0 0 Qn
S-R Ck 0 1 0
1 0 1
R Q 1 1 –
J Q J K Qn+1
0 0 Qn
J-K Ck 0 1 0
1 0 1
K Q 1 1 Qn
D Q D Qn+1
0 0
D Ck 1 1
39
Parallel Register
Data lines
D Q D Q D Q D Q D Q D Q D Q D Q
Clock
Load
Output lines
Clock
41
Counter
• A register whose value is easily incremented by 1 modulo the capacity of the
registe
• After the maximum value is achieved the next increment sets the counter value to
• An example of a counter in the CPU is the program counte
• Can be designated as:
• Asynchronou
• Relatively slow because the output of one ip- op triggers a change in the status
of the next ip- o
• Synchronou
• All of the ip- ops change state at the same tim
• Because it is faster it is the kind used in CPUs
42
r
fl
fl
s
fl
fl
p
fl
C B A Jc Kc Jb Kb Ja Ka
0 0 0 0 d 0 d 1 d
0 0 1 0 d 1 d d 1
0 1 0 0 d d 0 1 d
(a) Truth table 0 1 1 1 d d 1 d 1
1 0 0 d 0 0 d 1 d
1 0 1 d 0 1 d d 1
1 1 0 d 0 d 0 1 d
1 1 1 d 1 d 1 d 1
BA BA
(b) Karnaugh maps 00 01 11 10 00 01 11 10
0 1 0 d d d d
Jc = BA C Kc = BA C
1 d d d d 1 1
Design of a 0
00 01
1
BA
11
d
10
d 0
00
d
01
d
BA
11
1
10
Synchronous
Jb = A C Kb = A C
1 1 d d 1 d d 1
BA BA
00 01 11 10 00 01 11 10
Counter Ja = 1 C
0
1
1
1
d
d
d
d
1
1
Ka = 1 C
0
1
d
d
1
1
1
1
d
High Ja A Jb B Jc C C B A
binary
output
Ck Ck Ck
Ka A Kb B Kc C
Clock
44
Adder Circuit
• Perform bit by bit addition —
similar to the “paper and
pencil” way
45
Subtraction Circuit
• Use the formula
• X - Y = X + Y’ + 1
46
:
47
Logical Operations
48
Logical Operations: AND, OR
• MIPS logical instructions require bit by bit operation on 32 bit string
• AN
0010 1011 1100 0110 1111 0000 0101 100
0000 1111 0000 1111 0000 1111 0000 111
———————————————————
0000 1011 0000 0110 0000 0000 0000 100
•O
0010 1011 1100 0110 1111 0000 0101 100
0000 1111 0000 1111 0000 1111 0000 111
———————————————————
0010 1111 1100 1111 1111 1111 0101 1111
49
R
50
Combining AND, OR,
ADD, SUB — ALU
51
Over o
Comparing Two Integers
52
fl
w
Assignment —
Deadline 4th October, 2021
• Submission
• Hard copy containing all necessary work to do the assignment
• Prove accurate working off the design by using some random inputs.
53
:
54
Extending ALUi for Comparison (slt)
55
ALU for AND, OR,
ADD, SUB, BEQ, SLT
56
n
Assignment —
Deadline 11th October, 2021
57
Multiplier Design
58
Multiplication — ‘Paper Pencil’ Method
M 0 1 Multiplication of Unsigned
Binary Numbers [3 and 5]
Q 1 0 Multiplier Logic
Initialisation
———
A+M 0 0 0 0 0
0 1
Shift by 1 0 0 0 1 1
0 0 0
Shift by 2 0 0 0 1 1
0 1 1 x
—————
0 1 1 1 1 Partial
MxQ 0 1 1 1 1
Product
59
x
60
Flowchart for Unsigned
Binary Multiplication
61
Booth’s Algorith
Signed Binary Multiplication
A Q Q-1 M
0000 0011 0 0111 Initial Values
Fourth
0001 0101 0 0111 Shift
Cycle
62
m
Divider Design
63
Division: Example
0011 Q - Quotient
0100 00001101 A - Dividend
0000 0 x M x 23 Apply subtraction
0001101
M - Divisor 0000 0 x M x 22
001101
0100 1 x M x 21
00101
Partial
0101 1 x M x 20
Reminders
0001 R
64
Divider Design
+/
65
Flowchart for
Unsigned
Binary
Division
66
Restoring Division — Example (12/3)
M=0011, M’+1=1101
Comment A Q Comment A Q
Initial 0000 110
1- Shift Left 0001 100 3- Shift Left 0000 001x
111 1101
111 1101
000 1101
110
To nd Reminder
001
Restore A←A+M
0000 Quotient
68
Reminder
fi
1
• Convention
• Dividend and reminder have the same sig
• Quotient is negative if signs disagre
• These rules ful l the equation above
69
:
fi
1
70
Shift Operations
71
Shift Operations — Logical
Shift left logical 3 bits Shift right logical 3 bits
72
Circuit for Shifting by 2 bits
73
Circuit for Shifting by 0 to 31 bits
74
Shift Operations — Arithmetic
a31 a30 …… a1 a0
75