arsitektur komputer - yogi.blog.unsoed.ac.id · chapter 2 number systems 2-11 aritmatika desimal...

45
Arsitektur Komputer Pertemuan ke-2 - Aritmatika Komputer >>> Sistem bilangan & Format Data - Perkembangan Perangkat Keras Komputer

Upload: nguyenliem

Post on 28-Mar-2019

221 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Arsitektur Komputer - yogi.blog.unsoed.ac.id · Chapter 2 Number Systems 2-11 Aritmatika Desimal atau basis 10 Asal: perhitungan menggunakan jari “Digit” berasal dari bahasa Latin

Arsitektur KomputerPertemuan ke-2

- Aritmatika Komputer

>>> Sistem bilangan & Format Data

- Perkembangan Perangkat Keras Komputer

Page 2: Arsitektur Komputer - yogi.blog.unsoed.ac.id · Chapter 2 Number Systems 2-11 Aritmatika Desimal atau basis 10 Asal: perhitungan menggunakan jari “Digit” berasal dari bahasa Latin

ARITMATIKA KOMPUTER

Materi :

Englander, bab 2 dan 3

Stallings, bab 8

IEEE 754 pada website IEEE

Page 3: Arsitektur Komputer - yogi.blog.unsoed.ac.id · Chapter 2 Number Systems 2-11 Aritmatika Desimal atau basis 10 Asal: perhitungan menggunakan jari “Digit” berasal dari bahasa Latin

Chapter 2 Number Systems 2-3

Komputer sistem biner

Tanya kenapa?

Desain komputer terdahulu : desimal

◦ Mark I and ENIAC

John von Neumann mengusulkan

pemrosesan data biner (1945)

◦ Desain komputer yang lebih sederhana

◦ Digunakan u/ instruksi dan data

Hubungan alami antara

switch on/off dan kalkulasi

menggunakan logika Boolean

On Off

True False

Yes No

1 0

Page 4: Arsitektur Komputer - yogi.blog.unsoed.ac.id · Chapter 2 Number Systems 2-11 Aritmatika Desimal atau basis 10 Asal: perhitungan menggunakan jari “Digit” berasal dari bahasa Latin

Biner : Representasi Integer

Hanya memiliki 1 dan 0 untuk

merepresentasikan semuanya

Angka positif disimpan dalam biner

◦ e.g. 41=00101001

Tidak ada tanda negatif

◦ Sign-Magnitude

Two’s compliment

Page 5: Arsitektur Komputer - yogi.blog.unsoed.ac.id · Chapter 2 Number Systems 2-11 Aritmatika Desimal atau basis 10 Asal: perhitungan menggunakan jari “Digit” berasal dari bahasa Latin

Sign-Magnitude

Bit paling kiri bit penanda

0 = positif

1 = negatif

+18 = 00010010

-18 = 10010010

Masalah◦ Perlu mempertimbangkan kedua tanda

dan besaran dalam aritmatika

◦ Dua representasi “nol” (+0 dan -0)

Page 6: Arsitektur Komputer - yogi.blog.unsoed.ac.id · Chapter 2 Number Systems 2-11 Aritmatika Desimal atau basis 10 Asal: perhitungan menggunakan jari “Digit” berasal dari bahasa Latin

Komplemen Dua

+3 = 00000011

+2 = 00000010

+1 = 00000001

+0 = 00000000

-1 = 11111111

-2 = 11111110

-3 = 11111101

Page 7: Arsitektur Komputer - yogi.blog.unsoed.ac.id · Chapter 2 Number Systems 2-11 Aritmatika Desimal atau basis 10 Asal: perhitungan menggunakan jari “Digit” berasal dari bahasa Latin

Keuntungan

Satu representasi “nol” (00000000)

Perhitungan aritmatika lebih mudah

Cukup mudah menegatifkan

◦ 3 = 00000011

◦ Boolean complement : 11111100

◦ Add 1 to LSB : 11111101

Page 8: Arsitektur Komputer - yogi.blog.unsoed.ac.id · Chapter 2 Number Systems 2-11 Aritmatika Desimal atau basis 10 Asal: perhitungan menggunakan jari “Digit” berasal dari bahasa Latin

