1 / 47

IPC144 Session 2 Computer Organization, Problem Analysis and Program Design

IPC144 Session 2 Computer Organization, Problem Analysis and Program Design. 1. Objectives: By the end of this session, the student will be able to: List the first three stages of the evolution of computer languages Compare the three stages from a programmer's point of view

carr
Download Presentation

IPC144 Session 2 Computer Organization, Problem Analysis and Program Design

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. IPC144 Session 2 Computer Organization, Problem Analysis and Program Design 1

  2. Objectives: By the end of this session, the student will be able to: • List the first three stages of the evolution of computer languages • Compare the three stages from a programmer's point of view • List other 3GL languages • Construct Boolean Logic Charts • Apply Boolean Logic to problems • List the steps in a model Systems Development Life Cycle • Describe the purpose of each of the model steps • List the 7 steps of a model Program Development Cycle • Describe the purpose of each step of the PDC • List the steps that occur when compiling a computer program 4

  3. Software • Software • Software is a set of instructions that cause the computer to perform specific tasks in a specific order, and make simple decisions about the data it encounters. The software must be written by people in order to be supplied to the computer. The software is written in a specialized language. • There have been many generations of computer languages: • machine language • assembly language • high-level language (3GL)‏ • very high-level language (4GL)‏ • natural language 5

  4. Software, continued • Machine Language Software • This software is in the language of the processor. This language is not easily readable by humans as it consists of numbers only. • The instructions will consist of • op-codes (operation codes) and, • operands (sometimes)‏ • Op-codes • The op-codes are fetched and decoded by the Control Unit, and executed by the ALU. • Operands • The operands are either scalar data (a fixed number, such as 5) or a memory address where data is stored. These are also fetched by the Control Unit for use by the ALU. 6

  5. Software, Continued • Machine language for Motorola 6809 (8-bit CPU)‏ • 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F 10 11 12 • 4F 9713961227094A 971296139B1120F13E02 05 • address • op-code • operand • data • The above program multiplies two numbers by repeated addition. • i.e.: 5 x 2 = 2 + 2 + 2 + 2 + 2 7

  6. Software, Continued Assembly language This is a small step forward. The numeric instructions from machine language have been replaced by mnemonics. This makes the programs must easier to read, however it still takes patience and a disciplined approach. There are some pockets of assembly programming that still exist. The mnemonics are designed for each individual processor, however there are some mnemonics that you may see from processor to processor. These mnemonics are not understood by the computer, so a simple program, called an Assembler, converts the mnemonics to numbers, and ultimately you end up with machine language. The advantage of assembly is that the programs written are very compact and run very fast. 8

  7. Software, Continued Assembly language for Motorola 6809 (8-bit CPU)‏ 00004FCLRA 000197 13:LOOP STA @13 000396 12LDA @12 000527 09BEQ :DONE 00074ADECA 000897 12 STA @12 000A96 13LDA @13 000C9B 11ADD @11 000E20 F1BRA :LOOP 000F3E:DONE HLT 001102 001205 0013 Address Machine Language (output from assembler)‏ Assembly Language (written by programmer)‏ 9

  8. Software, continued High-level language There are many high-level languages that exist. In these languages, the programmer is using something that almost passes as a human language. However, programs written in these languages must be converted to machine language. The advantage to these languages is that there are relatively easy to learn, although you might not believe me when we start talking about C. The disadvantage is that the machine code that is generated is not as optimized as code written directly in machine language. These languages are not specific to a particular processor- therefore they are easily transported from processor to processor. 10

  9. Software, continued High-level language, continued The assembly program in C How it would actually be written in C i = 5; i = 5; j = 2; j = 2; k = 0; k = i * j; while (i > 0)‏ { k = k + j; i--; } 11

  10. Software, continued • High-level language, continued • Other 3GL languages: • TAL (for Tandem computers)‏ • Turing (developed by University of Toronto, to teach well structured programming)‏ • COBOL (a language for business applications)‏ • FORTRAN (FORmula TRANslation - scientific and engineering applications)‏ • PASCAL (a simple well structured language)‏ • BASIC (a simple initially unstructured language for learning programming)‏ 12

  11. Boolean Logic 13

  12. Boolean Logic Boolean logic Developed by George Boole in the 19th century. A form of logical algebra, as opposed to mathematical algebra. We are concerned with TRUE or FALSE values instead of numbers. Sometimes the digits 1 and 0 or the letters T and F are used to represent the values of TRUE and FALSE respectively. The algebra will consist of statements that can be evaluated to being either TRUE or FALSE: 'Today is Saturday' - FALSE 'You are in a lecture' - TRUE 'You are asleep in the lecture' - ?? 14

  13. Boolean Logic, continued Boolean logic, continued The expressions being evaluated will be mathematical expressions in this course: 5 = 6 a > b a + 4 < c - 1 These expressions will evaluate to either TRUE or FALSE depending on the algebraic value of the variables. a > b would be TRUE if 'a' was 5 and 'b' was 4. a > b would be FALSE if 'a' was 4 and 'b' was 5. We can now take the results of the expressions and apply Boolean operators to them. 15

  14. Boolean Logic, continued • Truth Tables • The Boolean algebra is summarized in 'Truth Tables'. There are two sections to the Truth Table: • Conditions • Result • Conditions • There are 1 or more columns in the Conditions section, depending on the number of possible combinations of TRUE and FALSE being tested. • 1 column = 2 possible conditions • 2 columns = 4 possible conditions • 3 columns = 8 possible conditions • n columns = 2n possible conditions • Result • The result column will contain only 1 possible outcome for each condition, the result will be either TRUE or FALSE. 16

  15. Boolean Logic, continued Boolean NOT operator The Boolean NOT operator simply reverses the values of TRUE and FALSE. There is only one possible column in the conditions section: Examples (assuming x is TRUE, y is FALSE): NOT x result is FALSE NOT y result is TRUE NOT (5 < 6) result is FALSE 17

  16. Boolean Logic, continued Boolean OR operator The Boolean OR (also known as Inclusive-OR) looks for any conditions that contains at least one TRUE value: Examples (assuming x is TRUE, y is FALSE): x OR y result is TRUE y OR y result is FALSE x OR x result is TRUE (7 > 8) OR (1 < 2) result is TRUE 18

  17. Boolean Logic, continued Boolean OR operator, continued An extended OR Truth Table 19

  18. Boolean Logic, continued Boolean AND operator The Boolean AND looks for any conditions that contain all TRUE values: Examples (assuming x is TRUE, y is FALSE): x AND y result is FALSE y AND y result is FALSE x AND x result is TRUE (7 > 8) AND (1 < 2) result is FALSE 20

  19. Boolean Logic, continued Boolean AND operator, continued An extended AND Truth Table 21

  20. Boolean Logic, continued Boolean Exclusive-OR operator The Boolean XOR looks for any conditions that contain an odd number of TRUE values: Examples (assuming x is TRUE, y is FALSE): x XOR y result is TRUE y XOR y result is FALSE x XOR x result is FALSE (7 > 8) XOR (1 < 2) result is TRUE 22

  21. Boolean Logic, continued Boolean XOR operator, continued An extended XOR Truth Table 23

  22. Boolean Logic, continued Order of Precedence Just as in mathematics, you have an order of precedence when calculating an expression. What is the result of: 5 + 22 x 2 / 4 + (7 + 6 x 7) - 2 x 7 In Boolean Algebra, the order of precedence, (unless overridden by brackets) is: perform NOT operations first, followed by AND operations, followed by XOR operations, followed by OR. Just like multiplication is transitive in Mathematics, the Boolean AND, OR and XOR are transitive. a x b x c = c x b x a = b x a x c = c x a x b = b x c x a = a x c x b a & b & c = c & b & a = b & a & c = c & a & b = b & c & a = a & c & b What is the Truth Table for: a AND b XOR c? a AND b XOR NOT c OR b? 24

  23. Boolean Logic, continued Order of Precedence What is the Truth Table for: a AND b XOR c? 25

  24. Boolean Logic, continued Order of Precedence What is the Truth Table for: a AND b XOR NOT c OR b? 26

  25. Boolean Logic, continued Exercises 1) What is the Truth Table for: a AND NOT b OR NOT a AND b 2) TRUE AND FALSE OR NOT FALSE Assuming the variables X, Y and Z have been assigned the values 5, 7 and 12 respectively, what is the result (TRUE or FALSE) of the following expressions: 3) X = 5 4) X < Y 5) X + Y > Z 6) (X > 5) OR (Y > 5)‏ 7) NOT (X = 5)‏ 8) (X + Y > Z) AND (Z < 24) OR NOT (Y < 3)‏ 9) Create an expression that will result in TRUE when any of the variables (A, B, C) are greater than 0. A, B, C can be any number, positive, negative, fractional. 10) Create an expression that will result in FALSE only when all three variables (A, B, C) are equal to 0) A, B, C can be any number, positive, negative, fractional. 27

  26. Boolean Logic, continued • Exercises • 1) What is the Truth Table for: a AND NOT b OR NOT a AND b- see XOR table • 2) TRUE AND FALSE OR NOT FALSE - TRUE • Assuming the variables X, Y and Z have been assigned the values 5, 7 and 12 respectively, what is the result (TRUE or FALSE) of the following expressions: • 3) X = 5 - TRUE • 4) X < Y - TRUE • 5) X + Y > Z - FALSE • 6) (X > 5) OR (Y > 5) - TRUE • 7) NOT (X = 5) - FALSE • 8) (X + Y > Z) AND (Z < 24) OR NOT (Y < 3) - TRUE • 9) Create an expression that will result in TRUE when any of the variables (A, B, C) are greater than 0 - (A>0) OR (B>0) OR (C>0)‏ • 10) Create an expression that will result in FALSE only when all three variables (A, B, C) are equal to 0) - NOT (A=0) OR NOT(B=0) OR NOT (C=0)‏ 28

  27. Systems Development Life Cycle 29

  28. Systems Development Life Cycle • Background • As systems become more complex, and businesses become more reliant on computers, means to structure the way new software is delivered is needed. There are two aspects that will be discussed: • System Development Life Cycle • Program Development Cycle • The Program Development Cycle is a subset of the System Development Life Cycle. • The following slides will provide an overview of SDLC and PDC. The section on PDC will be investigated closer for the remainder of the course. 30

  29. Systems Development Life Cycle • System Development Life Cycle • The steps of the System Development Life Cycle are: • Analyse System • Define System Requirements • Design New System • Develop New System • Accept New System • Implement System • These steps are guidelines, and are not cast in stone. Each company will have some variation of these steps. There may be more steps, or some steps will be combined. 31

  30. Systems Development Life Cycle • SDLC: Analyse System • Performed on existing manual systems as well as existing automated systems • Performed by System Analyst • Most effectively performed by interviewing the users • Identify what is done, and how • Identify any problems with current system • Go-No Go Decision based on ROI estimates 32

  31. Systems Development Life Cycle • SDLC: Define System Requirements • What changes are required • System Analyst works with Business Analyst • Develop 'look and feel' of new system • Determine what needs to be done (not how)‏ • Every input, output and process is documented: • Output: reports, screen designs • Input: what data, where does it come from • Process: what activities are required to produce the output • Go-No Go Decision 33

  32. Systems Development Life Cycle • SDLC: Design New System • Define all programs, files, databases, manual processes • System Flowcharts are a common tool • Like a program flowchart • Major inputs • Major outputs • Inter-relationships between entities in system • No details as to how the programs work 34

  33. Systems Development Life Cycle • SDLC: Develop New System • Involves designing, coding and unit-testing • Uses Program Development Cycle • Goal is high-quality well structured programs • Main focus of the remainder of this course 35

  34. Systems Development Life Cycle • SDLC: Accept New System • Performed by Business user or Representative who has intimate knowledge of Business functionality of the system • Entire system is tested to ensure it conforms to the System Requirements (Phase 2)‏ • Assumes no knowledge of internal workings of system • System documentation reviewed • Implementation strategies discussed • Users trained 36

  35. Systems Development Life Cycle • SDLC: Implement New System • When the new system is implemented into the production environment • Evaluation of new system (comparison between the expected objectives and the actual results)‏ • Results of the evaluation may become the input to a subsequent SDLC 37

  36. Program Development Cycle 38

  37. Program Development Cycle • Program Development Cycle • The steps of the Program Development Cycle are: • Define the Problem • Outline the Solution • Develop the Solution into an Algorithm • Test the Algorithm for Correctness • Code the Program into a Specific Language (C)‏ • Run the Program on the Computer • Document and Maintain the Program • These steps are guidelines, and are not cast in stone. Each company will have some variation of these steps. There may be more steps, or some steps will be combined. 39

  38. Program Development Cycle • PDC: Define the Problem • Must have a clear understanding of the problem • There is no room for assumptions • There is no difference between solving the wrong problem correctly and solving the right problem incorrectly • To help with analysis, the problem should be broken into: • Inputs • Outputs • Processes • IPO Charts are a tool used 40

  39. Program Development Cycle • PDC: Outline the Solution • Break problem into smaller tasks or steps • Create a rough draft of the solution, may include • Major processing steps • Major sub-tasks (if any)‏ • Major control structures (repetition loops)‏ • Major variables and record structures • Mainline logic of the program • Top-down design • Modularity and Hierarchy charts are tools used 41

  40. Program Development Cycle • PDC: Develop the Outline into an Algorithm • Computers cannot devise a plan or decide to act • Computers can only do what they are told, exactly the way they are told • Computers do what you tell them to do, not what you want them to do • An algorithm is a set of precise instructions which describe the task to be performed and the order in which they are to be carried out • Flowcharts and Pseudocode are tools to be discussed 42

  41. Program Development Cycle • PDC: Test the Algorithm for Correctness • One of the most important steps • Identifies major logic errors • Walkthroughs are a technique for testing • Test plans are used to document and plan the tests necessary to prove your algorithm performs as required 43

  42. Program Development Cycle • PDC: Code the Program • Performed only after previous design considerations have been complete • In this course the C language will be used, although these techniques can be used for any language (Fortran, COBOL, BASIC, Pascal, Turing, TAL...)‏ • Unfortunately, this is where many people begin PDC or SDLC 44

  43. Program Development Cycle • PDC: Run the Program • Most will find this the most rewarding step • This step involves the compiler, which will identify syntax errors and some basic coding/logic errors • Further testing takes place against a Test Plan • Can be very frustrating if the design and testing is incomplete before the coding is performed • May need to be performed several times 45

  44. Program Development Cycle • PDC: Document and Maintain Program • Documentation is an ongoing task throughout the PDC • External Documentation • Internal Documentation • Maintenance takes place during the life of the program, due to: • Enhancements (new functionality, new requirements)‏ • Bugs 46

  45. Compile Process 47

  46. Compile Process Compile Process As mentioned, a high-level language must be converted to machine language. This process is referred to as compiling the program. The program is a file that contains instructions written in the high-level language. It is used as data to the compiler, which generates machine language. 48

  47. Compile Process Compile Process The compile process starts by taking the source file (the file containing the high-level instructions) and converts it into an object file. The object file contains some machine language and some points that additional code needs to be attached to. The object file is linked into the operating system, and the final result is an executable file containing the machine language instructions ready to run. Compiler Translator Linker Object File Source file (3GL Language Text File)‏ Executable file Library files (for O/S)‏ 49

More Related