1 / 22

Program Structure and Design

Program Structure and Design. ELEC 330 Digital Systems Engineering Dr. Ron Hayne. Software Facts. Software Cost Expensive to develop Volume reduces unit cost Software (and documentation) Quality Often poor Inadequate testing (debugging) Programming Difficult Tedious.

iolana
Download Presentation

Program Structure and 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. Program Structure and Design ELEC 330 Digital Systems Engineering Dr. Ron Hayne

  2. Software Facts • Software Cost • Expensive to develop • Volume reduces unit cost • Software (and documentation) Quality • Often poor • Inadequate testing (debugging) • Programming • Difficult • Tedious 330_04

  3. Programmers' Goals Write the shortest program Write the fastest program Write an easily understood program Write and easily modified program Meet the schedule Market Conditions Microprocessor speed increases Chip cost reductions Memory size increases Secondary storage evolution Program Design 330_04

  4. Goals vs. Reality • Write the shortest program • Tricks usually lead to problems • Write the fastest program • Profile and optimize parts that make a difference • Write an easily understood program • Simple straightforward problem solutions • Write an easily modified program • Modifications happen frequently • Meet the schedule • Good software delivered late is often not profitable 330_04

  5. Practical Programming • Don't use a single resource for multiple purposes • Use no intimate knowledge of hardware configuration • Keep the instructions and data separated • Use tables to collect program parameters and data • Only put constant data within instructions • Avoid tricks • Clever use of instructions not easy to alter • Don't write self-modifying programs • Use the instructions in the instruction set well 330_04

  6. Flowchart Symbols 330_04

  7. Example Flowchart 330_04

  8. Structured Programming • Fundamental Program Structures • SEQUENCE • IF-THEN-ELSE • DO-WHILE • Extended Program Structures • DO-UNTIL • IN-CASE-OF 330_04

  9. SEQUENCE Structure 330_04

  10. IF-THEN-ELSE Structure 330_04

  11. PRESS RMB 1 WARNING RMB 1 LIMIT FCB 100  * PRESSURE OVER LIMIT? START LDAA PRESS CMPA LIMIT BHI OVER YES * SET WARNING TO FALSE CLR WARNING BRA LAST * SET WARNING TO TRUE OVER LDAA #$01 STAA WARNING LAST  IF-THEN-ELSE Example Pressureover limit? Set warning to false Set warning to true 330_04

  12. DO-WHILE Structure 330_04

  13. * INITIALIZE NONZERO COUNT START CLR COUNT * INITIALIZE TABLE POINTER LDX #TABLE * TABLE ENTRY ZERO? AGAIN TST 0,X BEQ LAST YES * INCREMENT NONZERO COUNT INC COUNT * ADVANCE POINTER INX BRA AGAIN LAST  DO-WHILE Example Initializenonzero count Initializetable pointer Table entryzero? Yes No Incrementnonzero count Advancepointer 330_04

  14. DO-UNTIL Structure 330_04

  15. IN-CASE-OF Structure 330_04

  16. Start Module 1 Module 1 Module 2 Task 1 Task 2 Module 2 End 1 Task 3 End End 2 Top Down Design 330_04

  17. Top/Down Design • Develop flow charts in order, top first • Start coding after all levels are developed • Run program modules as soon as practical • Use structured programming in each module • Comment as you code, in accordance with flowcharts • Include program structure info in your comments • Keep flowchart symbols at functional level • Keep flowcharts independent of hardware • No more than ten symbols per flowchart • Make flowcharts conform to structured programming 330_04

  18. ************************** ** Program Name ** Description ************************** ** Data Section ************************** ORG $10 DATA1 RMB 2 Comment * ************************** ** Program Section ************************** ORG $E010 Start Module 1 Module 2 End Top/Down Assembly Language 330_04

  19. *------------------------- * Module 1 *------------------------- * Task 1 * Subtask 1a START LDD #0000 STD DATA1 * Subtask 1b LDAA DATA2 * Task 2  *------------------------- Module 1 Task 1 Task 2 End 1 Top/Down Assembly Language 330_04

  20. Top/Down Design Teams • Teams of people write most programs • Flowcharts and written materials document design • Interaction between program modules very important • Team members work on different modules • Structured programming necessary to ensure modules will fit together 330_04

  21. Top/Down Implementation • Start writing and running the program soon after starting the design • Start writing the program even before designing the lower levels • Dummy modules called stubs • Program Testing • Running and demonstrating the program containing stubs checks the design, overall function and initial coding • Stubs replaced by actual modules as they are developed 330_04

  22. Summary • Program Design • Flowcharts • Structured Programming • Top/Down Design 330_04

More Related