1 / 27

ECS15: Introduction to Computers

ECS15: Introduction to Computers. fall 2010 S. Felix Wu Midterm review. Number representation. We are used to counting in base 10:. 1000. 100. 10. 1. 10 3 10 2 10 1 10 0. ….. thousands hundreds tens units. Example:. digits. 1. 7. 3. 2.

Télécharger la présentation

ECS15: Introduction to Computers

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. ECS15:Introduction to Computers fall 2010 S. Felix Wu Midterm review

  2. Number representation We are used to counting in base 10: 1000 100 10 1 103 102 101 100 ….. thousands hundreds tens units Example: digits 1 7 3 2 1000 100 10 1 1x1000+7x100+3x10+2x1 = 1732

  3. Number representation Computers use a different system: base 2: 1024 512 256 128 64 32 16 8 4 2 1 210 29 28 27 26 25 24 23 22 21 20 Example: bits 1 1 0 1 1 0 0 0 1 0 0 1024 512 256 128 64 32 16 8 4 2 1 1x1024+1x512+0x256+1x128+1x64+0x32+ 0x16+ 0x8 + 1x4 + 0x2 + 0x1 = 1732

  4. Hexadecimal numbers While base 10 and base 2 are the most common bases used to represent numbers, others are also possible: base 16 is another popular one, corresponding to hexadecimal numbers 256 16 1 162 161 160 The “digits” are: 0 1 2 3 4 5 6 7 8 9 A B C D E F Example: 2 A F 256 16 1 2x256 + 10*16 + 15x1 = 687

  5. ASCII American Standard Code for Information Interchange So far, we have seen how computers can handle numbers. What about letters / characters? The ASCII code was designed for that: it assigns a number to each character: A-Z: 65-90 a-z: 97-122 0-9: 48-57

  6. Logic: compound propositions Conjunction: The conjunction of two propositions p and q is the proposition p q (read “p and q”) that is true if and only if both p and q are true. Truth table:

  7. The not-and (NAND) gate

  8. The AND gate

  9. The OR gate

  10. The Fetch/Execute Cycle The CPU cycles through a series of operations or instructions, organized in a cycle, the Fetch/Execute cycle: Instruction Fetch (IF) Instruction Decode (DP) Data Fetch (DF) Instruction Execute (IE) Result Return

  11. Step 1: Instruction Fetch Fetch instruction from memory position 2200: Add numbers in memory positions 884 and 428, and store results at position 800

  12. Step 2: Instruction Decode Decode instruction: Defines operation (+), and set memory pointers in ALU

  13. Computer Layers Hardware BIOS Operating System Software Programming languages

  14. BIOS: Basic Input/Output Layer • BIOS refers to the firmware code usually stored on the PROM, EPROM or flash drive that is run by a computer when first powered on. • BIOS performs three major tasks: • First, the Power On Self Tests (POST) are conducted. These tests verify that the hardware system is operating correctly. • - Second, the BIOS initiates the different hardware component of the system, scanning their own ROM or PROM. • - Third, the BIOS initiate the boot process. The BIOS looks for boot information that is contained in file called the master boot record (MBR) at the first sector on the disk. Once an acceptable boot record is found the operating system is loaded which takes over control of the computer.

  15. Computer Layers Hardware BIOS Operating System Software Programming languages

  16. The operating system

  17. The operating system Definition found on Wikipedia: “An operating system (OS) is the software that manages the sharing of the resources of a computer and provides programmers with an interface used to access those resources” Most common operating systems: - DOS (desktops, laptops) - Unix and variants, including Linux (servers) - MacOS

  18. The operating system • Operating systems can be classified as follows: • multi-user : Allows two or more users to run programs at the same time. • -multiprocessing : Supports running a program on more than one CPU. • -multitasking : Allows more than one program to run concurrently. • multithreading : Allows different parts of a single program to run concurrently.

  19. The operating system Memory management: Current computers organize memory resources hierarchically, from registers, CPU cache, RAM and disks. The virtual memory manager coordinates the use of these resources by tracking which one is available, which is to be allocated or deallocated and how to move data between them. If running processes require significantly more RAM than is available, the system may start thrashing.

  20. The operating system Most operating systems come with an application that provides a user interface for managing the operating system, such as a command line interpreter or graphical user interface (GUI). Operating systems provide a software platform on top of which other programs, called application programs, can run. Your choice of operating system determines the applications you can run.

  21. X = X + 5 Assignment X += 5 X: a value Memory box & Assignment X  X+5 X: old value + 5

  22. ADD X, X, const(5) Add 848, 440, 820 ADD X, X, const(5) X . X: a value Memory box & Assignment X  X+5 X: old value + 5

  23. Index Control F T for <integer_variable> in range (start, end, skip): <statement> <statement> (optional) <other statements>

  24. Raw_input Password  Password == “secret” F T “access denied” “access granted” end

  25. Problem solving • Input three numbers • Print these numbers in the ascending order

  26. X <= Y? true: X <= Z? true: // print X Y <= Z? true: print XYZ false: print XZY false: print ZXY false: Y <= Z? true: // print Y X <= Z? true: print YXZ false: print YZX false: print ZYX Input X Input Y Input Z XYZ XZY YXZ YZX ZXY ZYX

More Related