DOC PREVIEW
Harvey Mudd CS 105 - Computer Systems Introduction

This preview shows page 1-2-14-15-29-30 out of 30 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 30 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 30 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 30 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 30 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 30 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 30 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 30 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

Computer Systems IntroductionCourse ThemeTextbooksSyllabusNotes:FacilitiesCS 105 “Tour of the Black Holes of Computing”C PuzzlesEncoding IntegersEncoding Integers (Cont.)Numeric RangesValues for Different Word SizesUnsigned & Signed Numeric ValuesCasting Signed to UnsignedRelation Between Signed & UnsignedSigned vs. Unsigned in CCasting SurprisesSlide 18Explanation of Casting SurprisesSign ExtensionSign Extension ExampleWhy Should I Use Unsigned?Negating with Complement & IncrementComp. & Incr. ExamplesUnsigned AdditionTwo’s Complement AdditionDetecting 2’s Comp. OverflowMultiplicationPower-of-2 Multiply by ShiftingUnsigned Power-of-2 Divide by Shifting– 1 –CS 105 Computer SystemsIntroduction Computer SystemsIntroductionTopics:Topics:Staff, text, and policiesLecture topics and assignmentsLab rationaleCS 105“Tour of the Black Holes of Computing!”Geoff KuenningSpring 2009– 2 –CS 105Course ThemeCourse ThemeAbstraction is good, but don’t forget reality!Many CS Courses emphasize abstractionMany CS Courses emphasize abstractionAbstract data typesAsymptotic analysisThese abstractions have limitsThese abstractions have limitsEspecially in the presence of bugsNeed to understand underlying implementationsUseful outcomesUseful outcomesBecome more effective programmersAble to find and eliminate bugs efficientlyAble to tune program performancePrepare for later “systems” classes in CSCompilers, Operating Systems, Networks, Computer Architecture, Robotics, etc.– 3 –CS 105TextbooksTextbooksRandal E. Bryant and David R. O’Hallaron, Randal E. Bryant and David R. O’Hallaron, “Computer Systems: A Programmer’s Perspective”, Prentice Hall, 2003.Brian Kernighan and Dennis Ritchie, Brian Kernighan and Dennis Ritchie, “The C Programming Language, Second Edition”, Prentice Hall, 1988Larry Miller and Alex QuiliciLarry Miller and Alex QuiliciThe Joy of C, Wiley, 1997– 4 –CS 105SyllabusSyllabusSyllabus on Web: http://www.cs.hmc.edu/~geoff/cs105Calendar defines due datesLabs: cs105submit for some, others have specific directions– 5 –CS 105Notes:Notes:Work groupsWork groupsYou must work in pairs on all labsHonor-code violation to work without your partner! HandinsHandinsCheck calendarElectronic submissions onlyGrading CharacteristicsGrading CharacteristicsLab scores tend to be highSerious handicap if you don’t hand a lab inTests & quizzes typically have a wider range of scoresI.e., they’re primary determinant of your grade»…but not the ONLY oneDo your share of lab work and reading, or bomb tests– 6 –CS 105FacilitiesFacilitiesAssignments will use Intel computer systemsAssignments will use Intel computer systemsNot all machines are created alikeSome Macs are PowerPCsEven Intel Macs aren’t necessarily compatibleKnuth is a 64-bit serverWilkes: x86/Linux specifically set up for this classLog in on a Mac, then ssh to WilkesIf you want fancy programs, start X11 firstDirectories are cross-mounted, so you can edit on Knuth or your Mac, and Wilkes will see your files…or ssh into Wilkes from your dormAll programs must run on Wilkes: that’s where we gradeCS 105 “Tour of the Black Holes of Computing”TopicsTopicsNumeric EncodingsUnsigned & two’s complementProgramming ImplicationsC promotion rulesBasic operationsAddition, negation, multiplication Programming ImplicationsConsequences of overflowUsing shifts to perform power-of-2 multiply/divideCS 105IntegersIntegers– 8 –CS 105C PuzzlesC PuzzlesTaken from old examsAssume machine with 32 bit word size, two’s complement integersFor each of the following C expressions, either:Argue that it is true for all argument valuesGive example where it is not true•x < 0  ((x*2) < 0)•ux >= 0•x & 7 == 7  (x<<30) < 0•ux > -1•x > y  -x < -y•x * x >= 0•x > 0 && y > 0  x + y > 0•x >= 0 -x <= 0•x <= 0 -x >= 0int x = foo();int y = bar();unsigned ux = x;unsigned uy = y;Initialization– 9 –CS 105Encoding IntegersEncoding Integers short int x = 15213; short int y = -15213;C short 2 bytes longSign BitSign BitFor 2’s complement, most-significant bit indicates sign0 for nonnegative1 for negativeB2T (X )   xw 12w 1 xi2ii0w 2B2U(X )  xi2ii0w 1UnsignedTwo’s ComplementSignBitDecimal Hex Binaryx152133B 6D 00111011 01101101y-15213C4 93 11000100 10010011– 10 –CS 105Encoding Integers (Cont.)Encoding Integers (Cont.) x = 15213: 00111011 01101101 y = -15213: 11000100 10010011Weight 15213 -1521311111200124140081800160011632132006416400128001128256125600512151200102400110242048120480040961409600819218192001638400116384-32768001-32768Sum 15213 -15213– 11 –CS 105Numeric RangesNumeric RangesUnsigned ValuesUnsigned ValuesUMin = 0000…0UMax = 2w – 1111…1Two’s Complement ValuesTwo’s Complement ValuesTMin = –2w–1100…0TMax = 2w–1 – 1011…1Other ValuesOther ValuesMinus 1111…1Decimal Hex BinaryUMax65535FF FF 11111111 11111111TMax327677F FF 01111111 11111111TMin-3276880 00 10000000 00000000-1-1FF FF 11111111 111111110000 00 00000000 00000000Values for W = 16– 12 –CS 105Values for Different Word SizesValues for Different Word SizesObservationsObservations|TMin | = TMax + 1Asymmetric rangeUMax = 2 * TMax + 1 C ProgrammingC Programming#include <limits.h>K&R App. B11Declares constants, e.g.,ULONG_MAXLONG_MAXLONG_MINValues platform-specific– 13 –CS 105Unsigned & SignedNumeric ValuesUnsigned & SignedNumeric ValuesX B2T(X)B2U(X)0000 00001 10010 20011 30100 40101 50110 60111 7–88–79–610–511–412–313–214–1151000100110101011110011011110111101234567EquivalenceEquivalenceSame encodings for nonnegative valuesUniquenessUniquenessEvery bit pattern represents unique integer valueEach representable integer has unique bit encoding– 14 –CS 105 short int x = 15213; unsigned short int ux = (unsigned short) x; short int y = -15213; unsigned short int uy = (unsigned short) y;Casting Signed to UnsignedCasting Signed to UnsignedC Allows Conversions from Signed to UnsignedC Allows Conversions from Signed to UnsignedResulting ValueResulting ValueNo change in bit representationNonnegative values unchangedux =


View Full Document

Harvey Mudd CS 105 - Computer Systems Introduction

Documents in this Course
Processes

Processes

25 pages

Processes

Processes

27 pages

Load more
Download Computer Systems Introduction
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Computer Systems Introduction and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Computer Systems Introduction 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?