Geometric Depiction of Twos

Complement Integers

Page 9: Arsitektur Komputer - yogi.blog.unsoed.ac.id · Chapter 2 Number Systems 2-11 Aritmatika Desimal atau basis 10 Asal: perhitungan menggunakan jari “Digit” berasal dari bahasa Latin

Negation Special Case 1

0 = 00000000

Bitwise not 11111111

Add 1 to LSB +1

Result 1 00000000

Overflow is ignored, so:

- 0 = 0

Page 10: Arsitektur Komputer - yogi.blog.unsoed.ac.id · Chapter 2 Number Systems 2-11 Aritmatika Desimal atau basis 10 Asal: perhitungan menggunakan jari “Digit” berasal dari bahasa Latin

Range of Numbers

8 bit 2s compliment

◦ +127 = 01111111 = 27 -1

◦ -128 = 10000000 = -(27)

16 bit 2s compliment

◦ +32767 = 011111111 11111111 = 215 - 1

◦ -32768 = 100000000 00000000 = -215

Page 11: Arsitektur Komputer - yogi.blog.unsoed.ac.id · Chapter 2 Number Systems 2-11 Aritmatika Desimal atau basis 10 Asal: perhitungan menggunakan jari “Digit” berasal dari bahasa Latin

Chapter 2 Number Systems

2-

11

Aritmatika

Desimal atau basis 10◦ Asal: perhitungan menggunakan jari◦ “Digit” berasal dari bahasa Latin digitus yang

artinya “jari”

Base / Basis : angka pada beberapa digit yang berbeda termasuk nol◦ Contoh : Basis 10 10 digit, 0 sampai 9

Binary basis 2 Bit (binary digit): 2 digit, 0 dan 1 Octal atau basis 8: 8 digit, 0 sampai 7 Hexadecimal atau basis 16:

16 digits, 0 sampai F◦ Examples: 1010 = A16; 1110 = B16

Page 12: Arsitektur Komputer - yogi.blog.unsoed.ac.id · Chapter 2 Number Systems 2-11 Aritmatika Desimal atau basis 10 Asal: perhitungan menggunakan jari “Digit” berasal dari bahasa Latin

Chapter 2 Number Systems

2-

12

“Keeping Track of the Bits”

“Bit” umumnya disimpan dan

dimanipulasi pada suatu grup:

◦ 8 bits = 1 byte

◦ 4 bytes = 1 word

Jumlah bit yang digunakan :

◦ Mempengaruhi akurasi hasil

◦ Membatasi ukuran angka yang bisa

dimanipulasi oleh komputer

Page 13: Arsitektur Komputer - yogi.blog.unsoed.ac.id · Chapter 2 Number Systems 2-11 Aritmatika Desimal atau basis 10 Asal: perhitungan menggunakan jari “Digit” berasal dari bahasa Latin

Chapter 2 Number Systems 2-13

Angka : Representasi Fisik

Jumlah jeruk yang sama dengan angka yang berbeda◦ Cave dweller: IIIII

◦ Roman: V

◦ Arabic: 5

Basis berbeda, namun jumlah sama◦ 510

◦ 1012

◦ 123

Page 14: Arsitektur Komputer - yogi.blog.unsoed.ac.id · Chapter 2 Number Systems 2-11 Aritmatika Desimal atau basis 10 Asal: perhitungan menggunakan jari “Digit” berasal dari bahasa Latin

Chapter 2 Number Systems

2-

14

Number System

Roman: position independent

Modern: based on positional notation (place value)◦ Decimal system: system of positional notation

based on powers of 10.

◦ Binary system: system of positional notation based powers of 2

◦ Octal system: system of positional notation based on powers of 8

◦ Hexadecimal system: system of positionalnotation based powers of 16

Page 15: Arsitektur Komputer - yogi.blog.unsoed.ac.id · Chapter 2 Number Systems 2-11 Aritmatika Desimal atau basis 10 Asal: perhitungan menggunakan jari “Digit” berasal dari bahasa Latin

Chapter 2 Number Systems

