Statements, Labeled statements, Mikroc – ABL electronic PIC Microcontrollers PIC16 User Manual

Page 123

Advertising
background image

Statements specify the flow of control as a program executes. In the absence of
specific jump and selection statements, statements are executed sequentially in the
order of appearance in the source code.

Statements can be roughly divided into:

- Labeled Statements
- Expression Statements
- Selection Statements
- Iteration Statements (Loops)
- Jump Statements
- Compound Statements (Blocks)

Labeled Statements

Every statement in program can be labeled. Label is an identifier added before the
statement like this:

label_identifier

:

statement

;

There is no special declaration of a label – it just “tags” the statement.

Label_identifier

has a function scope and label cannot be redefined within

the same function.

Labels have their own namespace: label identifier can match any other identifier in
the program.

A statement can be labeled for two reasons:

1. The label identifier serves as a target for the unconditional goto statement,

2. The label identifier serves as a target for the

switch

statement. For this

purpose, only

case

and

default

labeled statements are used:

case

constant-expression

:

statement

default

:

statement

MikroElektronika: Development tools - Books - Compilers

115

page

mikroC - C Compiler for Microchip PIC microcontrollers

mikroC

making it simple...

STATEMENTS

Advertising
This manual is related to the following products: