Download Introduction To The C Language
Transcript
3.3.4.3 The C166 Tab Explained There are three ways of controlling how the C166 compiler and A166 assembler translate a particular source file: (i) Via the command line: C166 MAIN.C DEBUG MOD167 HLARGE (ii) Via the #pragma keyword: #pragma MOD167 #pragma HLARGE #pragma DEBUG (iii) Via uVISION’s Options-C166 Compiler... menu item, covered in detail later. In anything but the smallest of projects, method (i) is not suitable. In practice, it is sometimes used just to quickly compile something from the MS-DOS command line with an unusual control such as “SRC”, which produces a valid assembler/C mixed file. This “.SRC” file can be useful for assessing code quality or for interfacing to assembler-coded functions. Usually, a combination of (ii) and (iii) is used. However, the user must decide which controls should be supplied by uVISION and which should be embedded in the source by the #pragma keyword. Where the default compiler setting is acceptable, it is not really necessary to explicitly state the control. As a general rule, anything which can alter the generated code must be given by a #pragma: although uVISION is unlikely to lose or alter a control over the duration of a project, bitter experience has shown that just prior to release, something will go astray and some vital control will disappear, resulting in a subtle change to the code. This will invalidate any proving work which has been done and may well result in unexpected program behaviour. Therefore you should not rely on an external tool (i.e. uVISION) to set the really important controls! If you are using a conventional command-line approach with an external MAKE utility, then the same rules apply in that your makefile should ideally not supply the “hard controls”. In all cases, it is acceptable to place the really critical controls in a header file, usually named “PRAGMAS.H” which contain them. Even if you do not intend to use uVISION, it does provide a quick way of putting togther the control keywords you require as it displays the final command line in the “Compiler Control String” box. The resulting string can then be used to construct the individual #pragma control lines in your source files - in effect, uVISION acts like an interactive user manual! Here are some tips as to where to put the controls in a real project: (i) Compiler Hardwired “HARD CONTROLS” Generally anything which can influence the code generator or optimizer - here are a few of the most common: MOD167 SMALL NODPPSAVE OPTIMIZE(x) - © Copyright Hitex (UK) Ltd 1999 Enable C167 family code generator Set the memory model Do not stack DPP3 on entry to interrupt routines (C167 only) Bias the code generator towards optimum program SIZE or SPEED C166 Introduction Page 22