1 / 28

CMP 131 Introduction to Computer Programming

This lecture provides an overview of computer hardware and software, including the interface between them, data and program representation, and machine arithmetic.

clisa
Download Presentation

CMP 131 Introduction to Computer Programming

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. CMP 131Introduction to Computer Programming Violetta Cavalli-Sforza Week 1, Lecture 2 CMP 131 Introduction to Computers and Programming

  2. Outline of Topics • Review briefly last class • More details about hardware • Software/Hardware interface • Data and program representation • Machine arithmetic CMP 131 Introduction to Computers and Programming

  3. Last Class • Course Description • Logistics • Assessments (Grading) • Homework • First assignment will come out Monday CMP 131 Introduction to Computers and Programming

  4. Last Class (2) • Computers: What’s in them? • Hardware • Software • Hardware devices • Computers through time • Hardware trends • Hardware/software trends CMP 131 Introduction to Computers and Programming

  5. Why Take This Course? • Be more familiar with PCs • Have a basic understanding of programming and the programming process • Develop critical thinking & problem solving capabilities • Learn other programming languages faster & easier CMP 131 Introduction to Computers and Programming

  6. Why Pascal? • One of the first structured programming languages • It influenced the design of its successors • Modula 2, Oberon (by N.Wirth) • Modula2+, Modula3 (DEC, Olivetti) • Java • Not C or C++ CMP 131 Introduction to Computers and Programming

  7. Today’s Lecture • Review of computers and hardware • Some more information • More about software • Programming languages • Low and high-level languages • Viewing programming through different languages • Introduction to the Pascal IDE environment CMP 131 Introduction to Computers and Programming

  8. Computer Systems • Computers • Devices for performing computations at high speeds with great accuracy • A machine that can be programmed to manipulate symbols. Can perform complex & repetitive procedures quickly, precisely and reliably. Can quickly store and retrieve large amounts of data. • Program • A set of instructions for a computer to follow, written in specific programming language CMP 131 Introduction to Computers and Programming

  9. Computer Systems • Hardware (HW) • Actual physical machines (equipment) that make up the computer • Software (SW) • A collection of programs used by a computer • A set of instructions provided by the programmer that the computer follows. • Program instructions have to be stored in main memory before they can be executed. CMP 131 Introduction to Computers and Programming

  10. Computer Systems • Computer Categories: • Microcomputers (Personal computers / PCs) • Used by a single person • Workstations: • Largest microcomputers • Minicomputers: • Can be used by many people simultaneously by using several terminals connected to the same CPU • Main frame computers: • Faster & larger than minicomputers • Super computers: • Most powerful mainframe computers • Of which category is you computer at home?? CMP 131 Introduction to Computers and Programming

  11. Hardware (HW): Organization • Computer HW usually consists of: • CPU • Main memory (RAM & ROM) • I/O Devices • Secondary Memory • CPU & main memory are the heart of the computer • Usually the CPU, main memory and secondary memory are housed in a single cabinet I/O Devices CPU Secondary Memory MainMemory CMP 131 Introduction to Computers and Programming

  12. Hardware (HW): Central Processing Unit (CPU) • Executes programs • Performs calculations • Arithmetic • Add, subtract, divide, multiply, … etc. • Logical • Compare, test for true/false • Controls & coordinates the other parts of the computer. CMP 131 Introduction to Computers and Programming

  13. Hardware (HW): Memory • Main (Primary) Memory: • Ordered sequence and specific number of memory locations (Bytes, words) that have unique addresses indicating their relative positions • Fast, expensive, short term memory • Holds intermediate results and serves as “scratch paper” • Needed to carry out program instructions • Types: • RAM: Random Access Memory (vs. Sequential Access Memory) • Volatile (i.e. contents disappear when the computer is switched off) • Writable (except where forbidden by the software) • ROM: Read Only Memory • Non-volatile • Also usually random access CMP 131 Introduction to Computers and Programming

  14. Hardware (HW): Memory • Secondary (auxiliary) memory • Used for keeping a permanent records of information • Holds programs and data between jobs • Keeps data or program files for later use • Slower, cheaper, long-term memory • Common forms • Diskettes, magnetic tapes, hard disk, CD-ROM’s, DVD • Some types are removable CMP 131 Introduction to Computers and Programming

  15. Hardware (HW) • I/O (Input/Output) devices • Allow the user to communicate with the computer. • A single computer could be connected to more than one input or output device. • Examples: • Input: Keyboard, mouse, scanner, voice • Output: Screen, printer, voice CMP 131 Introduction to Computers and Programming

  16. Hardware/Software Architectures • Mainframe Era • 1940’s-70’s: mainframe computer, minicomputers • Environments: • Batch environments, batch processing • Files are basis for I/O: fixed formats, minimal device I/O • Error recovery • Lack of timing constraints • Interactive environments • Terminal and file I/O: • Interactive error handling • Faster performance CMP 131 Introduction to Computers and Programming

  17. Personal Computers Era • 1978: the Apple II ran BASIC • Educational use • 1981: IBM released the first PC • 1984: Macintosh • Window environments: • OO models are ideal (Smalltalk) • Must interact with many I/O devices (file I/O is less important) • Embedded systems • Error handling • Real-time response • Distributed systems with concurrently running tasks CMP 131 Introduction to Computers and Programming

  18. Networking Era: • LANs (Local Area Networks): client-server model • Airline reservations, banking • Internet • 70’s: ARPANET: telnet, FTP, SMTP protocols • late 80’s: HTML and HTTP added • Issues and Effects: • Static web pages with URLs for accessURL = Uniform Resource Locator • Dynamic web pages for e-commerce (Perl, JAVA, etc.) • Security • Performance (multiple clients) • Offloading work to client CMP 131 Introduction to Computers and Programming

  19. Hardware/Software Concepts • Computers manipulate instructions and data • Represented in similar ways • Used in different ways • Representation is binary (digital hardware is binary) • Numbers vs. symbols • Computers represent everything as numbers • But numbers can represent symbols • Can perform “symbolic” computation • Beginning of Artificial Intelligence CMP 131 Introduction to Computers and Programming

  20. HW/SW Concepts: Data • What is it? • Numbers, characters, images, or other method of recording • Can be assessed by a human or (especially) input into a computer, stored and processed there, or transmitted on some digital channel. • Nearly always represent data in binary. • Has no meaning on its own. • When interpreted by data processing system it takes on meaning and becomes information. • Storage • Setting of individual bits to specific values, destroying its previous contents • Retrieval • Copying the contents of a particular memory cell to another storage area. • Original data remains unchanged CMP 131 Introduction to Computers and Programming

  21. HW/SW Concepts: Representation • Digit / Bit • Smallest unit of information/storage, sufficient to hold one bit • Can take one of two values (true/false, 1/0, or yes/no) • Corresponds to an input/output being on or off • Byte • Smallest addressable unit of storage • Usually 8 bits • Typically holds one character • Can represent 256 different values CMP 131 Introduction to Computers and Programming

  22. HW/SW Concepts: Representation • Word • Fundamental unit of storage in a computer • Word size is one of its chief distinguishing characteristics of a computer • Typical size in modern computers: 32 bits (4 bytes) or 64 bits (8 bytes) • An instruction is usually one or more words long • A word can be used to hold a whole number of characters CMP 131 Introduction to Computers and Programming

  23. Decimal Number System • A base 10 system • Each digit position can hold 10 values (0-9)Ex. 1234 = 4*1 + 3 * 10 + 2*100 + 1*1000= 4*100 + 3 * 101 + 2*102 + 1*103 CMP 131 Introduction to Computers and Programming

  24. Binary Number System • A base 2 system • Each digit position can hold 2 values (0-1)Ex. 1011 • Decimal conversion • Equals: 1*20 +1*21 +0*22 + 1*23 • Equals: 1 + 2 + 0 + 8 = 11 • Maximum number of values in 4 bits: 16 • 0 to 15 • Maximum number of values in 8 bits: 256 • 0 to 255 [or -128 to 127] • This is how much you can store in a byte CMP 131 Introduction to Computers and Programming

  25. Binary Numbers CMP 131 Introduction to Computers and Programming

  26. Binary Addition 10 + 5 =------15 1010 +0101 =---------1111 1010 +0011 =---------1101 10 + 3 =------13 10 + 7 =------17 => 1 1010 +0111 =---------0001 OVERFLOW!!! CMP 131 Introduction to Computers and Programming

  27. Other Number Systems • Hexadecimal: base 16 • Each digit can hold 16 values (0-9,A-F) • Ex: A02F • Decimal conversion? • Note: 1 hex digit = 4 binary digits • Octal: base 8 • Each digit can hold 8 values (0 to 7) • Ex: 127 • Decimal conversion? CMP 131 Introduction to Computers and Programming

  28. Logical Operations • AND: • 1 AND 1 = 1 • Everything else = 0 • OR • 0 AND 0 = 0 • Everything else = 1 • XOR (Exclusive OR) • 0 AND 1 = 1 • 0 AND 0 = 0, 1 AND 1 = 0 CMP 131 Introduction to Computers and Programming

More Related