CHAPTER 8 SEQUENCE CONTROL Hardware- Von Neumann architecture (sequence from incrementing program counter); loop and conditional from test and jump (branch)

Slides:



Advertisements
Similar presentations
Introduction to C Programming
Advertisements

Chapt.2 Machine Architecture Impact of languages –Support – faster, more secure Primitive Operations –e.g. nested subroutine calls »Subroutines implemented.
Programming Languages and Paradigms
Adapted from Scott, Chapter 6:: Control Flow Programming Language Pragmatics Michael L. Scott.
CSCI 330: Programming Language Concepts Instructor: Pranava K. Jha Control Flow-II: Execution Order.
Control Structures Any mechanism that departs from straight-line execution: –Selection: if-statements –Multiway-selection: case statements –Unbounded iteration:
Expressions and Statements. 2 Contents Side effects: expressions and statements Expression notations Expression evaluation orders Conditional statements.
1 Chapter Five Selection and Repetition. 2 Objectives How to make decisions using the if statement How to make decisions using the if-else statement How.
ISBN Chapter 7 Expressions and Assignment Statements.
COEN Expressions and Assignment
1 Languages and Compilers (SProg og Oversættere) Sequence control and Subprogram Control.
Lecture 3: Topics If-then-else Operator precedence While loops Static methods Recursion.
ISBN Chapter 7 Expressions and Assignment Statements.
1 Chapter 7: Expressions Expressions are the fundamental means of specifying computations in a programming language To understand expression evaluation,
Chapter 8 (Control Structure) Slide 1 Control Structures Control structures are used by the programmer to incorporate the desired sequence of execution.
Logical Operators Java provides two binary logical operators (&& and ||) that are used to combine boolean expressions. Java also provides one unary (!)
Chapter 8 . Sequence Control
Chapter 3 Program translation1 Chapt. 3 Language Translation Syntax and Semantics Translation phases Formal translation models.
Chapter 7 Expressions and Assignment Statements. Copyright © 2007 Addison-Wesley. All rights reserved. 1–2 Arithmetic Expressions Arithmetic evaluation.
ISBN Chapter 7 Expressions and Assignment Statements.
ISBN Chapter 7 Expressions and Assignment Statements.
ISBN Lecture 07 Expressions and Assignment Statements.
Expressions, Evaluation and Assignments
Expressions & Assignments One of the original intentions of computer programs was the evaluation of mathematical expressions –languages would inherit much.
Sequence Control Chapter 6. 2 l Control structures: the basic framework within which operations and data are combined into programs. Sequence control.
Copyright © 1998 by Addison -Wesley Longman, Inc. 1 Chapter 6 Arithmetic Expressions - Their evaluation was one of the motivations for the development.
1-1 University of Hail College of Computer Science and Engineering Department of computer Science and Software Engineering Course: ICS313: Fundamentals.
7-1 Chapter 7: Expressions and Assignment Statements Arithmetic Expressions –the fundamental means of specifying computations in a programming language.
Expressions creating information. topics  operators: precedence, associativity, parentheses, overloading  operands: side-effects, coercion  arithmetic,
Chapter 7 Expressions and Assignment Statements. Chapter 7 Topics 1-2 Introduction Arithmetic Expressions Overloaded Operators Type Conversions Relational.
Ryan Chu. Arithmetic Expressions Arithmetic expressions consist of operators, operands, parentheses, and function calls. The purpose is to specify an.
Chapter 7 Expressions and Assignment Statements. Copyright © 2007 Addison-Wesley. All rights reserved. 1–2 Arithmetic Expressions Arithmetic evaluation.
COMP4730/2002/lec7/H.Melikian Arithmetic Expressions Overloaded Operators Type Conversations Relational and Boolean Expressions Short Circuit Evaluation.
C H A P T E R S E V E N Expressions and Assignment Statements.
PLLab, NTHU,Cs2403 Programming Languages Expression and control structure Kun-Yuan Hsieh Programming Language Lab., NTHU.
Expressions and Statements. Expressions Literals and identifiers are expressions More complex expressions are built from simple expressions by the application.
Arithmetic Expressions
Control Structures sequence of execution of high-level statements.
Expressions and Assignment Statements
ISBN Chapter 7 Expressions and Assignment Statements.
Chapter 7 © 1998 by Addison -Wesley Longman, Inc Arithmetic Expressions - Their evaluation was one of the motivations for the development of the.
ISBN Chapter 7 Expressions and Assignment Statements.
Copyright © 2009 Elsevier Chapter 6:: Control Flow Programming Language Pragmatics Michael L. Scott.
7-1/27 Chapter 7 Expressions and Assignment Statements Introduction Arithmetic Expressions Overloaded Operators Type Conversions Relational and Boolean.
Expressions and Assignment Statements
Information and Computer Sciences University of Hawaii, Manoa
Expressions and Assignment Statements
7.2 Arithmetic Expressions
Chapter 7: Expressions and Assignment Statements
Expressions and Assignment Statements
CS2403 Programming Languages Expressions and Assignment Statements
Chapter 7: Expressions and Assignment Statements
Expressions and Assignment Statements
Control Structures – Selection
Chap. 6 :: Control Flow Michael L. Scott.
Expressions and Assignment Statements
Arithmetic Expressions
MSIS 655 Advanced Business Applications Programming
Expressions and Assignment Statements
College of Computer Science and Engineering
Chap. 6 :: Control Flow Michael L. Scott.
Final Review In Text: Chapters 1-3, 5-12,
Statement-Level Control Structures
Languages and Compilers (SProg og Oversættere)
Final Review In Text: Chapters 1-3, 5-16.
Chapter 7 Expressions and Assignment Statements.
Final Review In Text: Chapters 1-3, 5-16.
Chap 7. Advanced Control Statements in Java
PRESENTED BY ADNAN M. UZAIR NOMAN
Controlling Program Flow
Presentation transcript:

