Professional Documents
Culture Documents
LECTURE 02 BS COAL NumberSystems July 2022
LECTURE 02 BS COAL NumberSystems July 2022
Language
BS Semester-III
Lecture-2:
Number Systems-I
JULY, 2022
Course Outlines: 2
Course Outlines:
Computer Arithmetic, Integer representation, integer arithmetic, floating-
point representation, floating-point arithmetic, Instruction Sets: Character-
istics and Functions Machine Instruction Characteristics, Types of Operands,
Pentium Data Types, Types of Operations, Instruction Sets: Addressing
Modes and Formats Addressing, Pentium Addressing Modes, Instruction
Formats, Pentium Instruction Formats, Introduction to Assembly Language
with debug, Structure of Assembly Language Programs and Flag Regis-
ter, Control Flow Instructions, Addressing Modes, Stack & Procedures, Bit
Manipulation Instructions, Macros, Interrupts, Multiplication and Division
Instructions.
2/70
Reference Books
Myths About Assembly Language 9
9/70
Myths About Assembly Language 10
9/70
Myths About Assembly Language 11
9/70
Myths About Assembly Language 12
9/70
Myths About Assembly Language 13
9/70
Myths About Assembly Language 14
9/70
Myths About Assembly Language 15
9/70
Myths About Assembly Language 16
9/70
Myths About Assembly Language 17
If you need more speed, you should use a better algorithm rather than
switch to assembly language.
9/70
Myths About Assembly Language 18
If you need more speed, you should use a better algorithm rather than
switch to assembly language.
Machines have so much memory today, saving space using assembly is not
important.
9/70
Myths About Assembly Language 19
If you need more speed, you should use a better algorithm rather than
switch to assembly language.
Machines have so much memory today, saving space using assembly is not
important.
9/70
What’s Right With Assembly Language? 20
10/70
Taken from CS429: Computer Organization and Architecture Introduction by Dr. Bill Young, thanks to him
Number Systems
Types of Number System
https://www.cuemath.com/numbers/number-systems/
Machine-Level Programming I 28
Machine-Level Programming
3 Note that there is no symbol for ”10” - or for the base of any
system.
15/70
Machine-Level Programming II 29
Example
1 4 6 5 0 9 3
6 5 4 3 2 1
10 10 10 10 10 10 100
16/70
Positional Notation -A History 30
17/70
Positional Notation 36
Positional Notation
4621 6= 1264
18/70
Positional Number Systems 37
19/70
Positional Number Systems 38
20/70
Positional Number Systems 39
m−1
X
D= di · b i .
i=−n
21/70
Positional Number Systems: Example 40
EXAMPLE:
The value of 245.378
D = 2 · 82 + 4 · 81 + 5 · 80 + 3 · 8−1 + 7 · 8−2
= 165.48437510
22/70
Positional Number Systems: Example 41
EXAMPLE:
Decorate a 43-year-old’s birthday cake with only three candles.
Light all three candles and read them as a base-6 number, i.e.
43 = 62 + 61 + 60
23/70
The Computer
Number System
The Computer Number System 43
25/70
Nibbles 48
Nibbles
A nibble is a collection of four bits.
Nibbles 49
Nibbles
A nibble is a collection of four bits.
It wouldn’t be a particularly interesting data structure except
for two items:
Nibbles 50
Nibbles
A nibble is a collection of four bits.
It wouldn’t be a particularly interesting data structure except
for two items:
1 BCD (binary coded decimal) numbers and
2 hexadecimal numbers
Nibbles 51
Nibbles
A nibble is a collection of four bits.
It wouldn’t be a particularly interesting data structure except
for two items:
1 BCD (binary coded decimal) numbers and
2 hexadecimal numbers
Nibbles
A nibble is a collection of four bits.
It wouldn’t be a particularly interesting data structure except
for two items:
1 BCD (binary coded decimal) numbers and
2 hexadecimal numbers
26/70
Bytes 53
Bytes
Bytes
Bytes
Bytes
Bytes
Bytes
27/70
Bytes: Two Nibbles 59
28/70
Words 60
29/70
Words 61
31/70
Double Words 63
32/70
Data Type 68
33/70
Examples: Binary Numbers 69
34/70
Binary Numbers Representation 72
Binary Representations
35/70
Decimal to Binary Conversion
Decimal to Binary Conversion 74
456710 :
2 4567 1
2 2283 1
2 1141 1
2 570 0
2 285 1
2 142 0
2 71 1 = 10001110101112
2 35 1
2 17 1
2 8 0
2 4 0
2 2 0
2 1 1
37/70
Decimal to Binary Conversion 75
100010 :
2 1000 0
2 500 0
2 250 0
2 125 1
2 62 0
= 11111010002
2 31 1
2 15 1
2 7 1
2 3 1
2 1 1
38/70
Binary to Decimal Conversion 76
100010012
1 · 20 = 1
0 · 21 = 0
0 · 22 = 0
1 · 23 = 8
0 · 24 = 0
0 · 25 = 0
0 · 26 = 0
1 · 27 = 128
137
39/70
Binary to Decimal Conversion 77
Binary to Decimal Conversion
1000100100100011110000010102
0 · 20 = 0
1 · 21 = 2
0 · 22 = 0
1 · 23 = 8
0 · 24 = 0
0 · 25 = 0
0 · 26 = 0
0 · 27 = 0
0 · 28 = 0
1 · 29 = 512
1 · 210 = 1024
1 · 211 = 2048
1 · 212 = 4096
0 · 213 = 0
0 · 214 = 0
0 · 215 = 0
1 · 216 = 65536
0 · 217 = 0
0 · 218 = 0
1 · 219 = 524288
0 · 220 = 0
0 · 221 = 0
1 · 222 = 4194304
0 · 223 = 0
0 · 224 = 0
0 · 225 = 0
1 · 226 = 67108864
71900682
40/70
Base 9 to Decimal Conversion 78
123456789
8 · 90 = 8
7 · 91 = 63
6 · 92 = 486
5 · 93 = 3645
4 · 94 = 26244
3 · 95 = 177147
2 · 96 = 1062882
1 · 97 = 4782969
6053444
41/70
Base 16 to Decimal Conversion 79
1234567816
8 · 160 = 8
7 · 161 = 112
6 · 162 = 1536
5 · 163 = 20480
4 · 164 = 262144
3 · 165 = 3145728
2 · 166 = 33554432
1 · 167 = 268435456
305419896
42/70
Base 16 to Decimal Conversion 80
F9A70B4672116
1 · 160 = 1
2 · 161 = 32
7 · 162 = 1792
6 · 163 = 24576
4 · 164 = 262144
B · 165 = 11534336
0 · 166 = 0
7 · 167 = 1879048192
A · 168 = 42949672960
9 · 169 = 618475290624
F · 1610 = 16492674416640
17155990251297
43/70
MSB & LSB 81
25 2
1 12 2
0 6 2
0 3 2
1 1
44/70
Converting Decimal to Binary 82
2 )179
2 )89 · · · · · · 1 LSB
2 )44 ······1
2 )22 ······0
2 )11 ······0
2 )5 ······1
2 )2 ······1
1 ······0
MSB
Thus, the final conversion result is
17910 = 101100112 .
45/70
A Few More Conversions I 83
100010 : 100010 :
2 1000 0
3 1000 1
2 500 0 3 333 0
2 250 0 3 111 0
2 125 1 3 37 1 = 11010013
2 62 0 3 12 0
= 11111010002
2 31 1 3 4 1
2 15 1 3 1 1
2 7 1
2 3 1
2 1 1
46/70
A Few More Conversions II 84
100010 : 100010 :
4 1000 0
5 1000 0
4 250 2 5 200 0
4 62 2 = 332204 5 40 0 = 130005
4 15 3 5 8 3
4 3 3 5 1 1
47/70
A Few More Conversions III 85
100010 : 100010 :
6 1000 4
7 1000 6
6 166 4 7 142 2
= 43446 = 26267
6 27 3
7 20 6
6 4 4 7 2 2
48/70
A Few More Conversions IV 86
100010 : 100010 :
8 1000 0
9 1000 1
8 125 5 9 111 3
= 17508 = 13319
8 15 7
9 12 3
8 1 1 9 1 1
49/70
A Few More Conversions V 87
100010 : 100010 :
10 1000 0
11 1000 10
10 100 0 11 90 2 = 82A11
= 100010
10 10 0 11 8 8
10 1 1
50/70
A Few More Conversions VI 88
100010 : 100010 :
12 1000 4 13 1000 12
12 83 11 = 6B412 13 76 11 = 5BC13
12 6 6 13 5 5
51/70
A Few More Conversions VII 89
100010 : 100010 :
14 1000 6 15 1000 10
14 71 1 = 51614 15 66 6 = 46A15
14 5 5 15 4 4
52/70
A Few More Conversions VIII 90
100010 : 102410 :
16 1000 8 2 1024 0
16 62 14 = 3E816 2 512 0
16 3 3 2 256 0
2 128 0
2 64 0
2 32 0 = 100000000002
2 16 0
2 8 0
2 4 0
2 2 0
2 1 1
53/70
A Few More Conversions IX 91
102410 : 656110 :
16 1024 0 3 6561 0
16 64 0 = 40016 3 2187 0
16 4 4 3 729 0
3 243 0
3 81 0 = 1000000003
3 27 0
3 9 0
3 3 0
3 1 1
54/70
A Few More Conversions X 92
100000010 :
111 1000000 1
111 9009 18 = 81.18.1.111
111 81 81
100000000010 :
111 1000000000 1
111 9009009 27
111 81162 21 = 6.65.21.27.1.111
111 731 65
111 6 6
55/70
A Few More Conversions XI 93
100000000010 :
7 1000000000 6
7 142857142 1
7 20408163 6
7 2915451 0
7 416493 0
7 59499 6 = 335316006167
7 8499 1
7 1214 3
7 173 5
7 24 3
7 3 3
56/70
Binary Radix (Base=2) Number System 94
57/70
Binary Radix (Base=2) Number System 95
57/70
Binary Radix (Base=2) Number System 96
57/70
Binary Radix (Base=2) Number System 97
57/70
Binary Radix (Base=2) Number System 98
110100102 = 1·27 +1·26 +0·25 +1·24 +0·23 +0·22 +1·21 +0·20 = 21010
1101.00112 = 1·23 +1·22 +0·21 +1·20 +0·2−1 +0·2−2 +1·2−3 +1·2−4 = 13.187510
2 57/70
Number Systems 99
58/70
Number Systems 100
58/70
Number Systems 101
58/70
Number Systems 102
One may then wonder that how base-64 numbers are expressed.
Fortunately, we rarely use such high-based numbers because we find
no real advantage of using them.
58/70
Number Systems 103
One may then wonder that how base-64 numbers are expressed.
Fortunately, we rarely use such high-based numbers because we find
no real advantage of using them.
58/70
Number Systems 104
59/70
Decimal-Octal 105
60/70
Conversion of 2k -Base Number
Systems
Conversion of 2k -Base Number Systems 107
m−1
X
D= di · b i .
i=−n
z }|{ z }|{ z }| {
AB .D16 = 1010 1011 . 11012
z}|{ z}|{ z}|{ z}|{ z}|{
= 010 101 011 . 110 1002
= 253.648
2
We have seen that the conversion between numbers with power of 2 radix
can be readily achieved through binary expression and regrouping of bits.
This convenience led to the utilization of hexadecimal (or octal) numbers
in representing binary numbers for many computer architecture related
issues.
General Positional Number System
Conversion
Base-k to Base-p Conversion 111
Using
m−1
X i
D = di · b .
i=−n
we can easily convert from any base to decimal by simply expressing the digits and weights
using decimal.
Example: Base-k to decimal conversion
3 2 1 0
1BE 816 = 1 · 16 + 11 · 16 + 14 · 16 + 8· = 714410
2 1 0 −1
437.58 = 4·8 +3·8 +7·8 +5·8 = 287.62510
2
66/70
Assignment 113
1 Convert the number 204510 into Binary, Octal, and Hexadecimal Numbers
68/70
References I 114
69/70
After all... tomorrow is another day.
(Scarlett O’Hara, “Gone with the Wind”)