Like AVRASM, AVRASM2 may be used as a stand-alone program from the command line. The AVRASM2 command-line invocation syntax is shown below. Many options are the same as in AVRASM, new/changed AVRASM2 options are shown in bold and described below.
usage: avrasm2.exe [options] file.asm
-f [O|M|I|G|-] output file format:
-fO Debug info for simulation in AVR Studio (default)
-fO1 | -fO2 - force format version 1 or 2 (default: auto)
-fM Motorola hex
-fI Intel hex
-fG Generic hex format
-f- No output file
-o ofile Put output in 'ofile'.
-d dfile Generate debug info for simulation in AVR Studio in 'dfile'.
Can only be used with the -f [M|I|G] option.
-l lfile Generate listing in 'lfile'
-m mfile Generate map in 'mfile'
-e efile Place EEPROM contents in 'efile'
-w Relative jumps are allowed to wrap for program ROM
up to 4k words in size [ignored]
-C ver Specify AVR core version
-c Case sensitive
-1/-2 Turn on/off AVR Assembler version 1 compatibility.
-p1|0 Set/unset AVRASM1 implicit .device include (also set by -1)
-I dir Preprocessor: Add 'dir' to include search path
-i file Preprocessor: Explicitly pre-include file
-D name[=value] Preprocessor: Define symbol. If =value is
omitted, it is set to 1.
-U name Preprocessor: Undefine symbol.
-v verbosity [0-9][s]:
-vs Include target resource usage statistics
-vl Output low-level assembly code to stdout
-v0 Silent, only error messages printed
-v1 Error and warning messages printed
-v2 Error, warning, and info messages printed (default)
-v3-v9 Unspecified, increasing amounts of assembler internal dumps.
-O i|w|e Overlap report: ignore|warning|error [error]
-W-b|+bo|+bi Byte operand out of range warning disable|overflow|integer
-W+ie|+iw Unsupported instruction error | warning
-FD|Tfmt __DATE__ | __TIME__ format, using strftime(3) format string
Supported formats are generic/Intel/Motorola hex, and AVR Object files. There are two subvariants of the AVR Object file format:
Standard (V1) format, with 16-bit line number fields, supporting source files with up to 65534 lines.
Extended (V2) format, with 24-bit line number fields, supporting source files with up to ~16M lines.
By default, when output format is unspecified or specified with -fO, the assembler will select the appropriate format automatically, V1 if the file has less than 65533 lines, V2 if it has more. The -fO1 and -fO2 options may be used to force V1 or V2 output file format regardless of number of lines.
If V1 file format is used with source files with more than 65534 lines, the assembler will issue a warning, and the lines above 65534 cannot be debugged with AVR Studio. On the other hand, the V2 format is not recognized at all by AVR Studio versions prior to 4.12.
For all normal assembler projects, the default option should be safe. The extended format is primarily intended for machine-generated assembly files.
Wrap relative jumps. This option is obsoleted, because AVRASM2 automatically determines when to wrap relative jumps, based on program memory size. The option is recognized but ignored.
Specify AVR Core version. The core version is normally specified in part definition files (partdef.inc), this option is intended for testing of the assembler, and generally not useful for end-users.
Causes the assembler to become entirely case sensitive. Preprocessor directives and macros are always case sensitive. Warning: Setting this option will break many existing projects.
Enable and disable AVRASM1 compatibility mode. This mode is disabled (-2) by default. The compatibility mode will permit certain constructs otherwise considered errors, reducing the risk of breaking existing projects. It also affects the built-in include path, causing the assembler to look for device definition include files (devicedef.inc) for Assembler 1 in C:\Atmel\AVR Tools\AvrAssembler\Appnotes instead of the new Assembler 2 files in C:\Atmel\AVR Tools\AvrAssembler2\Appnotes (see also XML Converter). Note that recent devices may not be supported for Assembler 1.
Add directory to the include file search path. This affects both the preprocessor #include directive and the assembler .include directive.
Multiple -I directives may be given. directories are searched in the order specified.
Include a file. #include “file” directive is processed before the first source code line is processed. Multiple –i directives may be used and will be processed in order.
Define and undefine a preprocessor macro, respectively. Note that function-type preprocessor macros may not be defined from the command line. If -D is given no value, it is set to 1.
Print use statistics for register, instruction and memory on standard output. By default, only the memory statistic is printed. Note: The full statistics will always be printed to the list file, if one is specified.
This will print the raw instructions emitted to standard output, after all symbolic info is replaced. Mainly for assembler debugging purposes.
Print error messages only, warning and info messages are suppressed.
Print error and warning messages only, info messages are suppressed.
Print error, warning, and info messages. This is the default behaviour.
Print increasing amounts of assembler internal status dump. Mostly used for assembler debugging.
If different sections of code are mapped to overlapping memory locations using the .org directive, an error message is normally issued.
This option allows setting this condition to cause an error (-Oe, default), a warning (-Ow) or be completely ignored (-Oi). Not recommended for normal programs.
This may also be set by #pragma overlap directive.
-b, +bo, and +bi correspond to no no warning, warning when overflow, and warning when integer value out of range, respectively. This may also be set by #pragma warning range.
+ie and +iw selects if use of unsupported instructions gives error or warning, respectively. The default is to give an error. Corresponds to #pragma error instruction / pragma warning instruction, respectively.
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.
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:
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)