Previous: AVR32 Directives, Up: AVR32-Dependent



9.5.4 Opcodes

as implements all the standard AVR32 opcodes. It also implements several pseudo-opcodes, which are recommended to use wherever possible because they give the tool chain better freedom to generate optimal code.

LDA.W
                  lda.w   reg, symbol
     

This instruction will load the address of symbol into reg. The instruction will evaluate to one of the following, depending on the relative distance to the symbol, the relative distance to the constant pool and whether the --pic option has been specified. If the --pic option has not been specified, the alternatives are as follows:

                  /* symbol evaluates to a small enough value */
                  mov     reg, symbol
          
                  /* (. - symbol) evaluates to a small enough value */
                  sub     reg, pc, . - symbol
          
                  /* Constant pool is close enough */
                  lddpc   reg, cpent
                  ...
          cpent:
                  .long   symbol
          
                  /* Otherwise (not implemented yet, probably not necessary) */
                  mov     reg, lo(symbol)
                  orh     reg, hi(symbol)
     

If the --pic option has been specified, the alternatives are as follows:

                  /* (. - symbol) evaluates to a small enough value */
                  sub     reg, pc, . - symbol
          
                  /* If --linkrelax not specified */
                  ld.w    reg, r6[symbol@got]
          
                  /* Otherwise */
                  mov     reg, symbol@got / 4
                  ld.w    reg, r6[reg << 2]
     

If symbol is not defined in the same file and section as the LDA.W instruction, the most pessimistic alternative of the above is selected. The linker may convert it back into the most optimal alternative when the final value of all symbols is known.


CALL
                  call    symbol
     

This instruction will insert code to call the subroutine identified by symbol. It will evaluate to one of the following, depending on the relative distance to the symbol as well as the --linkrelax and --pic command-line options.

If symbol is defined in the same section and input file, and the distance is small enough, an rcall instruction is inserted:

                  rcall   symbol
     

Otherwise, if the --pic option has not been specified:

                  mcall   cpent
                  ...
          cpent:
                  .long   symbol
     

Finally, if nothing else fits and the --pic option has been specified, the assembler will indirect the call through the Global Offset Table:

                  /* If --linkrelax not specified */
                  mcall   r6[symbol@got]
          
                  /* If --linkrelax specified */
                  mov     lr, symbol@got / 4
                  ld.w    lr, r6[lr << 2]
                  icall   lr
     

The linker, after determining the final value of symbol, may convert any of these into more optimal alternatives. This includes deleting any superfluous constant pool- and GOT-entries.