Datasheet

JUMP STATEMENTS
The jump statement, when executed, transfers control unconditionally. There are
four such statements in the mikroC PRO for AVR:
- break
- continue
- goto
- return
BREAK AND CONTINUE STATEMENTS
Break Statement
Sometimes it is necessary to stop the loop within its body. Use the break statement
within loops to pass control to the first statement following the innermost switch,
for, while, or do block.
Break is commonly used in the switch statements to stop its execution upon the
first positive match. For example:
switch (state) {
case 0: Lo(); break;
case 1: Mid(); break;
case 2: Hi(); break;
default: Message("Invalid state!");
}
Continue Statement
The continue statement within loops is used to “skip the cycle”. It passes control to
the end of the innermost enclosing end brace belonging to a looping construct. At
that point the loop continuation condition is re-evaluated. This means that contin-
ue
demands the next iteration if the loop continuation condition is true.
Specifically, the continue statement within the loop will jump to the marked position
as it is shown below:
while (..) {
...
if (val>0) continue;
...
// continue jumps here
}
215
MIKROELEKTRONIKA - SOFTWARE AND HARDWARE SOLUTIONS FOR EMBEDDED WORLD
Language Reference
mikroC PRO for AVR
CHAPTER 5
do {
...
if (val>0) continue;
...
// continue jumps here
while (..);