2-

15

Positional Notation: Base 10

Place 101 100

Value 10 1

Evaluate 4 x 10 3 x1

Sum 40 3

1’s place10’s place

43 = 4 x 101 + 3 x 100

Page 16: Arsitektur Komputer - yogi.blog.unsoed.ac.id · Chapter 2 Number Systems 2-11 Aritmatika Desimal atau basis 10 Asal: perhitungan menggunakan jari “Digit” berasal dari bahasa Latin

Chapter 2 Number Systems

2-

16

Positional Notation: Base 10

Place 102 101 100

Value 100 10 1

Evaluate 5 x 100 2 x 10 7 x1

Sum 500 20 7

1’s place10’s place

527 = 5 x 102 + 2 x 101 + 7 x 100

100’s place

Page 17: Arsitektur Komputer - yogi.blog.unsoed.ac.id · Chapter 2 Number Systems 2-11 Aritmatika Desimal atau basis 10 Asal: perhitungan menggunakan jari “Digit” berasal dari bahasa Latin

Chapter 2 Number Systems

2-

17

Positional Notation: Octal

6248 = 40410

Place 82 81 80

Value 64 8 1

Evaluate 6 x 64 2 x 8 4 x 1

Sum for

Base 10 384 16 4

64’s place 8’s place 1’s place

Page 18: Arsitektur Komputer - yogi.blog.unsoed.ac.id · Chapter 2 Number Systems 2-11 Aritmatika Desimal atau basis 10 Asal: perhitungan menggunakan jari “Digit” berasal dari bahasa Latin

Chapter 2 Number Systems

2-

18

Positional Notation: Hexadecimal

6,70416 = 26,37210

Place 163 162 161 160

Value 4,096 256 16 1

Evaluate 6 x

4,096

7 x 256 0 x 16 4 x 1

Sum for

Base 1024,576 1,792 0 4

4,096’s place 256’s place 1’s place16’s place

Page 19: Arsitektur Komputer - yogi.blog.unsoed.ac.id · Chapter 2 Number Systems 2-11 Aritmatika Desimal atau basis 10 Asal: perhitungan menggunakan jari “Digit” berasal dari bahasa Latin

Chapter 2 Number Systems 2-19

Positional Notation: Binary

Place 27 26 25 24 23 22 21 20

Value 128 64 32 16 8 4 2 1

Evaluate 1 x 128 1 x 64 0 x 32 1 x16 0 x 8 1 x 4 1 x 2 0 x 1

Sum for

Base 10128 64 0 16 0 4 2 0

1101 01102 = 21410

Page 20: Arsitektur Komputer - yogi.blog.unsoed.ac.id · Chapter 2 Number Systems 2-11 Aritmatika Desimal atau basis 10 Asal: perhitungan menggunakan jari “Digit” berasal dari bahasa Latin

Chapter 2 Number Systems 2-20

Estimating Magnitude: Binary

1101 01102 = 21410

1101 01102 > 19210 (128 + 64 + additional bits to the right)

Place 27 26 25 24 23 22 21 20

Value 128 64 32 16 8 4 2 1

Evaluate 1 x 128 1 x 64 0 x 32 1 x16 0 x 8 1 x 4 1 x 2 0 x 1

Sum for

Base 10128 64 0 16 0 4 2 0

Page 21: Arsitektur Komputer - yogi.blog.unsoed.ac.id · Chapter 2 Number Systems 2-11 Aritmatika Desimal atau basis 10 Asal: perhitungan menggunakan jari “Digit” berasal dari bahasa Latin

Chapter 2 Number Systems 2-21

Range of Possible Numbers

R = BK where ◦ R = range

◦ B = base

◦ K = number of digits

Example #1: Base 10, 2 digits◦ R = 102 = 100 different numbers (0…99)

Example #2: Base 2, 16 digits◦ R = 216 = 65,536 or 64K

◦ 16-bit PC can store 65,536 different number values

Page 22: Arsitektur Komputer - yogi.blog.unsoed.ac.id · Chapter 2 Number Systems 2-11 Aritmatika Desimal atau basis 10 Asal: perhitungan menggunakan jari “Digit” berasal dari bahasa Latin

