Difference between revisions of "W1151 Conditional and Flow Chart"

From Coder Merlin
m (Merlin moved page W1151 Non-Sequential Execution to W1151 Execution Flow without leaving a redirect)
Line 47: Line 47:
   ! Meaning
   ! Meaning
   |-
   |-
   | [[File:Flowchart Line.svg|thumb|Flowchart Line]] || Describes the direction of flow through the diagram, particularly when the flow is not in the traditional top-to-bottom order
   | [[File:Flowchart Line.svg|link=|Directional Arrow]] || Describes the direction of flow through the diagram, particularly when the flow is not in the traditional top-to-bottom order.
  |-
  | [[File:Flowchart Terminal.svg|link=|Terminal]] || Indicates the beginning or end of a program or function.
  |-
  | [[File:Flowchart Process.svg|link=|Process]] || Indicates an ordered series of logically grouped operations.
   |}
   |}



Revision as of 17:23, 4 January 2020

Within these castle walls be forged Mavens of Computer Science ...
— Merlin, The Coder
Confluence

Prerequisites[edit]

Background[edit]

Introduction[edit]

Until now, the programs which we have observed and written exhibited sequential flow. That is, they had a single entry point and a single exit point. Instruction execution began at the entry point, instructions were executed sequentially, and then the program execution completed. While this type of flow is useful in some simple cases in the general case the flow will be more complex.

Sequential Execution[edit]

In the example above, the program execution begins at address 0x8020 and completes at address 0x8026. All instructions are executed sequentially.

Let's examine a Hello, World! program in assembly language:

        .global _start

        .text
_start:
        # write(1, messageA, 6)
        mov     $1, %rax                # system call 1 is write
        mov     $1, %rdi                # file handle 1 is stdout
        mov     $messageA, %rsi         # address of string to output
        mov     $6, %rdx                # number of bytes
        syscall                         # invoke operating system to do the write

        # write(1, messageB, 6)
        mov     $1, %rax                # system call 1 is write
        mov     $1, %rdi                # file handle 1 is stdout
        mov     $messageB, %rsi         # address of string to output
        mov     $6, %rdx                # number of bytes
        syscall                         # invoke operating system to do the write

        # exit(0)
        mov     $60, %rax               # system call 60 is exit
        xor     %rdi, %rdi              # we want return code 0
        syscall                         # invoke operating system to exit

messageA:
        .ascii  "Hello "
messageB:
        .ascii  "World!"

Flowcharts[edit]

A flowchart is a type of diagram that enables us to visualize the flow of execution through a program. As such, flowcharts representing an entire program generally have a single entry point, a single exit point, and one or more processes. (In this case the word process is not the same as an operating system process, but represents the general usage of the word, i.e. "do something".) Throughout this experience, we'll introduce several symbols that are typically used in flowcharts.

Symbol Meaning
Directional Arrow Describes the direction of flow through the diagram, particularly when the flow is not in the traditional top-to-bottom order.
Terminal Indicates the beginning or end of a program or function.
Process Indicates an ordered series of logically grouped operations.

Topic Headers[edit]

Key Concepts[edit]

Exercises[edit]

References[edit]