Control structures in High Level Programming Languages
Control structures
alters the
default program flow
Commonly used
control structures in
high level programming languages:
- The if-statement
- The if-else-statement
- The switch-statement
- The while-statement
- The for-statement
- The do-while-statement
|
I will omit the
switch-statement because it's
equivalent to
nested if-else-statements
I will omit the
do-while-statement because
it is
rarely used in
programs
Assembler instructions used to
implement control structures in
assembler
Control structure in
high level languages are
implemented in
Assembler using
2 assembler instructions:
- A
compare
instruction that:
-
compares
2 values
and
-
set
the
status flags (N, Z, V, C)
in the PSR (Processor Status Register)
according to
result of
the
comparison
|
-
Conditional
and
unconditional
branch
instructions:
- is a
group of (related)
instructions
-
can
make the
CPU
"jump"
to a given
memory
location
- Jumps can be
conditional or
unconditional (= always)
- Jumps will
result in
out-of-order
program flow
|
|