CSC-205 Computer Organization Lecture #002 Section 1.5 Dr...

30
1/30 Miscellanea 8224 Revisited Break 1.5 1.6 Conclusion References Backup slides CSC-205 Computer Organization Lecture #002 Section 1.5 Dr. Chuck Cartledge Dr. Chuck Cartledge Dr. Chuck Cartledge Dr. Chuck Cartledge Dr. Chuck Cartledge Dr. Chuck Cartledge Dr. Chuck Cartledge Dr. Chuck Cartledge Dr. Chuck Cartledge Dr. Chuck Cartledge Dr. Chuck Cartledge Dr. Chuck Cartledge Dr. Chuck Cartledge Dr. Chuck Cartledge Dr. Chuck Cartledge Dr. Chuck Cartledge Dr. Chuck Cartledge Dr. Chuck Cartledge Dr. Chuck Cartledge Dr. Chuck Cartledge Dr. Chuck Cartledge 3 June 2015 3 June 2015 3 June 2015 3 June 2015 3 June 2015 3 June 2015 3 June 2015 3 June 2015 3 June 2015 3 June 2015 3 June 2015 3 June 2015 3 June 2015 3 June 2015 3 June 2015 3 June 2015 3 June 2015 3 June 2015 3 June 2015 3 June 2015 3 June 2015

Transcript of CSC-205 Computer Organization Lecture #002 Section 1.5 Dr...

Page 1: CSC-205 Computer Organization Lecture #002 Section 1.5 Dr ...ccartled/Teaching/2015-Summer-TCC/Lect… · 1/30 Miscellanea 8224 Revisited Break 1.5 1.6 Conclusion References Backup

1/30

Miscellanea 8224 Revisited Break 1.5 1.6 Conclusion References Backup slides

CSC-205 Computer Organization

Lecture #002

Section 1.5

Dr. Chuck CartledgeDr. Chuck CartledgeDr. Chuck CartledgeDr. Chuck CartledgeDr. Chuck CartledgeDr. Chuck CartledgeDr. Chuck CartledgeDr. Chuck CartledgeDr. Chuck CartledgeDr. Chuck CartledgeDr. Chuck CartledgeDr. Chuck CartledgeDr. Chuck CartledgeDr. Chuck CartledgeDr. Chuck CartledgeDr. Chuck CartledgeDr. Chuck CartledgeDr. Chuck CartledgeDr. Chuck CartledgeDr. Chuck CartledgeDr. Chuck Cartledge

3 June 20153 June 20153 June 20153 June 20153 June 20153 June 20153 June 20153 June 20153 June 20153 June 20153 June 20153 June 20153 June 20153 June 20153 June 20153 June 20153 June 20153 June 20153 June 20153 June 20153 June 2015

Page 2: CSC-205 Computer Organization Lecture #002 Section 1.5 Dr ...ccartled/Teaching/2015-Summer-TCC/Lect… · 1/30 Miscellanea 8224 Revisited Break 1.5 1.6 Conclusion References Backup

2/30

Miscellanea 8224 Revisited Break 1.5 1.6 Conclusion References Backup slides

Table of contents I

1 Miscellanea

2 8224 Revisited

3 Break

4 1.5

5 1.6

6 Conclusion

7 References

8 Backup slides

Page 3: CSC-205 Computer Organization Lecture #002 Section 1.5 Dr ...ccartled/Teaching/2015-Summer-TCC/Lect… · 1/30 Miscellanea 8224 Revisited Break 1.5 1.6 Conclusion References Backup

3/30

Miscellanea 8224 Revisited Break 1.5 1.6 Conclusion References Backup slides

Corrections and additions since last lecture.

Correct typos

Page 4: CSC-205 Computer Organization Lecture #002 Section 1.5 Dr ...ccartled/Teaching/2015-Summer-TCC/Lect… · 1/30 Miscellanea 8224 Revisited Break 1.5 1.6 Conclusion References Backup

4/30

Miscellanea 8224 Revisited Break 1.5 1.6 Conclusion References Backup slides

What is in a number??

822410 =>

100000001000002

822410 => 202016

822410 => ASCII

Image from [3].

The language supported assigning strings to integers to save RAM.8224 is two spaces.

Page 5: CSC-205 Computer Organization Lecture #002 Section 1.5 Dr ...ccartled/Teaching/2015-Summer-TCC/Lect… · 1/30 Miscellanea 8224 Revisited Break 1.5 1.6 Conclusion References Backup

5/30

Miscellanea 8224 Revisited Break 1.5 1.6 Conclusion References Backup slides

Concept

How we see bits depends on our viewing tool.

Sometimes what we see isdifferent than what weexpect.

Page 6: CSC-205 Computer Organization Lecture #002 Section 1.5 Dr ...ccartled/Teaching/2015-Summer-TCC/Lect… · 1/30 Miscellanea 8224 Revisited Break 1.5 1.6 Conclusion References Backup

6/30

Miscellanea 8224 Revisited Break 1.5 1.6 Conclusion References Backup slides

Concept

And now we go live.

Hold on. Things can get alittle hairy.

When in doubt, have backup slides.

Page 7: CSC-205 Computer Organization Lecture #002 Section 1.5 Dr ...ccartled/Teaching/2015-Summer-TCC/Lect… · 1/30 Miscellanea 8224 Revisited Break 1.5 1.6 Conclusion References Backup

7/30

Miscellanea 8224 Revisited Break 1.5 1.6 Conclusion References Backup slides

Concept

What is the takeaway??

What we see is determinedby the tools we use.

Different tools give usdifferent views.

Some tools constrain yourview (without telling you.)

Take a look at a PDF, eps, or giffile using the “wrong” tool.

The more tools you have then more different views you can have.

Page 8: CSC-205 Computer Organization Lecture #002 Section 1.5 Dr ...ccartled/Teaching/2015-Summer-TCC/Lect… · 1/30 Miscellanea 8224 Revisited Break 1.5 1.6 Conclusion References Backup

8/30

Miscellanea 8224 Revisited Break 1.5 1.6 Conclusion References Backup slides

Break time.

Take about 10 minutes.

Page 9: CSC-205 Computer Organization Lecture #002 Section 1.5 Dr ...ccartled/Teaching/2015-Summer-TCC/Lect… · 1/30 Miscellanea 8224 Revisited Break 1.5 1.6 Conclusion References Backup

9/30

Miscellanea 8224 Revisited Break 1.5 1.6 Conclusion References Backup slides

Real and floating point numbers

So far we have only looked at integers, the counting

numbers.

What about “real” or “floatingpoint” numbers?? How do werepresent the value 5.375??

For integers:n = ∑positions

i=1 vali ∗base(i−1)

For floating point:n =

∑positionsi=1 vali ∗base

(i−1−m)

m is the number of bits tothe right of the decimalpoint

If m = 3 then5.37510 = 101.0112

Like so many other things, we change the definition of the bits.

Page 10: CSC-205 Computer Organization Lecture #002 Section 1.5 Dr ...ccartled/Teaching/2015-Summer-TCC/Lect… · 1/30 Miscellanea 8224 Revisited Break 1.5 1.6 Conclusion References Backup

10/30

Miscellanea 8224 Revisited Break 1.5 1.6 Conclusion References Backup slides

Real and floating point numbers

So how does this work??

We’ll pick it apart. n = ∑cellSizei=1 vali ∗base

(i−1−m) base = 2,m = 3

How do we represent the decimal point in binary??

Page 11: CSC-205 Computer Organization Lecture #002 Section 1.5 Dr ...ccartled/Teaching/2015-Summer-TCC/Lect… · 1/30 Miscellanea 8224 Revisited Break 1.5 1.6 Conclusion References Backup

11/30

