CHAPTER 8 SEQUENCE CONTROL - PowerPoint PPT Presentation

1 / 7
About This Presentation
Title:

CHAPTER 8 SEQUENCE CONTROL

Description:

CHAPTER 8 SEQUENCE CONTROL. Hardware- Von Neumann ... Short-circuit boolean operators. In Ada, and .. then; or.. else. and / or are not short circuit ... – PowerPoint PPT presentation

Number of Views:53
Avg rating:3.0/5.0
Slides: 8
Provided by: fdu4
Category:

less

Transcript and Presenter's Notes

Title: CHAPTER 8 SEQUENCE CONTROL


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)
  • Adas 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 gt 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
Write a Comment
User Comments (0)
About PowerShow.com