COMP 14 Introduction to Programming Miguel A Otaduy May 12 2004 from Last Time Homework 1 due Tomorrow Fill in form with personal info Getting started with jGRASP Compile and Run test programs Any problems Disable test for new versions Today ch 1 Parts of the computer hardware vs software CPU and memory Binary numbers What is an algorithm Reading Check Up 1 2 3 4 or hardware computer components including the CPU main memory I O devices and secondary storage CPU the brain of the computer containing the CU PC IR ALU and ACC computer instructions to solve a program problem The digits 0 and 1 are called binary digits the shortened term bits Hardware vs Software A computer is made up of hardware and software Hardware Software CPU operating systems ex 1 GHz Pentium III Windows XP input output Mac OS X keyboard monitor applications network card games main memory Microsoft Word ex 256 MB RAM Internet Explorer secondary memory ex 20 GB hard drive Hardware Organization CPU memory motherboard hard drive Central Processing Unit CPU Control Unit CU the brain of the CPU Program Counter PC points to the next instruction to be executed Instruction Register IR holds the currently executing instruction Arithmetic Logic Unit ALU carries out all arithmetic and logical ops Accumulator ACC holds the results of the operations performed by the ALU Main Memory Ordered sequence of cells AKA Random Access Memory RAM Directly connected to the CPU All programs must be brought into main memory before execution When power is turned off everything in main memory is lost Main Memory With 100 Cells Each memory cell has a numeric address which uniquely identifies it CPU and Main Memory All programs must be brought into main memory before execution Primary storage area for programs and data that are in active use RAM Chip that executes program instructions processor Secondary Storage Provides permanent storage for information Retains information even when power is off Examples of secondary storage Hard Disks Floppy Disks ZIP Disks CD ROMs Tapes Secondary Storage Secondary memory devices provide long term storage Information is moved between main memory and secondary memory as needed Input Devices Definition devices that feed data and computer programs into computers Examples Keyboard Mouse Secondary Storage Output Devices Definition devices that the computer uses to display results Examples Printer Monitor Secondary Storage Input Output Devices I O devices facilitate user interaction Hardware Components Opening MS Word Use the mouse to select MS Word The CPU requests the MS Word application MS Word is loaded from the hard drive to main memory The CPU reads instructions from main memory and executes them one at a time MS Word is displayed on your monitor Questions 1 program counter PC points to the next instruction to be executed 2 address a unique location in memory 3 secondary storage stores information permanently 4 Instructions executed by the CPU must be first loaded to main memory Software Categories Operating System controls all machine activities provides the user interface to the computer first program to load when a computer is turned on manages computer resources such as the CPU memory and hard drive examples Windows XP Linux Mac OS X Application generic term for any other kind of software examples word processors missile control systems games Operating System OS OS monitors overall activity of the computer and provides services Written using programming language Example services memory management input output storage management Application Programs Written using programming languages Perform a specific task Run by the OS Example programs Word Processors Spreadsheets Games Questions Classify the following pieces of software as operating system or application 1 2 3 4 Microsoft Windows 2000 Microsoft PowerPoint Linux Your COMP 14 programs OS app OS app It s All About Data Software is data numbers characters instructions programs Hardware stores and processes data read write add subtract multiply divide Analog vs Digital Analog continuous wave forms ex sound music on an audio tape Digital the information is broken down into pieces and each piece is represented separately represented as series of 0 and 1 0 low voltage 1 high voltage can be copied exactly ex music on a compact disc Representing Text Digitally All information in a computer is digitized broken down and represented as numbers Hi 72 105 44 32 Heather 72 101 97 116 104 101 Corresponding upper and lower case letters are separate characters 114 46 Language of a Computer Machine language the most basic language of a computer A sequence of 0s and 1s binary digit or bit sequence of 8 bits is called a byte Every computer directly understands its own machine language why can t Windows programs run on Apple computers Bit Permutations 1 bit 0 1 2 bits 00 01 10 11 3 bits 000 001 010 011 100 101 110 111 4 bits 0000 1000 0001 1001 0010 1010 0011 1011 0100 1100 0101 1101 0110 1110 0111 1111 Each additional bit doubles the number of possible permutations Bit Permutations Each permutation can represent a particular item There are 2N permutations of N bits N bits are needed to represent 2N unique items 1 bit How many items can be represented by 2 bits 3 bits 4 bits 5 bits 21 2 items 22 4 items 23 8 items 24 16 items 25 32 items Binary Numbers N bits to represent 2N values N bits represent values 0 to 2N 1 Example 5 bits 32 unique values 0 31 00000 0 11111 31 24 23 22 21 20 16 8 4 2 1 Decimal to Binary 114 Place 26 25 24 23 22 21 20 1110010 Digit 1 1 1 0 0 1 0 Value 64 32 16 0 0 2 0 Questions Binary Numbers What s the maximum value a 6 bit number can represent 63 What s the decimal representation of 111010 58 32 16 8 2 What s the binary representation of 35 100011 Storage Capacity Every memory device has a storage capacity indicating the number of bytes 8 bits it can hold Various units Unit kilobyte Symbol KB megabyte MB Number of Bytes 210 1024 220 over 1 million gigabyte GB 230 over 1 billion terabyte TB 240 over 1 trillion Programming Languages Evolution Early computers programmed in machine language only 0s and 1s Assembly languages were developed to make programmer s job easier Assembler translates assembly language instructions into machine language Assembly and Machine Language Programming Languages Evolution High level languages make programming easier Closer to spoken languages Examples Basic FORTRAN COBOL C C Java From Java to Machine Language Computers
View Full Document