Miscellanea 8224 Revisited Break 1.5 1.6 Conclusion References Backup slides

Real and floating point numbers

Another mechanical way to convert to binary.

Repeatedly divide theinteger portion by 2 andrecord the remainder

Repeatedly multiply thefractional portion by 2 andrecord the overflow

6.585937510 = 110.100101112

Stop converting when the integer and fractional part are 0.

Page 12: CSC-205 Computer Organization Lecture #002 Section 1.5 Dr ...ccartled/Teaching/2015-Summer-TCC/Lect… · 1/30 Miscellanea 8224 Revisited Break 1.5 1.6 Conclusion References Backup

12/30

Miscellanea 8224 Revisited Break 1.5 1.6 Conclusion References Backup slides

Real and floating point numbers

What happens with “messy” numbers??

As an exercise, convert1.2(10) to binary.

.2

0 .40 .81 .61 .20 .40 .81 .61 .2...

...

Some fractions can not be represented by a fixed length binarynumber.

Page 13: CSC-205 Computer Organization Lecture #002 Section 1.5 Dr ...ccartled/Teaching/2015-Summer-TCC/Lect… · 1/30 Miscellanea 8224 Revisited Break 1.5 1.6 Conclusion References Backup

13/30

Miscellanea 8224 Revisited Break 1.5 1.6 Conclusion References Backup slides

Real and floating point numbers

Our friend, scientific notation.

A short hand way of writingnumbers. Makes things likemultiplication and division oflarge numbers trivial. A couple ofexamples.

−328.4 =−3.284∗102

Three parts:1 Sign (- in this case)2 Coefficient (3.284 in this

case), sometimes calledthe significand

3 Exponent (2 in this case)4 Base (10 in this case)

value = SignCoefficient ∗BaseExponent

Writing numbers in scientific notation is called “normalized” form.

Page 14: CSC-205 Computer Organization Lecture #002 Section 1.5 Dr ...ccartled/Teaching/2015-Summer-TCC/Lect… · 1/30 Miscellanea 8224 Revisited Break 1.5 1.6 Conclusion References Backup

14/30

Miscellanea 8224 Revisited Break 1.5 1.6 Conclusion References Backup slides

Real and floating point numbers

Remember the question about where do we store the

decimal point??

When dealing with numbers in the normalized form, everyoneknows where the decimal is, so no one has to store it.

And because everyone “knows” that the most significant bithas to be 1, no has to store it.

Hidden and excess bits are conventions that allow more bits to beused where they are needed.

Page 15: CSC-205 Computer Organization Lecture #002 Section 1.5 Dr ...ccartled/Teaching/2015-Summer-TCC/Lect… · 1/30 Miscellanea 8224 Revisited Break 1.5 1.6 Conclusion References Backup

15/30

Miscellanea 8224 Revisited Break 1.5 1.6 Conclusion References Backup slides

Real and floating point numbers

Special Values

The limitation on the cell size(i.e., the number of bits we canuse) places a limit on the rangeof values we can represent.

We’ve seen how ADDingcan overflow a cell.

Normalization limits thesmallest coefficient that wecan have greater than 0.

Operations using values inrange can result in valuesthat can not be represented.

Sign bit, 7 bit coeff, 5 bit expon.

All of these errors can to caught by the CPU and software.

Page 16: CSC-205 Computer Organization Lecture #002 Section 1.5 Dr ...ccartled/Teaching/2015-Summer-TCC/Lect… · 1/30 Miscellanea 8224 Revisited Break 1.5 1.6 Conclusion References Backup

16/30

Miscellanea 8224 Revisited Break 1.5 1.6 Conclusion References Backup slides

Real and floating point numbers

There are too many possibilities. We need

standardization.

The IEEE 754 Floating PointStandard to the rescue.

Each CPU manufacturer hadtheir own floating pointrepresentation.

Each felt their’s was thebest.

Application software on onemachine may not runcorrectly on anothermachine.

