1 / 7

CHAPTER 8 SEQUENCE CONTROL

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.

khalil
Télécharger la présentation

CHAPTER 8 SEQUENCE CONTROL

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. 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

  2. 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

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

  4. 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)

  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.)

  6. 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

  7. 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

More Related