computer system & binary review. memory model what memory is supposed to look like

36
Computer System & Binary Review

Upload: linda-gallagher

Post on 28-Dec-2015

224 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Computer System & Binary Review. Memory Model What memory is supposed to look like

Computer System & Binary Review

Page 2: Computer System & Binary Review. Memory Model What memory is supposed to look like

Memory Model

• What memory is supposed tolook like

Page 3: Computer System & Binary Review. Memory Model What memory is supposed to look like

Memory Model

• What each process actually has:

Page 4: Computer System & Binary Review. Memory Model What memory is supposed to look like

The Instruction

• Machine Instruction:00000001000010010101000000100000

Page 5: Computer System & Binary Review. Memory Model What memory is supposed to look like

Assembly

• Assembly– Equivalent to instructions

from levels 1, 2, 3

Page 6: Computer System & Binary Review. Memory Model What memory is supposed to look like

1 bit = 2 patterns 2 bits = 4 patterns 3 bits = 8 patterns

Bits And Bit Patterns

• N bits gives 2n possible patterns

Page 7: Computer System & Binary Review. Memory Model What memory is supposed to look like

Metric Units

• Standard metric units

Page 8: Computer System & Binary Review. Memory Model What memory is supposed to look like

Explaining Size

• What the hell MS?

Page 9: Computer System & Binary Review. Memory Model What memory is supposed to look like

Bi units

• Metric prefixes– May refer to powers of

2 or 10– Roughly equivalent

GB GB 109 = 1000000000 ~ 1073741824 = 230

Page 10: Computer System & Binary Review. Memory Model What memory is supposed to look like

Bi units

• Memory measured in powers of 2• Network / Processor in powers of 10• Disk

– manufactures powers of 10– OS powers of 2

2 TB = 2 * 1012 2 * 1012 / 240 = 1.819 GiB

Page 11: Computer System & Binary Review. Memory Model What memory is supposed to look like

Bytes

• 8 bits = 1 byte

• How long does a 10 Meg/sec internet connection take to download a 10 Meg file?

Page 12: Computer System & Binary Review. Memory Model What memory is supposed to look like

Bytes

• How long does a 10 Meg/sec internet connection take to download a 10 Meg file?– Networks measured in bits using powers of 10– Files in bytes using powers of 2

10Mbit internet = 10,000,000 bits per second

= 1,250,000 bytes per second

10MB file = 10 * 220 = 10,485,760 bytes

10,485,760 / 1,250,000 = 8.39 seconds

Page 13: Computer System & Binary Review. Memory Model What memory is supposed to look like

Bases

• Place based number representations:

thirty-twos

25

sixteens24

eights23

fours22

twos21

ones20

1 0 1 1 0 1

ten thousand

s104

thousands

103

hundreds102

tens101

ones100

1 2 0 5 9

Page 14: Computer System & Binary Review. Memory Model What memory is supposed to look like

Specifying Base

• Specify base as subscript:610 = 1102

Page 15: Computer System & Binary Review. Memory Model What memory is supposed to look like

Binary Number Conversions

• Table Method:

64 + 32 + 8 + 1 = 105

011010012 = 10510

128 64 32 16 8 4 2 1

0 1 1 0 1 0 0 1

Page 16: Computer System & Binary Review. Memory Model What memory is supposed to look like

Divide Method1. Write out the Decimal number.2. Is it odd or even? If ODD, write a

'1'. If EVEN, write a '0'.3. Divide the Decimal number by 2,

and ignore the remainder (e.g., 105 / 2 = 52.5, ignore the remainder = 52).

4. Go back to step 2, always building the Binary number from right to left.

5. When you get to 0, you're done. Add enough zeros to the left of the Binary number to make 8 digits.

  105 odd 1

÷ 2 52 even 01

÷ 2 26 even 001

÷ 2 13 odd 1001

÷ 2 6 even 01001

÷ 2 3 odd 101001

÷ 2 1 odd 1101001

÷ 2 0 done 01101001

Page 17: Computer System & Binary Review. Memory Model What memory is supposed to look like

Multiply Method

Current number First Digit Old Total x 2 Total

 01101001 0 0 0

  1101001 1 0 1

  101001 1 2 3

  01001 0 6 6

  1001 1 12 13

  001 0 26 26

  01 0 52 52

  1 1 104 105

Page 18: Computer System & Binary Review. Memory Model What memory is supposed to look like

Hex

• Hexdecimal = base 16– 4 bits = 1 hex digit