Chapter 2 Number Systems 2-22

Decimal Range for Bit Widths

Bits Digits Range

1 0+ 2 (0 and 1)

4 1+ 16 (0 to 15)

8 2+ 256

10 3 1,024 (1K)

16 4+ 65,536 (64K)

20 6 1,048,576 (1M)

32 9+ 4,294,967,296 (4G)

64 19+ Approx. 1.6 x 1019

128 38+ Approx. 2.6 x 1038

Page 23: Arsitektur Komputer - yogi.blog.unsoed.ac.id · Chapter 2 Number Systems 2-11 Aritmatika Desimal atau basis 10 Asal: perhitungan menggunakan jari “Digit” berasal dari bahasa Latin

Chapter 2 Number Systems

2-

23

Base or Radix

Base:

◦ The number of different symbols required to

represent any given number

The larger the base, the more numerals are

required

◦ Base 10: 0,1, 2,3,4,5,6,7,8,9

◦ Base 2: 0,1

◦ Base 8: 0,1,2, 3,4,5,6,7

◦ Base 16: 0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F

Page 24: Arsitektur Komputer - yogi.blog.unsoed.ac.id · Chapter 2 Number Systems 2-11 Aritmatika Desimal atau basis 10 Asal: perhitungan menggunakan jari “Digit” berasal dari bahasa Latin

Chapter 2 Number Systems

2-

24

Number of Symbols vs. Number of Digits

For a given number, the larger the

base

◦ the more symbols required

◦ but the fewer digits needed

Example #1:

◦ 6516 10110 1458 110 01012

Example #2:

◦ 11C16 28410 4348 1 0001 11002

Page 25: Arsitektur Komputer - yogi.blog.unsoed.ac.id · Chapter 2 Number Systems 2-11 Aritmatika Desimal atau basis 10 Asal: perhitungan menggunakan jari “Digit” berasal dari bahasa Latin

Chapter 2 Number Systems 2-25

Counting in Base 2

Binary

Number

Equivalent Decimal

Number8’s (23) 4’s (22) 2’s (21) 1’s (20)

0 0 x 20 0

1 1 x 20 1

10 1 x 21 0 x 20 2

11 1 x 21 1 x 20 3

100 1 x 22 4

101 1 x 22 1 x 20 5

110 1 x 22 1 x 21 6

111 1 x 22 1 x 21 1 x 20 7

1000 1 x 23 8

1001 1 x 23 1 x 20 9

1010 1 x 23 1 x 21 10

Page 26: Arsitektur Komputer - yogi.blog.unsoed.ac.id · Chapter 2 Number Systems 2-11 Aritmatika Desimal atau basis 10 Asal: perhitungan menggunakan jari “Digit” berasal dari bahasa Latin

Chapter 2 Number Systems 2-26

Addition

Base Problem Largest Single Digit

Decimal6

+39

Octal6

+17

Hexadecimal6

+9F

Binary1

+01

Page 27: Arsitektur Komputer - yogi.blog.unsoed.ac.id · Chapter 2 Number Systems 2-11 Aritmatika Desimal atau basis 10 Asal: perhitungan menggunakan jari “Digit” berasal dari bahasa Latin

Chapter 2 Number Systems 2-27

Addition

Base Problem Carry Answer

Decimal6

+4Carry the 10 10

Octal6

+2Carry the 8 10

Hexadecimal6

+ACarry the 16 10

Binary1

+1Carry the 2 10

Page 28: Arsitektur Komputer - yogi.blog.unsoed.ac.id · Chapter 2 Number Systems 2-11 Aritmatika Desimal atau basis 10 Asal: perhitungan menggunakan jari “Digit” berasal dari bahasa Latin

Chapter 2 Number Systems 2-28

Binary Arithmetic

1 1 1 1 1

1 1 0 1 1 0 1

+ 1 0 1 1 0

1 0 0 0 0 0 1 1

Page 29: Arsitektur Komputer - yogi.blog.unsoed.ac.id · Chapter 2 Number Systems 2-11 Aritmatika Desimal atau basis 10 Asal: perhitungan menggunakan jari “Digit” berasal dari bahasa Latin

Chapter 2 Number Systems

2-

29

Binary Arithmetic

Addition

◦ Boolean using

XOR and AND

Multiplication

◦ AND

◦ Shift

Division

+ 0 1

0 0 1

1 1 10

x 0 1

0 0 00

1 00 01

Page 30: Arsitektur Komputer - yogi.blog.unsoed.ac.id · Chapter 2 Number Systems 2-11 Aritmatika Desimal atau basis 10 Asal: perhitungan menggunakan jari “Digit” berasal dari bahasa Latin

Chapter 2 Number Systems 2-30

Binary Arithmetic: Boolean Logic

Boolean logic without performing arithmetic◦ EXCLUSIVE-OR

Output is “1” only if either input, but not both inputs, is a “1”

◦ AND (carry bit)

Output is “1” if and only both inputs are a “1”

1 1 1 1 1

1 1 0 1 1 0 1

+ 1 0 1 1 0

1 0 0 0 0 0 1 1

Page 31: Arsitektur Komputer - yogi.blog.unsoed.ac.id · Chapter 2 Number Systems 2-11 Aritmatika Desimal atau basis 10 Asal: perhitungan menggunakan jari “Digit” berasal dari bahasa Latin

Chapter 2 Number Systems 2-31

Binary Multiplication

Boolean logic without performing

arithmetic◦ AND (carry bit)

Output is “1” if and only both inputs are a “1”

◦ Shift

Shifting a number in any base left one digit multiplies its

value by the base

Shifting a number in any base right one digit divides its

value by the base

Examples:

1010 shift left = 10010 1010 shift right = 110

102 shift left = 1002 102 shift right = 12

Page 32: Arsitektur Komputer - yogi.blog.unsoed.ac.id · Chapter 2 Number Systems 2-11 Aritmatika Desimal atau basis 10 Asal: perhitungan menggunakan jari “Digit” berasal dari bahasa Latin

Chapter 2 Number Systems 2-32

Binary Multiplication

1 1 0 1

1 0 1

1 1 0 1 1’s place

0 2’s place

1 1 0 1 4’s place (bits shifted to line up with 4’s place of multiplier)

1 0 0 0 0 0 1 Result (AND)

Page 33: Arsitektur Komputer - yogi.blog.unsoed.ac.id · Chapter 2 Number Systems 2-11 Aritmatika Desimal atau basis 10 Asal: perhitungan menggunakan jari “Digit” berasal dari bahasa Latin

Chapter 2 Number Systems 2-33

Binary Multiplication

1 1 0 1 1 0 1

x 1 0 0 1 1 0

1 1 0 1 1 0 1 2’s place (bits shifted to line

up with 2’s place of multiplier)

1 1 0 1 1 0 1 4’s place

1 1 0 1 1 0 1 32’s place

1 0 0 0 0 0 0 1 0 1 1 1 0 Result (AND)

Note the 0 at the end, since

the 1’s place is not brought

down.

Note: multiple carries are possible.

Page 34: Arsitektur Komputer - yogi.blog.unsoed.ac.id · Chapter 2 Number Systems 2-11 Aritmatika Desimal atau basis 10 Asal: perhitungan menggunakan jari “Digit” berasal dari bahasa Latin

Chapter 2 Number Systems 2-34

From Base 10 to Base 2

Base 10 42

2 ) 42 ( 0 Least significant bit

2 ) 21 ( 1

2 ) 10 ( 0

2 ) 5 ( 1

2 ) 2 ( 0

2 ) 1 Most significant bit

Base 2 101010

Remainder

Quotient

Page 35: Arsitektur Komputer - yogi.blog.unsoed.ac.id · Chapter 2 Number Systems 2-11 Aritmatika Desimal atau basis 10 Asal: perhitungan menggunakan jari “Digit” berasal dari bahasa Latin

Chapter 2 Number Systems 2-35

From Base 10 to Base 16

Base 10 5,735

