Keywords

Predefined identifiers (keywords) are reserved and cannot be redefined. The keywords include all Instruction mnemonics, Functions.

Assembler keywords are recognized regardless of case, unless the -c option is used, in which case the keywords are lower case (i.e., "add" is reserved, "ADD" is not).

Preprocessor directives

AVRASM2 considers all lines starting with a '#' as the first non-space character a preprocessor directive.

Comments

In addition to the classic assembler comments starting with ';', AVRASM2 recognizes C-style comments. The following comment styles are recognized:

; The rest of the line is a comment (classic assembler comment)
// Like ';', the rest of the line is a comment
/* Block comment; the enclosed text is a comment, may span 
multiple lines.This style of comments cannot be nested. */

Line continuation

Like in C, source lines can be continued by means of having a backslash (\) as the last character of a line. This is particularly useful when defining long preprocessor macros, and for long .db directives.

Example:

.db 0, 1, "This is a long string", '\n', 0, 2, \ 
"Here is another one", '\n', 0, 3, 0

Integer constants

AVRASM2 allows underscores (_) to be used as separators for increased readability. Underscores may be located anywhere in the number except as the first character or inside the radix specifier.

Example: 0b1100_1010 and 0b_11_00_10_10_ are both legal, while _0b11001010 and 0_b11001010 are not.

Strings and character constants

A string enclosed in double quotes (") can only be used in conjunction with the DB directive and the MESSAGE/.WARNING/ERROR directives. The string is taken literally, no escape sequences are recognized, and it is not NULL-terminated.

Quoted strings may be concatenated according to the ANSI C convention, i.e., "This is a " "long string" is equivalent to "This is a long string".This may be combined with Line to form long strings spanning multiple source lines.

Character constants are enclosed in single quotes ('), and can be used anywhere an integer expression is allowed. The following C-style escape sequences are recognized, with the same meaning as in C:

Escape sequence

Meaning

\n

Newline (ASCII LF 0x0a)

\r

Carriage return (ASCII CR 0x0d)

\a

Alert bell (ASCII BEL 0x07)

\b

Backspace (ASCII BS 0x08)

\f

Form feed (ASCII FF 0x0c)

\t

Horizontal tab (ASCII HT 0x09)

\v

Vertical tab (ASCII VT 0x0b)

\\

Backslash

\0

Null character (ASCII NUL)

\ooo (ooo = octal number) and \xhh (hh = hex number) are also recognized.

Examples

.db "Hello\n" // is equivalent to:
.db 'H', 'e', 'l', 'l', 'o', '\\', 'n'
.db '\0', '\177', '\xff'

To create the equivalent to the C-string "Hello, world\n", do as follows:

.db "Hello, world", '\n', 0

Multiple instructions per line

AVRASM2 allows multiple instructions and directives per line, but its use is not recommended. It is needed to support expansion of multiline preprocessor macros.

Operands

AVRASM2 has support for integer operands and limited support for floating point constant expressions. All operands are described Operands.