CHAPTER 8 SEQUENCE CONTROL Hardware- Von Neumann architecture (sequence from incrementing program counter); loop and conditional from test and jump (branch) Control Abstraction includes intramodule, intermodule, and concurrent module control Implicit or explicit

Expressions Precedence rules (consider exponentiation) Tree-structure –Execution time representation when operand values are determined prefix; postfix to avoid ambiguity –Ex: Forth and Lisp Side effects –X := A + fun (A) where fun (A) changes the value of A What is the value of the expression? What if A itself must be evaluated? Should A be fetched once or twice? (compiler optimization an issue) –Ada’s approach – allow side effects; but if different results occur they are erroneous

Error conditions (exceptions) Divide by 0, overflow, underflow In Ada, orthogonality combines all types of errors, such as input errors in Exception handling

Short-circuit boolean operators In Ada, and.. then; or.. else and / or are not short circuit In C, C++, Java, && || are short circuit Optimization Program structure if (x != 0 ) if (a/x > 5)

Intramodule Scalar (unstructured) statements Assignment Input Parameter passing Go to/ break/ (multiple) exit/multiple entries Composite Conditional Discuss case (switch) Discuss nested if Loop Perform 5 (times) Test at bottom of Fortran do loop Recursion Infinite (for servers, etc.)

Exceptions Program controlled termination on serious error COBOL – on size error (compiler supplied code), PL/1 Ada : user defined exceptions identical to system defined ones Constraint_Error, Storage_Error, Tasking_Error Exceptions propagate dynamic stack C++ assert Java – try

SNOBOL4 (from the textbook) * Output longest odd length bit string palindrome start grammar = 0 | 1 | 0 *grammar 0 | 1 *grammar 1 * add 00 and 11 to the above loop newline = TRIM (INPUT) : f(end) newline (POS (0) SPAN (“01”) RPOS(0)) : f(bad) sn = SIZE (newline) next newline POS(0) grammar. palindrome POS(sn) :s(match) f(not) match OUTPUT = “MATCH:” “ “ palindrome: loop not sn = sn – 1: next bad OUTPUT = “improper input:” “ “ newline: loop end