Lecture 1 - ODU Computer Science
Download
Report
Transcript Lecture 1 - ODU Computer Science
CS170 Computer Organization
and Architecture I
Ayman Abdel-Hamid
Department of Computer Science
Old Dominion University
Lecture 1: 8/27/2002
Lecture 1: 8/27/2002
CS170 Fall 2002
1
Outline
•What is a computer?
•An overview of number systems
•Decimal
•Binary
•Octal
•Hexadecimal
Lecture 1: 8/27/2002
CS170 Fall 2002
2
A Computer
Input
Tapes
Keyboard
Mouse
scanner
Processor
Memory
Five classic components of a computer:
Output
Display
Paper
Processor
Input, Output, Memory, Data path, Control
Lecture 1: 8/27/2002
CS170 Fall 2002
3
Computers are built on two key principles
•Both instructions and data are represented by numbers
•Instructions and data are stored in memory and are read
and written as numbers
All computers use the binary number system (base 2)
(basic nature of electronic circuits ON/OFF, current flow/does
not flow)
Machine alphabet has two letters “0”, “1”
Each letter is a binary digit “bit”. Byte is 8 bits
Lecture 1: 8/27/2002
CS170 Fall 2002
4
Number Systems
Numbers can be represented in any base (humans use base 10)
•Symbols for a number system of base B are 0, 1, 2, …, B –1
•decimal (base 10) 0, 1, 2, .., 9
binary (base 2) 0, 1
•notation “numberB” (375 in decimal is written 37510, 1011 in binary is written 10112)
•Value of ith digit d is “d * Bi” where i starts from 0 and increases from right to left
210
i
375
d
5 * 100
=
5
7 * 101
=
70
3 * 102
=
300
Lecture 1: 8/27/2002
positional notation
CS170 Fall 2002
Three hundred and
seventy five
5
Conversion from binary to decimal
Convert 10112 to decimal
3210i
1011d
= (1 * 20) + (1 * 21) + (0 * 22) + (1 *23)
=1+2+0+8
= 1110
This process can be used for conversion from any number
system to decimal (TRY convert 1238 to decimal)
Lecture 1: 8/27/2002
CS170 Fall 2002
6
Conversion from decimal to binary
Step 1: divide value by 2 and record remainder
Step 2: as long as quotient not zero, continue to divide the newest quotient by 2
and record the remainder
Step 3: when obtain a zero as quotient, binary representation consists of
remainders listed from right to left in order
Convert 1310 to binary
Operation
Quotient
remainder
13 by 2
6
1
6 by 2
3
0
3 by 2
1
1
1 by 2
0
1
1310 = 11012
Lecture 1: 8/27/2002
CS170 Fall 2002
7
Conversion from decimal to binary
Previous approach can be used to convert from decimal to any number system
Convert 1310 to octal (octal is base 8)
Operation
Quotient
remainder
13 by 8
1
5
1 by 8
0
1
1310 = 158
158= (5 * 80) + (1 * 81) = 1310
Lecture 1: 8/27/2002
CS170 Fall 2002
8
Other Number Systems
•Octal (base 8)
Symbols (0, 1, 2, 3, 4, 5, 6, 7)
•Working with too long binary numbers is a problem
•Hexadecimal (base 16)
Symbols (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F)
•Byte = 8 bits = 2 hex digits ( 1 hex digit is 4 bits)
Lecture 1: 8/27/2002
CS170 Fall 2002
9
Conversion from binary to hex
Convert 11010011102 to hex
Divide binary number into 4 bits groups from right to left
1101001110
11
316
Lecture 1: 8/27/2002
0100
1110
416
E16
CS170 Fall 2002
34E16
10
Decimal
Binary
Hexadecimal
0
0000
0
1
0001
2
20 = 1
27 = 128
1
21 = 2
28 = 256
0010
2
22 = 4
29 = 512
3
0011
3
4
0100
4
23 = 8
210 = 1024
5
0101
5
24 = 16
211 = 2048
6
0110
6
7
0111
7
25 = 32
212 = 4096
8
1000
8
26 = 64
213 = 8190
9
1001
9
10
1010
A
11
1011
B
12
1100
C
13
1101
D
14
1110
E
15
1111
F
Lecture 1: 8/27/2002
210
Tera
240
Mega 220
Peta
250
Kilo
Giga
CS170 Fall 2002
230
11