Код
.org (FLASHEND - 64)
.db " Encoder&Keyboard v1.4 25.10.2009"
.db " Encoder&Keyboard v1.4 25.10.2009"
Т.е. в конец флеша записываю строку с названием проекта, версией прошивки и датой билда, что порой очень выручает.
На днях узнал про "предопределённые макросы" __DATE__ __TIME__, был приятно удивлён. Но не очень устраивает формат вывода даты макросом __DATE__ . Он выдаёт "Oct 25 2009", а хочется именно "25.10.2009". В хэлпе по AVRasm2 приводят:
Код
-FDformat
-FTformat
Specify the format of the __DATE__ and __TIME__ predefined macros, respectively. The format string is passed directly to the strftime(3) C library function. The __DATE__ and __TIME__ preprocessor macros will always be string tokens, i.e., their values will appear in double quotes.
The default formats are "%b %d %Y" and "%H:%M:%S", respectively.
Example: To specify ISO format for __DATE__, specify -FD"%Y-%m-%d" See note below
These formats may only be specified at the command line, there are no corresponding #pragma directives.
Important note: The Windows command interpreter (cmd.exe or command.com) may interpret a character sequence starting and ending with a '%' character as an environment variable to be expanded even when it is quoted. This may cause the date/time format strings to be changed by the command interpreter and not work as expected. A workaround that will work in many cases is to use double '%' characters to specify the format directives, e.g., -FD"%%Y-%%m-%%d" for the example above. The exact behaviour of the command interpreter seems to be inconsistent and vary depending on a number of circumstances, for one, it is different in batch and interactive mode. The effect of the format directives should be tested. It is recommended to put the following line in the source file for testing this:
#message "__DATE__ =" __DATE__ "__TIME__ =" __TIME__
This will print the value of the date and time macros when the program is assembled, making verification easy (see #message directive documentation).
An alternative syntax for the format specification may be considered in future AVRASM2 versions to avoid this problem.
Some relevant strftime() format specifiers (see strftime(3) manual page for full details):
%Y - Year, 4 digits
%y - Year, 2 digits
%m - Month number (01-12)
%b - Abbreviated month name
%B - Full month name
%d - Day number in month (01-31)
%a - Abbreviated weekday name
%A - Full weekday name
%H - Hour, 24-hour clock (00-23)
%I - Hour, 12-hour clock (01-12)
%p - "AM" or "PM" for 12-hour clock
%M - Minute (00-59)
%S - Second (00-59)
-FTformat
Specify the format of the __DATE__ and __TIME__ predefined macros, respectively. The format string is passed directly to the strftime(3) C library function. The __DATE__ and __TIME__ preprocessor macros will always be string tokens, i.e., their values will appear in double quotes.
The default formats are "%b %d %Y" and "%H:%M:%S", respectively.
Example: To specify ISO format for __DATE__, specify -FD"%Y-%m-%d" See note below
These formats may only be specified at the command line, there are no corresponding #pragma directives.
Important note: The Windows command interpreter (cmd.exe or command.com) may interpret a character sequence starting and ending with a '%' character as an environment variable to be expanded even when it is quoted. This may cause the date/time format strings to be changed by the command interpreter and not work as expected. A workaround that will work in many cases is to use double '%' characters to specify the format directives, e.g., -FD"%%Y-%%m-%%d" for the example above. The exact behaviour of the command interpreter seems to be inconsistent and vary depending on a number of circumstances, for one, it is different in batch and interactive mode. The effect of the format directives should be tested. It is recommended to put the following line in the source file for testing this:
#message "__DATE__ =" __DATE__ "__TIME__ =" __TIME__
This will print the value of the date and time macros when the program is assembled, making verification easy (see #message directive documentation).
An alternative syntax for the format specification may be considered in future AVRASM2 versions to avoid this problem.
Some relevant strftime() format specifiers (see strftime(3) manual page for full details):
%Y - Year, 4 digits
%y - Year, 2 digits
%m - Month number (01-12)
%b - Abbreviated month name
%B - Full month name
%d - Day number in month (01-31)
%a - Abbreviated weekday name
%A - Full weekday name
%H - Hour, 24-hour clock (00-23)
%I - Hour, 12-hour clock (01-12)
%p - "AM" or "PM" for 12-hour clock
%M - Minute (00-59)
%S - Second (00-59)
Куда писать эти спецификаторы - ума не приложу :-[ Имею подозрения, что поле "Additional Parameters" окна "Project->Assembler Options" для этих целей используется.
Также вопрос вдогонку. При присваивании константам текстовых имён хочу делать проверку на допустимость значения
Код
.equ defineParam1 = 1
......
......
#if (defineParam1 < 3)
#error "defineParam1 must be more then 3"
#endif
......
......
#if (defineParam1 < 3)
#error "defineParam1 must be more then 3"
#endif
Но вот как в тексте ошибки вернуть значение этой константы? Чтобы при неверно заданном параметре был виден не только текст констатирующий ошибку, но и первопричину этой ошибки, что-то вроде #error "defineParam1 must be more then 3. Param1=", (????).
Спасибо всем откликнувшимся.