Mikroelektronika MIKROE-742 데이터 시트

다운로드
페이지 532
PROGRAM ORGANIZATION
Pascal imposes quite strict program organization. Below you can find models for
writing legible and organized source files. For more information on file inclusion and
scope, refer to Units and Scope and Visibility.
Organization of Main Unit
Basically, the main source file has two sections: declaration and program body. Dec-
larations should be in their proper place in the code, organized in an orderly man-
ner. Otherwise, the compiler may not be able to comprehend the program correctly.
When writing code, follow the model presented below. The main unit should look like this:
program { program name }
uses { include other units }
//********************************************************
//* Declarations (globals):
//********************************************************
{ constants declarations }
const ...
{ types declarations }
type ...
{ variables declarations }
var
Name[, Name2...] : [^]type; [
absolute
0x123;] [
external;]
[
volatile;] [register;] [sfr;]
{ labels declarations }
label ...
{ procedures declarations }
procedure procedure_name(parameter_list);
{ local declarations }
begin
...
end;
{ functions declarations }
function function_name(parameter_list) : return_type;
{ local declarations }
begin
...
end
129
MIKROELEKTRONIKA
- SOFTWARE AND HARDWARE SOLUTIONS FOR EMBEDDED WORLD
Language Reference
mikroPASCAL PRO for AVR
CHAPTER 5