Structured Programming

Slides:



Advertisements
Similar presentations
Control Structures Ranga Rodrigo. Control Structures in Brief C++ or JavaEiffel if-elseif-elseif-else-end caseinspect for, while, do-whilefrom-until-loop-end.
Advertisements

Recitation 1 Session 5 + handout Ishani Chakraborty.
CPS3340 COMPUTER ARCHITECTURE Fall Semester, /15/2013 Lecture 11: MIPS-Conditional Instructions Instructor: Ashraf Yaseen DEPARTMENT OF MATH & COMPUTER.
1 ILP (Recap). 2 Basic Block (BB) ILP is quite small –BB: a straight-line code sequence with no branches in except to the entry and no branches out except.
Chapter 10 Code Optimization. A main goal is to achieve a better performance Front End Code Gen Intermediate Code source Code target Code user Machine-
IT253: Computer Organization Lecture 6: Assembly Language and MIPS: Programming Tonga Institute of Higher Education.
Homework Any Questions?. Statements / Blocks, Section 3.1 An expression becomes a statement when it is followed by a semicolon x = 0; Braces are used.
Chapter 8 (Control Structure) Slide 1 Control Structures Control structures are used by the programmer to incorporate the desired sequence of execution.
Control Structures. Hierarchical Statement Structure Standard in imperative languages since Algol60. Exceptions: Early FORTRAN, COBOL, early BASIC, APL.
Translating high level language into machine code
Chapter 8 . Sequence Control
Quiz (Representative of what might appear on a test, see posted sample tests.) Instruction formats and addressing modes.
Programming Languages CPS120: Introduction to Computer Science Lecture 5.
 2003 Prentice Hall, Inc. All rights reserved. 1 Dijkstra Letter Quotes...the quality of programmers is a decreasing function of the density of go to.
IT253: Computer Organization Lecture 4: Instruction Set Architecture Tonga Institute of Higher Education.
GOTO CONSIDERED HARMFUL Tarana Yar. The publishing of the paper entitled “Go To Statement Considered Harmful”, written by Edsger W. Dijkstra in 1968,
1 Homework / Exam Turn in HW3 today Exam 1 next class –Open Book / Open Notes –Recommended Use of Book / Notes in Exam: Avoids reliance on “rote memorization”
Lecture 15: 10/24/2002CS170 Fall CS170 Computer Organization and Architecture I Ayman Abdel-Hamid Department of Computer Science Old Dominion University.
11/02/2009CA&O Lecture 03 by Engr. Umbreen Sabir Computer Architecture & Organization Instructions: Language of Computer Engr. Umbreen Sabir Computer Engineering.
Copyright © 2006 by The McGraw-Hill Companies, Inc. All rights reserved. McGraw-Hill Technology Education Programming Languages and the Programming Process.
© Calvin College, For a number of years I have been familiar with the observation that the quality of programmers is a decreasing function of the.
CSE 425: Control Flow I Categories of Control Flow Constructs Sequencing –order of expressions and statements Selection –if, else, switch Iteration –loops.
MIPS coding. Review Shifting – Shift Left Logical (sll) – Shift Right Logical (srl) – Moves all of the bits to the left/right and fills in gap with 0’s.
Chapter 2 Decision-Making Instructions (Instructions: Language of the Computer Part V)
Computer Architecture CSE 3322 Lecture 3 Assignment: 2.4.1, 2.4.4, 2.6.1, , Due 2/3/09 Read 2.8.
1 The Software Development Process ► Systems analysis ► Systems design ► Implementation ► Testing ► Documentation ► Evaluation ► Maintenance.
1 Overview of Programming Principles of Computers.
Problem-solving with Computers. 2Outline  Computer System  5 Steps for producing a computer program  Structured program and programming  3 types of.
Computer Organization Instructions Language of The Computer (MIPS) 2.
Flow Control in Imperative Languages. Activity 1 What does the word: ‘Imperative’ mean? 5mins …having CONTROL and ORDER!
Copyright © 2006 by The McGraw-Hill Companies, Inc. All rights reserved. McGraw-Hill Technology Education Chapter 13 A & B Programming Languages and the.
Problem Solving.  Similar to Solving Math Word Problem  Read the Problem  Decide how to go about Solving the Problem  Solve the Problem  Test the.
Programming Techniques
1 Chapter10: Code generator. 2 Code Generator Source Program Target Program Semantic Analyzer Intermediate Code Generator Code Optimizer Code Generator.
IST 210: PHP Logic IST 210: Organization of Data IST2101.
Computer Science 210 Computer Organization Machine Language Instructions: Control.
CIS 365: Visual Application Development Introduction to Computers and Programming.
Why don’t programmers have to program in machine code?
Fundamentals of PL/SQL part 2 (Basics)
Introduction to programming
Statements (6 of 6) A statement causes an action to be performed by the program. It translates directly into one or more executable computer instructions.
Software Engineering (LECT 1)
Computer Architecture & Operations I
Entry Ticket: High and Low Level Languages
Vocabulary Algorithm - A precise sequence of instructions for processes that can be executed by a computer.
Programming Fundamentals
Flow of Control.
The University of Adelaide, School of Computer Science
Flow of Control.
Creativity in Algorithms
CPS120: Introduction to Computer Science
Lesson 2 Programming constructs – Algorithms – Scratch – Variables Intro.
Control Flow Analysis CS 4501 Baishakhi Ray.
Program Flow CSCE 121 J. Michael Moore.
Control Flow.
Computer Science 210 Computer Organization
CS-401 Computer Architecture & Assembly Language Programming
Flow of Control.
Coding Constructs considered Violations of Structured Programming
CSC215 Lecture Flow Control.
CSC215 Lecture Control Flow.
Homework Any Questions?.
What is a Basic Block ? A BASIC BLOCK is a sequence of consecutive language statements with the following properties: Program flow doesn't jump into or.
Type Topic in here! Created by Educational Technology Network
CSC215 Lecture Control Flow.
U3L2 The Need For Algorithms
CPS120: Introduction to Computer Science
Intermediate Code Generating machine-independent intermediate form.
Go To Statement Considered Harmful
Code Optimization.
Presentation transcript:

Structured Programming

Goto hell Goto : unconstrained jump Any jump in assembly Exists in C/C++ 

GOTO Considered Harmful "For a number of years I have been familiar with the observation that the quality of programmers is a decreasing function of the density of go to statements in the programs they produce. More recently I discovered why the use of the go to statement has such disastrous effects, and I became convinced that the go to statement should be abolished from all "higher level" programming languages (i.e. everything except, perhaps, plain machine code)." -Edsger Djikstra

A program Clear implementation of 4*(4 + 12)

A program Ugly implementation of 4*(99 + 43)

Block Block : List of instructions with 1 entry and 1 exit

Block Block : List of instructions with 1 entry and 1 exit Defined Entry conditions : Exit conditions : answer in r1

Structured Programming A block is structured If entry conditions met and no bugs, exit conditions will be met

Structured Programming A sequence of blocks are structured if exit conditions for block 1 match entry for block 2

Structured Programming Alternation is structured if both branches end at same location with same exit conditions

Structured Programming Iteration of a code block is structured

Structured Programming Any block can be used inside any other

Universality Any program can be written in structured format: