1 / 59

Week 7 (Unit 6)

q. Week 7 (Unit 6). What you should do this week?. Read Unit 6. Outline. Unit 6 What ’ s next Some review questions Your questions. Unit 6 : Five Themes. Distinguishing: Computer as a system that is made up of Software, Hardware and Firmware.

maxwell
Télécharger la présentation

Week 7 (Unit 6)

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. q Week 7 (Unit 6) AOU Leb. - F08 - M150 - Unit 6

  2. What you should do this week? • Read Unit 6 AOU Leb. - F08 - M150 - Unit 6

  3. Outline • Unit 6 • What’s next • Some review questions • Your questions AOU Leb. - F08 - M150 - Unit 6

  4. Unit 6: Five Themes • Distinguishing: Computer as a system that is made up of Software, Hardware and Firmware. • Describing: Functions of different components of a computer ( memory, OS, mother board, etc….). • Collaborating: Different computer components to process a computer program. • Understanding: How computer understand our commands???!!!. • Introducing: The mechanism of how the software is going to skip or repeat a sequence of instructions AOU Leb. - F08 - M150 - Unit 6

  5. Unit 6: Agenda • Hardware, Software and Computer system • The resources of a computer , and how they are managed. • Running a program. • Types of programming languages. • The structure of computer programs. AOU Leb. - F08 - M150 - Unit 6

  6. Unit 6: Hardware, Software and Computersystem • Hardware vs. Software • Computer Hardware and Software components work together in order to execute computer program • Hardware: describes the physical parts of computer that can be touched. • Software: describes the information or the programming the computer uses, you can't touch it AOU Leb. - F08 - M150 - Unit 6

  7. Unit 6: Firmware • a software program or set of instructions programmed on a hardware device (usually in the ROM) • It provides the necessary instructions for how the device communicates with the other computer hardware • can be thought of as "semi-permanent" since it remains the same unless it is updated AOU Leb. - F08 - M150 - Unit 6

  8. Unit 6: Example1 "I bought a 100-pack of empty DVD discs and tried to burn a video to a few of them but it would not work". I contacted my DVD drive manufacturer and they suggested that I update the firmware on the DVD drive. The updated Firmware had a new set of computer code for my drive instructing how to write to the DVD I’m using AOU Leb. - F08 - M150 - Unit 6

  9. Unit 6: Hardware Vs. Software • Although Hardware and Software are different in nature, there are related. • A solution to a computer problem can be implemented using either Hardware or Software. • Hardware uses several tangible electronic circuits. • Software uses instructions to use same circuits. AOU Leb. - F08 - M150 - Unit 6

  10. Unit 6: Reflection 1 EX: 2.3 A book could be thought of as being made of paper and ink, or it could be thought of as being a collection of words and sentences. Which view is analogous to Software and which to Hardware? AOU Leb. - F08 - M150 - Unit 6

  11. Unit 6: Computer as a system • The tutor asked us to define computer, after a discussion the result was a computer is a machine that Accepts input, Process Input then it gives a result as an Output. • So every machine that Accepts input, Processes that input, and produces Output is called a system Perfect Then my mother’s Washing machine is a system Yes Or No AOU Leb. - F08 - M150 - Unit 6

  12. Unit 6: Agenda • Hardware, Software and Computer system • The resources of a computer, and how they are managed. • Running a program. • Types of programming languages. • The structure of computer programs. AOU Leb. - F08 - M150 - Unit 6

  13. Unit 6: Reflection 2 EX:3.1 In what form are the data and Instructions stored in a computer? AOU Leb. - F08 - M150 - Unit 6

  14. Unit 6: CPU – The Heart Of Computer • The Central Processing Unit: (CPU also called processor) is the part of the computer that executes program instructions. It consists of two parts: • 1. The Arithmetic and Logic Unit (ALU) is where all calculations and logical operations are performed. a- Arithmetic operations involve addition, subtraction, multiplication, and division. b- Logic operations basically consist of comparing or combining two values: • All ALUs can compare >, <, and =. • Some ALUs can also compare >=, <=, and <>. • Comparisons can be combined using the logical operations NOT, AND and OR. Truth tables are used to formally define these logical operations. • 2. The Control Unit (CU): The control unit interprets program instructions. The control unit communicates with main memory and with input and output device controllers. The control unit directs the ALU to execute program instructions. AOU Leb. - F08 - M150 - Unit 6

  15. Unit 6: CPU – The Heart Of Computer • The CPU Registers : are high-speed storage locations within the CPU, used for specific tasks: • Memory Data Register(MDR) is used to hold data that are being transferred to or from primary storage. • Memory Address Register (MAR) indicates the location of the data to be stored or retrieved from primary storage. • Instruction Register (IR) holds the instruction being executed. • Program Counter (PC) holds the primary storage address of the next instruction to be executed. • The address held in the PC ,instruction cycle • insures sequential execution of instructions. • Jumps to another part of the program are achieved by instructions, which reset the contents of the program counter. AOU Leb. - F08 - M150 - Unit 6

  16. Unit 6: CPU – The Heart Of Computer • Accumulator (AC) holds the results of ALU operations. • Program Status Register (PS) contains binary flags that signal the results of the previous operation. For example the carry bit will be set to 1 if the last arithmetic operation lost a carry bit, and to 0 otherwise. Other condition codes indicate whether the last result was negative, zero or overflowed. • General-purpose registers are used for different purposes. • The first three registers are used by the control unit and are not accessible to the programmer. • The arrangement of registers define the processor architecture. AOU Leb. - F08 - M150 - Unit 6

  17. Unit 6: Memory • (also called primary storage, internal storage, or main memory). • Memory is the part of the computer that holds data for processing, programs, and information waiting to be output to secondary storage. • There are three main characteristicsof memories: • The capacity of the memory varies in different computers and is measured in bytes. • A byte consists of 8 binary digits called bits. • Each bit can represent binary 0 or binary 1. Each byte represents one character in memory. • There are four commonly used units of memory capacity: AOU Leb. - F08 - M150 - Unit 6

  18. Unit 6: Memory • There are two types of memory chips: • Random access memory (RAM): Data and programs must be loaded from external storage (such as disk) into RAM before it can be used by the processor. RAM is volatile (temporary). • Read only memory (ROM): chips have programs built into them at the factory and cannot be changed by the user, thus they are not volatile. • programmable ROMs (PROM) that can be programmed by the user using special devices to save his own information. • ROM typically contains special instructions to start up the computer, give keyboard keys their special control capabilities and put characters on the screen. AOU Leb. - F08 - M150 - Unit 6

  19. Unit 6: Memory hierarchy • Memory hierarchy: there is a memory hierarchy consisting of primary memory (CPU internal registers, cache memory, main memory) and secondary memory (external devices such as disks) • Cache memory: is a high-speed expensive RAM memory used to store copies of the most frequently accessed information in main memory. • Virtual memory: Virtual memory is a memory system used to increase the effective size of the computers physical main memory. AOU Leb. - F08 - M150 - Unit 6

  20. Unit 6: Secondary (external) storage • We mentioned before that the main memory is volatile (temporary). • If the power is turned off program and data disappear. • External storage is nonvolatile (permanent). • External storage also has much more capacity than the primary memory. • There are two approaches to external storage: sequential access and direct access. • The most widely used external storage media are -- floppy disks, -- hard disks, -- optical disks and -- magnetic tapes. • Disks are direct access storage media, while tapes are sequential access storage media. AOU Leb. - F08 - M150 - Unit 6

  21. Unit 6: Operating System • Is the most important system software component. • It interacts between the application software and the computer and manages the computer’s internal resources. • Within the OS, besides the kernel, there is a group of other programs called utility programs, that perform common tasks, such as formatting disks, copy files from other disks, backup disks, remove and rename files, and others. • Mainframes and minicomputers have powerful OS, including virtual memory, multiprogramming and multiprocessing, where many users can run different programs at the same time. Microcomputer OS focus on a single user. • The most important operating systems are: DOS, Microsoft Windows, Unix, Linux and MAC. AOU Leb. - F08 - M150 - Unit 6

  22. Unit 6: Operating System The Operating system has the following functions; • Provision of user interface • Management of the memory • Coordination and control of peripheral devices. • Scheduling access for the processor • Interface between Hardware and computer applications. • Provide basic utilities (disk formatting, file management, etc….). The bootstrap loader:is a program that is stored permanently in the computer’s electronic circuitry in ROM. This process is called booting. AOU Leb. - F08 - M150 - Unit 6

  23. Unit 6: Agenda • Hardware, Software and Computer system • The resources of a computer , and how they are managed. • Running a program. • Types of programming languages. • The structure of computer programs. AOU Leb. - F08 - M150 - Unit 6

  24. Unit 6: The Fetch/execute cycle During the program execution the CPU do the following steps: • Get an instruction from the program. • Find and transfer any data necessary to perform instruction. • Carry out the instruction. The process of locating, transferring and carrying out a single instruction during execution is called fetch/execute cycle. AOU Leb. - F08 - M150 - Unit 6

  25. Unit 6: Continue During each cycle the CPU must: • Locate the next instruction in the program which is stored in the main memory (first one is used if the execution has just started). • Transfer the instruction in to the processor by putting it in a register. • Decode the instruction. • Locate any data located in the main memory which refers to the instruction. • Do the processing. • Place the result in an appropriate register. • If needed move result back to the main memory to be used later. • Increment the program counter by 1. AOU Leb. - F08 - M150 - Unit 6

  26. Unit 6: Example executing Program • Executing Program AOU Leb. - F08 - M150 - Unit 6

  27. ? 2 3 ? 500 501 502 503 Unit 6:Continue operator operand LDA 501 address of a memory location LoaDAccumulator part of the computer's memory The Accumulator Before LDA executes ??? after LDAexecutes 2 AOU Leb. - F08 - M150 - Unit 6

  28. ? 2 3 ? 500 501 502 503 Unit 6:Continue operator operand ADD 502 address of a memory location ADD to Accumulator The Accumulator part of the computer's memory before ADD executes 2 after ADD executes 5 AOU Leb. - F08 - M150 - Unit 6

  29. ? ? 2 2 3 3 5 ? 500 500 501 501 502 502 503 503 Unit 6:Continue operator operand STO 503 address of a memory location STOre Accumulator in memory computer's memory before STO The Accumulator before STO executes computer's memory after STO 5 after STO executes 5 AOU Leb. - F08 - M150 - Unit 6

  30. Unit 6:Continue operator operand HLT 000 dummy value - not used HaLT No effect on accumulator or memory AOU Leb. - F08 - M150 - Unit 6

  31. Unit 6: Agenda • Hardware, Software and Computer system • The resources of a computer , and how they are managed. • Running a program. • Types of programming languages. • The structure of computer programs. AOU Leb. - F08 - M150 - Unit 6

  32. Unit 6: Types of programminglanguages. • Five Generations of Programming Languages GENERATION NAME SAMPLE STATEMENT • First Machine 10010001 • Second Assembly ADD A, B JMP L • Third Procedural and structural Overtime:= 5 0; • Fourth Object oriented FIND NAME "JONES“ • Fifth Natural IF patient is dizzy, THEN check temperature and blood pressure • Computer professionals talk about levels or generations of program­ming languages, ranging from ‘low’ to ‘high.’ Programming languages are called lower level when they are closer to the language the computer itself uses. • The computer understands the 0s and 1s that make up bits and bytes. Programming languages are called higher level when they are closer to the language humans use that is, for English speakers, more like English. AOU Leb. - F08 - M150 - Unit 6

  33. Unit 6: Machine Languages: The First Generation • We mentioned earlier that a byte is made up of bits, consisting of 1s and 0s. • These 1s and 0s may correspond to electricity’s being on or off in the computer. • They may also correspond to a magnetic charge’s being present or absent on storage media such as disk or tape. • Data represented in 1s and 0s is said to be written in machine language. • To see how hard this is to understand, imagine if you had to code this : • 111100100111001111010010000100000111000000101011 • Machine languages also vary according to computer design - another characteristic that makes them hard to work with AOU Leb. - F08 - M150 - Unit 6

  34. Unit 6: Assembly Languages: The Second Generation Assembly languages have a clear advantage over the 1s and 0s of machine language because they use abbreviations or mnemonics. • These are easier for human beings to remember. • The machine language code we gave earlier could be expressed in assembly language as: ADD A, B JMP L • Assembly language is also considered low-level. • Assembly languages also vary from computer to computer. • With the third generation, we advance to high-level languages, many of which are considered portable languages. • That is, they can be run on more than one kind of com­puter—they are “portable” from one machine to another. AOU Leb. - F08 - M150 - Unit 6

  35. Unit 6: High-Level Procedural Languages: The Third Generation • People are able to understand languages that are more • like their own (e.g., English) than machine languages or assembly languages. These more English-like programming languages are called “high-level” languages. • However, most people still require some training in order to use higher-level languages. This is particularly true of procedural languages. • Procedural languages are programming languages with names like BASIC, Pascal, C, COBOL, and FORTRAN. • They are called “procedural” because they are designed to express the logic—the procedures—that can solve general problems. • For a procedural language to work on a computer, it must be translated into machine language Depending on the language, this translation is performed by either a compiler or an interpreter. AOU Leb. - F08 - M150 - Unit 6

  36. Unit 6: High-Level Procedural Languages: The Third Generation • A compiler converts the programmer’s procedural language program, called the source code; into a machine language code, called the object code. • An interpreter converts the procedural language one statement at a time into machine code just before it is to be executed. No object code is saved. What is the difference between using a compiler and using an interpreter? • When a program is run, the compiler requires two steps. The first step is to convert the entire program’s source code to object code. • The second step is to run the object code. The interpreter, in contrast, converts and runs the program one line at a time. • The advantage of a compiler language is that once the object code has been obtained, the program executes faster. • The advantage of an interpreter language is that programs are easier to develop. AOU Leb. - F08 - M150 - Unit 6

  37. Unit 5: Problem-Oriented Languages: The Fourth Generation • Third-generation languages are valuable, but they require training in program­ming. • Object-oriented languages, also known as very high-level languages, require little special training on the part of the user. • Unlike general-purpose languages, object-oriented languages are designed to solve specific problems. Some of these fourth-generation languages are used for very specific applications. Many consider Lotus 1-2-3 and dBASE to be flexible fourth-generation languages. • Query languages: Query languages enable nonprogrammers to use certain easily understood commands to search and generate reports from a database. An example is the commands used on an airline reservations system AOU Leb. - F08 - M150 - Unit 6

  38. Unit 6: Natural Languages: The Fifth Generation • Natural languages are still being developed. • They are designed to give people a more human (“natural”) connection with computers. • The languages are human languages: English, French, Japanese, or whatever. • Researchers also hope that natural languages will enable a computer to learn — to “remember” information, as people do, and to improve upon it. • Clearly this area is extremely challenging. AOU Leb. - F08 - M150 - Unit 6

  39. Unit 6: Agenda • Hardware, Software and Computer system • The resources of a computer , and how they are managed. • Running a program. • Types of programming languages. • The structure of computer programs. AOU Leb. - F08 - M150 - Unit 6

  40. Unit 6: The basic building blocks of computer programs • All programs can be built from three logical building blocks • Selection/ifs • If the traffic in the high street is heavy • take the first left • take the first right • take the first left • else • follow the high street to the end • Repetition/loops • while you have not yet reached the turnoff for Little Whamping • go straight ahead at each roundabout • Sequence • Take the first left • Take the second right • Take the third exit at the roundabout AOU Leb. - F08 - M150 - Unit 6

  41. Unit 6:Continue • Let's not worry about the programming language for a while • The syntax for how you do sequence, selection and repetition varies from programming language to programming language but the basic structures stay the same. • Once you have the concepts clear you can apply them to any language (JavaScript, Java, Visual Basic, C#, C++, Perl etc etc) AOU Leb. - F08 - M150 - Unit 6

  42. Unit 6: Sequence • The only thing to worry about is getting the instructions in the correct order buy a stamp post the envelope put the card in the envelope write in the birthday card buy a birthday card address the envelope • Put these instructions into a logical sequence for Robbie the willing but slightly dim robot! AOU Leb. - F08 - M150 - Unit 6

  43. Unit 6: Selection • A selection instruction allows you to write programs (and remember programs are basically just plans) that will operate in different ways depending on circumstances If I win the lottery this Saturday I'll tell my boss what I think of her on Monday otherwise I'll start an OU degree and get a better job in a couple of years AOU Leb. - F08 - M150 - Unit 6

  44. Unit 6: True or false • Selection always includes a condition that can be evaluated when the program runs (i.e. the plan is executed) to be true or false (this is called a Boolean expression). • The truth or falsity of the condition determines which path is taken. a "flow chart" I win the lottery this Saturday True False The condition is like a fork in the road determining which path you take tell my boss what I think of her on Monday start an OU degree AOU Leb. - F08 - M150 - Unit 6

  45. Unit 6: Selection exercises • If Charlton Athletic stay in the premiership next season I'll renew my season ticket. Otherwise I'll spend my money on getting Sky instead. • Identify the condition and draw a flow chart diagram AOU Leb. - F08 - M150 - Unit 6

  46. Unit 6: Repetition • A repetition instruction allows one or more instructions to be repeated a number of times. While I've got a chance of winning I'll keep putting one foot in front of the other I've got a chance of winning False True put one foot in front of the other Sorry Paula! AOU Leb. - F08 - M150 - Unit 6

  47. Unit 6: Repetition exercise I'm getting Robbie to plant tulip bulbs in the garden. I've given him a bag of bulbs and told him that while there are still any left in the bag he should take one out, dig a hole for it and put it in. • Draw a flow chart representing my instructions to Robbie. What's wrong with these instructions for Robbie • To make cups of tea for the family repeat the following actions: • put milk in cup • put teabag in cup • pour in boiling water AOU Leb. - F08 - M150 - Unit 6

  48. Unit 6: Conditions again • Important observation: both selection and repetition are controlled by conditions that can be evaluated to true or false (i.e. Boolean expressions). • Selection - which path should I follow? • Repetition - how often should I go round the loop? • Because Boolean expressions are of crucial importance a considerable chunk of Unit 6 section 6 is devoted to them. AOU Leb. - F08 - M150 - Unit 6

  49. Unit 6: Compound conditions • Often we want to combine separate conditions when using them to control a selection or a repetition e.g. if (the customer is over 64 or the customer is under 18) charge them reduced rate else charge them full rate AOU Leb. - F08 - M150 - Unit 6

  50. Unit 6: Evaluating compound conditions • You have to evaluate the separate parts and combine them according to rules in order to evaluate the truth or falsity of the overall expression true/false true/false true/false (the customer is over 64 or the customer is under 18) • The rules used to combine the separate parts depend on the operator used. In this case the operator is or. AOU Leb. - F08 - M150 - Unit 6

More Related