Page 17: CSC-205 Computer Organization Lecture #002 Section 1.5 Dr ...ccartled/Teaching/2015-Summer-TCC/Lect… · 1/30 Miscellanea 8224 Revisited Break 1.5 1.6 Conclusion References Backup

17/30

Miscellanea 8224 Revisited Break 1.5 1.6 Conclusion References Backup slides

Real and floating point numbers

IEEE 754 Special Values and Notes

Predefined special values by thespecification:

Positive and negativeinfinity: sign ⇒ 0/1, expon.⇒ all 1s, coeff ⇒ all 0s

Not a Number (NaN): sign⇒ 0/1, expon. ⇒ all 1s,coeff ⇒ anything except all0s

Precision:2−149

≈ 1.17549∗10−38 or2−1074

≈ 4.94066∗10−324

Rounding: nearest, even, 0,+/- infinity

Page 18: CSC-205 Computer Organization Lecture #002 Section 1.5 Dr ...ccartled/Teaching/2015-Summer-TCC/Lect… · 1/30 Miscellanea 8224 Revisited Break 1.5 1.6 Conclusion References Backup

18/30

Miscellanea 8224 Revisited Break 1.5 1.6 Conclusion References Backup slides

Numbers at different levels

Just a little C++

We’ve talked about numbers andASCII, lets put them to use.

int declaration sets asidememory for a 2’scompliment integer

char declaration sets asidememory for an 8 bit ASCIIcharacter

cout << “prints”something to the screen This model is referred to often in

[4].

You don’t have to have taken a C++ course to get through this,but it helps.

Page 19: CSC-205 Computer Organization Lecture #002 Section 1.5 Dr ...ccartled/Teaching/2015-Summer-TCC/Lect… · 1/30 Miscellanea 8224 Revisited Break 1.5 1.6 Conclusion References Backup

19/30

Miscellanea 8224 Revisited Break 1.5 1.6 Conclusion References Backup slides

Numbers at different levels

Given the information from the previous slide . . .

What does this code snippetdo??int j = 12;

char c = j;

cout << ch;

What will I see on the screen??

Page 20: CSC-205 Computer Organization Lecture #002 Section 1.5 Dr ...ccartled/Teaching/2015-Summer-TCC/Lect… · 1/30 Miscellanea 8224 Revisited Break 1.5 1.6 Conclusion References Backup

20/30

Miscellanea 8224 Revisited Break 1.5 1.6 Conclusion References Backup slides

Numbers at different levels

Given what we’ve covered in class . . .

How would I find out how manybits (or bytes) are in a Bloodshedint??

Class discussion.

Why would I care??

Page 21: CSC-205 Computer Organization Lecture #002 Section 1.5 Dr ...ccartled/Teaching/2015-Summer-TCC/Lect… · 1/30 Miscellanea 8224 Revisited Break 1.5 1.6 Conclusion References Backup

21/30

Miscellanea 8224 Revisited Break 1.5 1.6 Conclusion References Backup slides

Numbers at different levels

Other ways to represent numbers

Binary Coded Decimal(BCD) — each decimal digitis represented in one nibble.

Gray code — adjacentvalues differ by exactly onebit

Non Zero Return (NZR) —bits only change state if theoriginal bits change Image from [2].

Lots of different ways to represent numbers.

Page 22: CSC-205 Computer Organization Lecture #002 Section 1.5 Dr ...ccartled/Teaching/2015-Summer-TCC/Lect… · 1/30 Miscellanea 8224 Revisited Break 1.5 1.6 Conclusion References Backup

22/30

Miscellanea 8224 Revisited Break 1.5 1.6 Conclusion References Backup slides

Numbers at different levels

Models

”. . . essentially, allmodels are wrong, butsome are useful.”

George E. P. Box [1]

Plato — celestial spheres

Copernicus — earth(planets) revolves aroundthe sun

Brache — Copernicus notquite correct

