The available pseudo-ops in the assembler are described in the GNU assembler (gas) manual. The manual can be found online as part of the current binutils release under http://sources.redhat.com/binutils/.

As gas comes from a Unix origin, its pseudo-op and overall assembler syntax is slightly different than the one being used by other assemblers. Numeric constants follow the C notation (prefix 0x for hexadecimal constants), expressions use a C-like syntax.

Some common pseudo-ops include:

  • .byte allocates single byte constants

  • .ascii allocates a non-terminated string of characters

  • .asciz allocates a \0-terminated string of characters (C string)

  • .data switches to the .data section (initialized RAM variables)

  • .text switches to the .text section (code and ROM constants)

  • .set declares a symbol as a constant expression (identical to .equ)

  • .global (or .globl) declares a public symbol that is visible to the linker (e. g. function entry point, global variable)

  • .extern declares a symbol to be externally defined; this is effectively a comment only, as gas treats all undefined symbols it encounters as globally undefined anyway

Note that .org is available in gas as well, but is a fairly pointless pseudo-op in an assembler environment that uses relocatable object files, as it is the linker that determines the final position of some object in ROM or RAM.

Along with the architecture-independent standard operators, there are some AVR-specific operators available which are unfortunately not yet described in the official documentation. The most notable operators are:

  • lo8 Takes the least significant 8 bits of a 16-bit integer

  • hi8 Takes the most significant 8 bits of a 16-bit integer

  • pm Takes a program-memory (ROM) address, and converts it into a RAM address. This implies a division by 2 as the AVR handles ROM addresses as 16-bit words (e.g. in an IJMP or ICALL instruction), and can also handle relocatable symbols on the right-hand side.

Example: ldi r24, lo8(pm(somefunc)) ldi r25, hi8(pm(somefunc)) call something

This passes the address of function somefunc as the first parameter to function something.