Page 19: Computer System & Binary Review. Memory Model What memory is supposed to look like

Hex Numbers

• 1A316 =

1 * 256 + 10 * 16 + 3 * 1256 + 160 + 3 = 41910

OR

1 A 3

= 0001 1010 00112

4096 256 16 1

1 A 3

Decimal Binary Hex 0 0 0 1 1 1 2 10 2 3 11 3 4 100 4 5 101 5 6 110 6 7 111 7

8 1000 8 9 1001 9

10 1010 A 11 1011 B 12 1100 C 13 1101 D 14 1110 E 15 1111 F

Page 20: Computer System & Binary Review. Memory Model What memory is supposed to look like

Hex Conversion

• Convert with division 41916 to base 10

  Number Quotient Remainder

÷ 16 419 26 3 3

÷ 16 26 1 10 (A) A3

÷ 16 1 0 1 1A3

Page 21: Computer System & Binary Review. Memory Model What memory is supposed to look like

Specifying Bases

• Leading 0 Octal (base 8)• Leading 0x Hex (base 16)

Page 22: Computer System & Binary Review. Memory Model What memory is supposed to look like

ASCII

• Maps a byte ofmemory to chars/control symbols

Page 23: Computer System & Binary Review. Memory Model What memory is supposed to look like

Unsigned Binary Addition

• Adding base 2:• 1 = 1• 2 = 10 = keep 0 and carry 1• 3 = 11 = keep 1 carry 1

1 1 10 1 0 10 1 1 11 1 0 0

Page 24: Computer System & Binary Review. Memory Model What memory is supposed to look like

Unsigned Addition

• Overflow : Carry out of highest bit– Error!

• 13 + 7 = 4?

1 1 1 11 1 0 10 1 1 10 1 0 0

Page 25: Computer System & Binary Review. Memory Model What memory is supposed to look like

Signed numbers

• 2's complement system:– Positive numbers normal, but

must have a 0 in left bit– Negative numbers:

• Start with 1• Value defined as inverse of

– Flip all bits then add 1

Page 26: Computer System & Binary Review. Memory Model What memory is supposed to look like

Signed numbers

What is 1001? 1001 Negative number

0110 reverse

6 As decimal

7 Add one

-7 = 1001

Page 27: Computer System & Binary Review. Memory Model What memory is supposed to look like

Signed numbers

Make -3 0011 start with 3

1100 reverse bits

1101 + 1

1101 Two’s complement -3

Page 28: Computer System & Binary Review. Memory Model What memory is supposed to look like

2’s complement

1 + (-2)

00011110------

1111

Page 29: Computer System & Binary Review. Memory Model What memory is supposed to look like

2’s complement

7 + 7

01110111------

1110 = -2??? Overflow switches

sign

Page 30: Computer System & Binary Review. Memory Model What memory is supposed to look like

4 bits

• Biggest positive: 7

• -1 :

• Lowest negative: -8

0 1 1 1

1 0 0 00 1 1 1 Flip (7)

+1 = 8

1 1 1 1

Page 31: Computer System & Binary Review. Memory Model What memory is supposed to look like

2’s complement

• Cary into final column and no extra carry– Positive overflow!– Ex: 4 + 6 (sign bits are blue)

0 1 0 00 1 0 00 1 1 01 0 1 0

Page 32: Computer System & Binary Review. Memory Model What memory is supposed to look like

2’s complement

• Extra carry and no carry in final column– Negative overflow!– Ex: -4 + -6 (sign bits are blue)

1 0 0 01 1 0 01 0 1 00 1 1 0

Page 33: Computer System & Binary Review. Memory Model What memory is supposed to look like

2’s complement

• No final column carry & no extra carry– Success

0 0 0 00 1 0 00 0 1 00 1 1 0

Page 34: Computer System & Binary Review. Memory Model What memory is supposed to look like

2’s complement

• Final column carry & extra carry– Success – ignore extra carry

1 1 0 01 1 0 11 1 1 01 0 1 1

Page 35: Computer System & Binary Review. Memory Model What memory is supposed to look like

2’s complement

• Pros– One zero– Easy to switch sign– Consistent direction

• Cons– Break : - above +

Page 36: Computer System & Binary Review. Memory Model What memory is supposed to look like

Signed - Excess Notation

• Excess Notation : start counting from a negative number– Used in some situation

• Pros:– Values are properly ordered

• Cons:– Harder to read

• Need to know starting point

– Normal math does not work

Binary Value

000 -4

001 -3

010 -2

011 -1

100 0

101 1

110 2

111 3