Often we find group of instruction for a certain need often implemented in a program. Group of this instruction can be made as procedure or function. Stepped this will be able to economize memory compared to if the instruction is written repeatedly. Remember, program in microcontroller to have a real limited memory.
Definition of Procedure.
Procedure is a gathering of instruction to do a certain need without returning a value.
Under this is as of cut-off example of way of writing of program at procedure making;
...
void name_procedure (parameter1, parameter2, ... parameter N)
statements;
}
...
Example of in the application of the program is
...
void delay (unsigned char i)
while (i--) {
/* writing for language assembly * /
/* will be studied separate of 8/
#asm
nop
nop
#endasm
};
}
...
Definition of Function
Function is a gathering of instruction to do a certain need with return end result of the value and need. Under this is writing concept of its(the program.
...
Type data name_function ( parameter1, parameter2,... parameter N)
{
Statements;
return variable_result;
}
...
Example:
...
int wide(int width, int height) {
wide = width*height
return wide;
}
...
Denominating of procedure or function of done directly by writing down its(the procedure or function.
example:
...
delay(150); //the way calls procedure
dt = wide(5,10); //the way applies function
}
...
No comments:
Post a Comment