1 / 63

CPS120: Introduction to Computer Science

This resource provides an overview of computer processors, machine language, and assembly language. It covers topics such as instruction formats, addressing modes, and program design. Additionally, it introduces flowcharts, pseudocode, and boolean logic gates.

hmcdonald
Download Presentation

CPS120: Introduction to Computer Science

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. CPS120: Introduction to Computer Science Midterm Exam Review

  2. Introduction To Computers

  3. Machine Language • Every processor type has its own set of specific machine instructions • The relationship between the processor and the instructions it can carry out is completely integrated • Each machine-language instruction does only one very low-level task

  4. Assembly Language • Assembly languages: assign mnemonic letter codes to each machine-language instruction • The programmer uses these letter codes in place of binary digits • A program called an assembler reads each of the instructions in mnemonic form and translates it into the machine-language equivalent

  5. Instruction Format Difference between immediate-mode and direct-mode addressing

  6. Some Sample Instructions Subset of Pep/7 instructions

  7. Figure 7.5 Assembly Process

  8. Algorithm and Program Design

  9. Top-Down Design • This process continues for as many levels as it takes to expand every task to the smallest details • A step that needs to be expanded is an abstract step An example of top-down design

  10. A General Example • Planning a large party Subdividing the party planning

  11. Flowchart • A graphical representation of an algorithm.

  12. Pseudocode • Uses a mixture of English and formatting to make the steps in the solution explicit

  13. Logic Flowcharts • These represent the flow of logic in a program and help programmers “see” program design.

  14. Common Flowchart Symbols Terminator. Shows the starting and ending points of the program. A terminator has flow lines in only one direction, either in (a stop node) or out (a start node). Data Input or Output. Allows the user to input data and results to be displayed. Processing. Indicates an operation performed by the computer, such as a variable assignment or mathematical operation. With a heading – an internal subroutine Decision. The diamond indicates a decision structure. A diamond always has two flow lines out. One flow lineout is labeled the “yes” branch and the other is labeled the “no” branch. Predefined Process. One statement denotes a group of previously defined statements. Such as a function or a subroutine created externally Connector. Connectors avoid crossing flow lines, making the flowchart easier to read. Connectors indicate where flow lines are connected. Connectors come in pairs, one with a flow line in and the other with a flow line out. Off-page connector. Even fairly small programs can have flowcharts that extend several pages. The off-page connector indicates the continuation of the flowchart on another page. Just like connectors, off-page connectors come in pairs. Flow line. Flow lines connect the flowchart symbols and show the sequence of operations during the program execution. Common Flowchart Symbols

  15. How to Draw a Flowchart • There are no hard and fast rules for constructing flowcharts, but there are guidelines which are useful to bear in mind.Here are six steps which can be used as a guide for completing flowcharts. • Describe the purpose of the program to be created (this is a one-line statement) • Start with a 'trigger' event (it may be the beginning of the program) • Initialize any values that need to be defined at the start of the program • Note each successive action concisely and clearly • Go with the main flow (put extra detail in other charts -- this is the basis of structured programming) • Follow the process through to a useful conclusion (end at a 'target' point -- like having no more records to process)

  16. Pseudocode for a Generalized Program START Intialize variables LOOP While More records do READ record PROCESS record PRINT detail record ENDLOOP CALCULATE TOTALS PRINT total record END

  17. Rules for Pseudocode • Make the pseudocode language-independent • Indent lines for readability • Make key words stick out by showing them capitalized, in a different color or a different font • Punctuation is optional • End every IF with ENDIF • Begin loop with LOOP and end with ENDLOOP • Show MAINLINE first; all others follow • TERMINATE all routines with an END instruction

  18. Gates and Boolean Logic

  19. Gates • Six types of gates • NOT • AND • OR • XOR • NAND • NOR

  20. NOT Gate • A NOT gate accepts one input value and produces one output value Various representations of a NOT gate

  21. NOT Gate • By definition, if the input value for a NOT gate is 0, the output value is 1, and if the input value is 1, the output is 0

  22. AND Gate • An AND gate accepts two input signals • If the two input values for an AND gate are both 1, the output is 1; otherwise, the output is 0 Various representations of an AND gate

  23. OR Gate • If the two input values are both 0, the output value is 0; otherwise, the output is 1 Figure 4.3 Various representations of a OR gate

  24. XOR Gate • XOR, or exclusive OR, gate • An XOR gate produces 0 if its two inputs are the same, and a 1 otherwise • Note the difference between the XOR gate and the OR gate; they differ only in one input situation • When both input signals are 1, the OR gate produces a 1 and the XOR produces a 0

  25. XOR Gate Various representations of an XOR gate

  26. NAND and NOR Gates • The NAND and NOR gates are essentially the opposite of the AND and OR gates, respectively Various representations of a NAND gate Various representations of a NOR gate

  27. Review of Gate Processing • A NOT gate inverts its single input value • An AND gate produces 1 if both input values are 1 • An OR gate produces 1 if one or the other or both input values are 1

  28. Review of Gate Processing (cont.) • An XOR gate produces 1 if one or the other (but not both) input values are 1 • A NAND gate produces the opposite results of an AND gate • A NOR gate produces the opposite results of an OR gate

  29. Adders • At the digital logic level, addition is performed in binary • Addition operations are carried out by special circuits called, appropriately, adders

  30. Adders • The result of adding two binary digits could produce a carry value • Recall that 1 + 1 = 10 in base two • A circuit that computes the sum of two bits and produces the correct carry bit is called a half adder

  31. Adders • Circuit diagram representing a half adder • Two Boolean expressions: sum = A  B carry = AB Page 103

  32. Adders • A circuit called a full adder takes the carry-in value into account A full adder

  33. Computer Mathematics

More Related