|
This is so intentionally. The preprocessor conditionals (#if and
friends) only relate to preprocessor symbols (i.e., symbols defined
with
#define). The preprocessor directives are modeled after the C standard,
and hence will evaluate undefined (for the preprocessor) symbols to 0
without complaining.
This is the reason for having assembler conditionals (.if and friends)
as well. If you replace #if/#endif with .if/.endif in your program, it
will work as expected. Alternatively, you can replace the .equ
directives with #define. Both alternatives are shown below:
Alternative 1:
----------------------------------
.equ Fclk = 16000 ;Fclk, kHz
.equ Tbas = 5 ;time base, mS
.equ T1Div = Fclk*Tbas
.equ MAXWORD = 0xFFFF
.if T1Div > MAXWORD
.error "out of range constant"
.endif
-----------------------------------
Alternative 2:
-----------------------------------
#define Fclk 16000 //Fclk, kHz
#define Tbas 5 //time base, mS
#define T1Div Fclk*Tbas
#define MAXWORD 0xFFFF
#if T1Div > MAXWORD
#error "out of range constant"
#endif
-----------------------------------
Note the different style of comments in exampe 2, this is not mandatory
but we recommend sticking to either C or assembler style and not mix
the
two extensively, as this may easily cause confusion.
E-mail: info@telesys.ru