Kepler — planets revolve inellipses

All models have imperfections.

Page 23: CSC-205 Computer Organization Lecture #002 Section 1.5 Dr ...ccartled/Teaching/2015-Summer-TCC/Lect… · 1/30 Miscellanea 8224 Revisited Break 1.5 1.6 Conclusion References Backup

23/30

Miscellanea 8224 Revisited Break 1.5 1.6 Conclusion References Backup slides

What have we covered?

There are many differentways to look at bitsSections 1.5 and 1.6Concept of “More tools isbetter”Concept of “Your tools maybe limiting you”

Exam on Chapter 1Sections 2.1 through 2.4

Page 24: CSC-205 Computer Organization Lecture #002 Section 1.5 Dr ...ccartled/Teaching/2015-Summer-TCC/Lect… · 1/30 Miscellanea 8224 Revisited Break 1.5 1.6 Conclusion References Backup

24/30

Miscellanea 8224 Revisited Break 1.5 1.6 Conclusion References Backup slides

References I

[1] George E. P. Box and Norman R. Draper,Empirical Model-Building and Response Surfaces, HighOccupancy Vehicle 4 (1987), 21.

[2] Clive Maxfield,How to generate Gray Codes for non-power-of-2 sequences,http://www.eetimes.com/document.asp?doc id=1274581,2007.

[3] Museum of HP Calcualtors Staff, Hp 9830a,http://www.hpmuseum.org/hp9830.htm.

[4] J. Stanley Warford, Computer Systems, Jones & BartlettPublishers, 2010.

Page 25: CSC-205 Computer Organization Lecture #002 Section 1.5 Dr ...ccartled/Teaching/2015-Summer-TCC/Lect… · 1/30 Miscellanea 8224 Revisited Break 1.5 1.6 Conclusion References Backup

25/30

Miscellanea 8224 Revisited Break 1.5 1.6 Conclusion References Backup slides

A Word 2010 file in Word.

Page 26: CSC-205 Computer Organization Lecture #002 Section 1.5 Dr ...ccartled/Teaching/2015-Summer-TCC/Lect… · 1/30 Miscellanea 8224 Revisited Break 1.5 1.6 Conclusion References Backup

26/30

Miscellanea 8224 Revisited Break 1.5 1.6 Conclusion References Backup slides

A Word file on the file system.

Page 27: CSC-205 Computer Organization Lecture #002 Section 1.5 Dr ...ccartled/Teaching/2015-Summer-TCC/Lect… · 1/30 Miscellanea 8224 Revisited Break 1.5 1.6 Conclusion References Backup

27/30

Miscellanea 8224 Revisited Break 1.5 1.6 Conclusion References Backup slides

A Word file outside of Word.

Page 28: CSC-205 Computer Organization Lecture #002 Section 1.5 Dr ...ccartled/Teaching/2015-Summer-TCC/Lect… · 1/30 Miscellanea 8224 Revisited Break 1.5 1.6 Conclusion References Backup

28/30

Miscellanea 8224 Revisited Break 1.5 1.6 Conclusion References Backup slides

The raw Word word/document.xml file.

Page 29: CSC-205 Computer Organization Lecture #002 Section 1.5 Dr ...ccartled/Teaching/2015-Summer-TCC/Lect… · 1/30 Miscellanea 8224 Revisited Break 1.5 1.6 Conclusion References Backup

29/30

Miscellanea 8224 Revisited Break 1.5 1.6 Conclusion References Backup slides

The pretty printed Word word/document.xml file.

Page 30: CSC-205 Computer Organization Lecture #002 Section 1.5 Dr ...ccartled/Teaching/2015-Summer-TCC/Lect… · 1/30 Miscellanea 8224 Revisited Break 1.5 1.6 Conclusion References Backup

30/30

Miscellanea 8224 Revisited Break 1.5 1.6 Conclusion References Backup slides

A raw PDF file.