computer basics
play

Computer Basics and software. Hardware includes the tangible parts - PDF document

1/6/16 Hello Hello World World Hardware and Software Computer systems consist of hardware Computer Basics and software. Hardware includes the tangible parts of computer systems. TOPICS Software includes programs - sets of


  1. 1/6/16 Hello Hello World World Hardware and Software § Computer systems consist of hardware Computer Basics and software. § Hardware includes the tangible parts of computer systems. TOPICS § Software includes programs - sets of • Computer Organization instructions for the computer to follow. • Data Representation § Familiarity with hardware basics helps • Program Execution • Computer Languages us understand software. CS 160, Spring Semester 2016 2 Hello Hello World World Computer Organization Hardware § The majority of modern computers have similar components including: § Input devices (keyboard, mouse, etc.) § Output devices (display screen, printer, etc.) § Central Processing Unit (CPU) or processor § Main and auxiliary (secondary) memory CS 160, Spring Semester 2016 3 CS 160, Spring Semester 2016 4 1

  2. 1/6/16 Hello Hello World World Computer Architecture Processors § The processor is also called the CPU (Central Processing Unit) § Processes a relatively simple set of instructions. § Programs must be translated into the specific instruction set. § The power of computing comes from speed and program intricacy. CS 160, Spring Semester 2016 5 CS 160, Spring Semester 2016 6 Hello Hello World World Main memory Auxiliary Memory § Working memory used to store § Also called secondary memory § set of instructions for current program § Disk drives, optical drives (CD/DVD), flash drives, etc. § data the program is using § results of intermediate calculations § More or less permanent (nonvolatile) § Now measured in gigabytes § Usually measured in gigabytes § e.g. 8 gigabytes of RAM § e.g. 512 gigabyte hard drive § RAM is short for random access memory § A byte is a quantity of memory CS 160, Spring Semester 2016 7 CS 160, Spring Semester 2016 8 2

  3. 1/6/16 Hello Hello World World Data Representation Bits, Bytes and Words n Computers store data as binary numbers, not n Bit : 0 or 1 decimal! n Byte : sequence of eight bits: 00101110 n Numbers can be used to represent almost any type of data: n Word : sequence of 2, 4 or 8 bytes § Characters (e.g. ‘a’) are represented by numbers, n To computer, everything is a sequence strings (e.g. “foo”) are just groups of characters of bits! § Pictures are represented by dividing them into picture elements known as pixels n If we have 4 bits, how many things can § Video images or animations are represented by we represent? placing several pictures one after another § Sounds are represented by sampling the pressure wave at regular intervals CS 160, Spring Semester 2016 9 CS 160, Spring Semester 2016 10 Hello Hello World World Bit Permutations Main Memory 1 bit 2 bits 3 bits 4 bits 0 00 000 0000 1000 1 01 001 0001 1001 10 010 0010 1010 11 011 0011 1011 100 0100 1100 101 0101 1101 110 0110 1110 111 0111 1111 Each additional bit doubles the number of possible permutations. CS 160, Spring Semester 2016 11 CS 160, Spring Semester 2016 12 3

  4. 1/6/16 Hello Hello World Bit Permutations World Positional Representation n Each permutation can represent a particular item n Decimal number representation: n There are 2 N permutations of N bits n What does 256 mean? n N bits are needed to represent 2 N unique items 2 * 100 + 5 * 10 + 6 2 * 10 2 + 5 * 10 1 + 6 * 10 0 2 1 = 2 items 1 bit ? n Binary number representation: 2 2 = 4 items How many 2 bits ? items can be n What does 10010 mean? 2 3 = 8 items 3 bits ? represented by 1 * 2 4 + 0 * 2 3 + 0 * 2 2 + 1 * 2 1 + 0 * 2 0 2 4 = 16 items 4 bits ? 1 * 16 + 0 * 8 + 0 * 4 + 1 * 2 + 0 * 0 = 18 2 5 = 32 items 5 bits ? n Let’s count 0 to 15 in binary. How many items can be represented by 8 bits? 16 bits? n Add 1 each time, carry just like in base 10 32 bits? 64 bits? CS 160, Spring Semester 2016 13 CS 160, Spring Semester 2016 14 Hello Hello World World Text Representation ASCII n Remember to a computer everything is stored in a binary format n Need to convert from characters (what is on a keyboard) to bit representation n ASCII: 7 bit mapping in one byte, n Each character maps to different value, n A decimal digit is also a character and has a mapping, e.g., ‘0’ is 00110000 (48 in decimal). CS 160, Spring Semester 2016 15 CS 160, Spring Semester 2016 16 4

  5. 1/6/16 Hello Hello World World Pixels Pixels n Everything is stored as 0’s and 1’s n Pictures are reduced to rectangles, or pixels CS 160, Spring Semester 2016 17 CS 160, Spring Semester 2016 18 Hello Hello World World Animation Sound/Audio CS 160, Spring Semester 2016 19 CS 160, Spring Semester 2016 20 5

  6. 1/6/16 Hello Hello World World Analog to Digital Conversion Files § Large groups of bytes in auxiliary memory are called files. § Files have names and extensions, managed by operating system. § Files are organized into groups called directories or folders. § Java programs are stored in files, and are copied to memory before running. CS 160, Spring Semester 2016 21 CS 160, Spring Semester 2016 22 Hello Hello World World The Operating System Computer Languages n Low-Level Languages § The operating system is a supervisory n Machine Code program that: n Assembly Code n High-Level Languages § oversees the operation of the computer n Fortran § controls resources such as disk drives n COBOL, BASIC n Pascal, C, § retrieves and starts program for you n C++, Java § Well-known operating systems: n Perl, Python n R, Matlab § Microsoft Windows, Apple Mac OS, Linux, n Interpretation versus Compilation and UNIX. n Visual Languages CS 160, Spring Semester 2016 23 CS 160, Spring Semester 2016 24 6

  7. 1/6/16 Hello Hello World World Programming Languages Compilers § A compiler translates a program from a § High-level languages are relatively high-level language to a low-level easy to use for the programmer: language that the computer can run. § Java, C#, C++, Python, Ruby, etc. § You compile a program by running the § Low-level languages are very complex compiler on the source code of the and error prone, but computers don’t high-level program. understand high-level languages! § Compilers produce machine or § High-level language programs must be assembly-language programs called translated into low-level languages. object programs. CS 160, Spring Semester 2016 25 CS 160, Spring Semester 2016 26 Hello Hello World World Java Byte-Code Java Byte-Code § The Java compiler doesn’t translate a § A byte-code program is easy to Java program into assembly or translate into machine language for any machine language for a particular particular computer, this can be done computer. ‘on-the-fly’. § Instead, it translates a Java program § A program called an interpreter into byte-code. translates each byte-code instruction, § Byte-code is the machine language for a executing the resulting machine- hypothetical computer (or interpreter) language. called the Java Virtual Machine. CS 160, Spring Semester 2016 27 CS 160, Spring Semester 2016 28 7

  8. 1/6/16 Hello Hello World World Compiling, Interpreting, Running Portability § Use the compiler to translate the Java § After compiling a Java program into program into byte-code (done using the byte-code, the byte-code can be used javac command). on any computer with a byte-code interpreter without recompiling. § Use the Java virtual machine for your computer to translate each byte-code § Byte-code can be sent over the Internet instruction into machine language. and used anywhere in the world, this makes Java highly portable and thus § Eclipse tool makes all this very easy! suitable for Internet applications. CS 160, Spring Semester 2016 29 CS 160, Spring Semester 2016 30 Hello Hello World World Running a Program Running a program another view 1. First the program and all its data are copied from the word in hard disk into main memory. 2. The CPU goes to the location of the program instruction and reads that word. 3. The CPU determines what action is requested by decoding its bit pattern representation. 4. The CPU performs the action, usually a math operation or memory read/write. 5. The CPU moves to the location of the next program instruction in memory and repeats the process. CS 160, Spring Semester 2016 31 CS 160, Spring Semester 2016 32 8

  9. 1/6/16 Hello Hello World World Instruction Execution Model Instructions n CPU n Format: <operation, operand, operand> n Instruction cycle n Operations n Fetch instruction from main n Arithmetic & logical memory n Data movement n Decode instruction n Control n Fetch operands n Operands: locations of data and instructions n Execute instruction n Examples: n Store operands n Add reg1 reg2 n Determine the next n Move reg1 010010100101001010010100 instruction to execute n Goto 110101110101110101110101 CS 160, Spring Semester 2016 33 CS 160, Spring Semester 2016 34 9

Recommend


More recommend