Download Computer Organization Lecture 2 Section 1.2 Robb T. Koether

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts

Computer science wikipedia , lookup

Emulator wikipedia , lookup

Manchester Mark 1 wikipedia , lookup

Transcript
Computer Organization
Lecture 2
Section 1.2
Robb T. Koether
Hampden-Sydney College
Fri, Aug 30, 2013
Robb T. Koether (Hampden-Sydney College)
Computer Organization
Fri, Aug 30, 2013
1 / 28
1
The Main Components
2
Storing Numbers
Binary Numbers
Hexadecimal Numbers
Converting Between Binary and Hexadecimal
3
Assignment
Robb T. Koether (Hampden-Sydney College)
Computer Organization
Fri, Aug 30, 2013
2 / 28
Outline
1
The Main Components
2
Storing Numbers
Binary Numbers
Hexadecimal Numbers
Converting Between Binary and Hexadecimal
3
Assignment
Robb T. Koether (Hampden-Sydney College)
Computer Organization
Fri, Aug 30, 2013
3 / 28
The Main Components
The Central Processing Unit (CPU)
Memory
Input devices
Output devices
Robb T. Koether (Hampden-Sydney College)
Computer Organization
Fri, Aug 30, 2013
4 / 28
The CPU
The central processing unit (CPU).
The register bank.
The arithmetic and logic unit (ALU).
The branch unit.
The memory read/write unit.
The control unit.
Robb T. Koether (Hampden-Sydney College)
Computer Organization
Fri, Aug 30, 2013
5 / 28
The CPU
The CPU:
Performs arithmetic.
Addition, subtraction, logical operations, etc.
Makes logical decisions.
Branch if two values are equal, etc.
Loads data from memory to registers.
Stores data from registers to memory.
Robb T. Koether (Hampden-Sydney College)
Computer Organization
Fri, Aug 30, 2013
6 / 28
Memory
Levels of memory.
Registers (in the CPU).
Level 1 Cache (L1)
Holds commonly used data.
“10% of the data is used 90% of the time.”
Level 2 Cache (L2)
Holds less commonly used data.
Main Memory
Holds data that are “seldom” used.
Robb T. Koether (Hampden-Sydney College)
Computer Organization
Fri, Aug 30, 2013
7 / 28
Outline
1
The Main Components
2
Storing Numbers
Binary Numbers
Hexadecimal Numbers
Converting Between Binary and Hexadecimal
3
Assignment
Robb T. Koether (Hampden-Sydney College)
Computer Organization
Fri, Aug 30, 2013
8 / 28
Representing Data
How can a machine “store” a number?
We design a machine that can be put into different “states.”
Each state represents a value.
For example, the values 0 through 9 may be represented by 10
different states.
Robb T. Koether (Hampden-Sydney College)
Computer Organization
Fri, Aug 30, 2013
9 / 28
Representation of Data
How could we represent the values 0 through 99?
Robb T. Koether (Hampden-Sydney College)
Computer Organization
Fri, Aug 30, 2013
10 / 28
Representation of Data
How could we represent the values 0 through 99?
Build a machine with 100 states.
Robb T. Koether (Hampden-Sydney College)
Computer Organization
Fri, Aug 30, 2013
10 / 28
Representation of Data
How could we represent the values 0 through 99?
Build a machine with 100 states.
Or, build two machines with 10 states each.
One machine represents the 1’s digit.
The other machine represents the 10’s digit.
With six 10-state machines, we could represent values from 0 to
999999.
Robb T. Koether (Hampden-Sydney College)
Computer Organization
Fri, Aug 30, 2013
10 / 28
Binary Representation of Data
In computers, it is more efficient to use only two states.
A light: on/off
A switch: open/closed
Voltage: high/low
Therefore, numbers will be stored in binary rather than decimal.
Robb T. Koether (Hampden-Sydney College)
Computer Organization
Fri, Aug 30, 2013
11 / 28
Outline
1
The Main Components
2
Storing Numbers
Binary Numbers
Hexadecimal Numbers
Converting Between Binary and Hexadecimal
3
Assignment
Robb T. Koether (Hampden-Sydney College)
Computer Organization
Fri, Aug 30, 2013
12 / 28
Binary Representation of Data
With 1 bit, we can represent 2 different values, namely 0 and 1.
With 2 bits, we can represent 4 different values, namely 0 through
3.
Pattern
00
01
10
11
Robb T. Koether (Hampden-Sydney College)
Value
0
1
2
3
Computer Organization
Fri, Aug 30, 2013
13 / 28
Binary Representation of Data
With 3 bits, we can represent 8 values, namely 0 through 7.
Pattern
000
001
010
011
100
101
110
111
Robb T. Koether (Hampden-Sydney College)
Value
0
1
2
3
4
5
6
7
Computer Organization
Fri, Aug 30, 2013
14 / 28
Negative Numbers
If we wanted to represent negative numbers using 2 bits, we could
represent −2 through +1.
Pattern
00
01
10
11
Robb T. Koether (Hampden-Sydney College)
Value
0
1
−2
−1
Computer Organization
Fri, Aug 30, 2013
15 / 28
Negative Numbers
With 3 bits, we can represent −4 through +3.
Pattern
000
001
010
011
100
101
110
111
Robb T. Koether (Hampden-Sydney College)
Value
0
1
2
3
−4
−3
−2
−1
Computer Organization
Fri, Aug 30, 2013
16 / 28
Fixed-Length Binary Numbers
In general, n bits can represent any of 2n different values, ranging
from 0 to 2n − 1.
4 bits represent values from 0 to 15.
8 bits represent values from 0 to 255.
16 bits represent values from 0 to 65535, etc.
Or we can represent signed numbers from −2n−1 to 2n−1 − 1.
16 bits represent values −32768 to +32767.
32 bits represent values −2147483648 to +2147483647.
Robb T. Koether (Hampden-Sydney College)
Computer Organization
Fri, Aug 30, 2013
17 / 28
Binary Number System
In the binary number system, each position in the number
represents a power of 2.
Example: 101011 represents
(1 × 25 ) + (0 × 24 ) + (1 × 23 ) + (0 × 22 ) + (1 × 21 ) + (1 × 20 )
which equals 32 + 8 + 2 + 1 = 43.
Robb T. Koether (Hampden-Sydney College)
Computer Organization
Fri, Aug 30, 2013
18 / 28
The Structure of Memory
1 bit = 1 binary digit (0 or 1).
1 half-byte (nibble) = 4 bits.
1 byte = 2 nibbles = 8 bits.
1 half-word = 2 bytes = 16 bits.
1 word = 4 bytes = 32 bits (standard size).
1 kilobyte (Kb) = 1024 bytes = 210 bytes.
1 megabyte (Mb) = 1024 K = 220 bytes.
1 gigabyte (Gb) = 1024 M = 230 bytes.
1 terabyte (Tb) = 1024 T = 240 bytes.
Robb T. Koether (Hampden-Sydney College)
Computer Organization
Fri, Aug 30, 2013
19 / 28
Outline
1
The Main Components
2
Storing Numbers
Binary Numbers
Hexadecimal Numbers
Converting Between Binary and Hexadecimal
3
Assignment
Robb T. Koether (Hampden-Sydney College)
Computer Organization
Fri, Aug 30, 2013
20 / 28
Hexadecimal Numbers
For convenience, we often display values in hexadecimal (base
16).
The hexadecimal system has 16 digits with values 0 through 15.
Digit
0
1
2
3
4
5
6
7
Robb T. Koether (Hampden-Sydney College)
Value
0
1
2
3
4
5
6
7
Digit
8
9
A
B
C
D
E
F
Computer Organization
Value
8
9
10
11
12
13
14
15
Fri, Aug 30, 2013
21 / 28
Examples of Hexadecimal Numbers
4A16 = (4 × 16) + 10 = 74,
FF16 = (15 × 16) + 15 = 255,
12316 = (1 × 162 ) + (2 × 16) + 3 = 292,
FACE16 = (15 × 163 ) + (10 × 162 ) + (12 × 16) + 14
= 61440 + 2560 + 192 + 14
= 64206.
Robb T. Koether (Hampden-Sydney College)
Computer Organization
Fri, Aug 30, 2013
22 / 28
Hexadecimal Numbers
Hexadecimal numbers are convenient because
They are compact.
There is a very simple relation between them and binary numbers.
One hexadecimal digit represents a 4-digit binary number (values 0
- 15), or half a byte.
Robb T. Koether (Hampden-Sydney College)
Computer Organization
Fri, Aug 30, 2013
23 / 28
Outline
1
The Main Components
2
Storing Numbers
Binary Numbers
Hexadecimal Numbers
Converting Between Binary and Hexadecimal
3
Assignment
Robb T. Koether (Hampden-Sydney College)
Computer Organization
Fri, Aug 30, 2013
24 / 28
Conversion from Hexadecimal to Binary
Convert 2B6F to binary
Write each hex digit as a 4-bit binary number.
2 = 0010
B = 1011
6 = 0110
F = 1111
Write the 4-bit numbers together as a single binary number
0010101101101111
Robb T. Koether (Hampden-Sydney College)
Computer Organization
Fri, Aug 30, 2013
25 / 28
Conversion from Binary to Hexadecimal
Convert 1001101011101011 to hexadecimal.
Break it up into groups of 4 bits (starting on the right).
1001 1010 1110 1011
Write each block of 4 bits as a hex digit.
9
A
E
B
Write the hex digits as a single hex number.
9AEB
Robb T. Koether (Hampden-Sydney College)
Computer Organization
Fri, Aug 30, 2013
26 / 28
Outline
1
The Main Components
2
Storing Numbers
Binary Numbers
Hexadecimal Numbers
Converting Between Binary and Hexadecimal
3
Assignment
Robb T. Koether (Hampden-Sydney College)
Computer Organization
Fri, Aug 30, 2013
27 / 28
Assignment
Homework
Read Sections 1.2.
Robb T. Koether (Hampden-Sydney College)
Computer Organization
Fri, Aug 30, 2013
28 / 28