16 ) 5,735 ( 7 Least significant bit

16 ) 358 ( 6

16 ) 22 ( 6

16 ) 1 ( 1 Most significant bit

16 ) 0

Base 16 1667

Quotient

Remainder

Page 36: Arsitektur Komputer - yogi.blog.unsoed.ac.id · Chapter 2 Number Systems 2-11 Aritmatika Desimal atau basis 10 Asal: perhitungan menggunakan jari “Digit” berasal dari bahasa Latin

Chapter 2 Number Systems 2-36

From Base 10 to Base 16

Base 10 8,039

16 ) 8,039 ( 7 Least significant bit

16 ) 502 ( 6

16 ) 31 ( 15

16 ) 1 ( 1 Most significant bit

16 ) 0

Base 16 1F67

Quotient

Remainder

Page 37: Arsitektur Komputer - yogi.blog.unsoed.ac.id · Chapter 2 Number Systems 2-11 Aritmatika Desimal atau basis 10 Asal: perhitungan menggunakan jari “Digit” berasal dari bahasa Latin

Chapter 2 Number Systems 2-37

From Base 8 to Base 10

72638 = 3,76310

Power 83 82 81 80

512 64 8 1

x 7 x 2 x 6 x 3

Sum for

Base 103,584 128 48 3

Page 38: Arsitektur Komputer - yogi.blog.unsoed.ac.id · Chapter 2 Number Systems 2-11 Aritmatika Desimal atau basis 10 Asal: perhitungan menggunakan jari “Digit” berasal dari bahasa Latin

Chapter 2 Number Systems 2-38

From Base 8 to Base 10

72638 = 3,76310

7

x 8

56 + 2 = 58

x 8

464 + 6 = 470

x 8

3760 + 3 = 3,763

Page 39: Arsitektur Komputer - yogi.blog.unsoed.ac.id · Chapter 2 Number Systems 2-11 Aritmatika Desimal atau basis 10 Asal: perhitungan menggunakan jari “Digit” berasal dari bahasa Latin

Chapter 2 Number Systems 2-39

From Base 16 to Base 2

The nibble approach

◦ Hex easier to read and write than binary

◦ Why hexadecimal?

Modern computer operating systems and networks

present variety of troubleshooting data in hex format

Base 16 1 F 6 7

Base 2 0001 1111 0110 0111

Page 40: Arsitektur Komputer - yogi.blog.unsoed.ac.id · Chapter 2 Number Systems 2-11 Aritmatika Desimal atau basis 10 Asal: perhitungan menggunakan jari “Digit” berasal dari bahasa Latin

Hardware for Addition and

Subtraction

Page 41: Arsitektur Komputer - yogi.blog.unsoed.ac.id · Chapter 2 Number Systems 2-11 Aritmatika Desimal atau basis 10 Asal: perhitungan menggunakan jari “Digit” berasal dari bahasa Latin

Unsigned Binary Multiplication

Page 42: Arsitektur Komputer - yogi.blog.unsoed.ac.id · Chapter 2 Number Systems 2-11 Aritmatika Desimal atau basis 10 Asal: perhitungan menggunakan jari “Digit” berasal dari bahasa Latin

Expressible Numbers

Page 43: Arsitektur Komputer - yogi.blog.unsoed.ac.id · Chapter 2 Number Systems 2-11 Aritmatika Desimal atau basis 10 Asal: perhitungan menggunakan jari “Digit” berasal dari bahasa Latin

IEEE 754

Standard for floating point storage

32 and 64 bit standards

8 and 11 bit exponent respectively

Extended formats (both mantissa and

exponent) for intermediate results

Page 44: Arsitektur Komputer - yogi.blog.unsoed.ac.id · Chapter 2 Number Systems 2-11 Aritmatika Desimal atau basis 10 Asal: perhitungan menggunakan jari “Digit” berasal dari bahasa Latin

Floating

Point

Multiplication

Page 45: Arsitektur Komputer - yogi.blog.unsoed.ac.id · Chapter 2 Number Systems 2-11 Aritmatika Desimal atau basis 10 Asal: perhitungan menggunakan jari “Digit” berasal dari bahasa Latin

Floating

Point

Division