Nios II Dependent Features
**************************

Options
=======

-relax-section
     Replace identified out-of-range branches with PC-relative jmp sequences when possible.  The generated code sequences are suitable for use in position-independent code, but there is a practical limit on the extended branch range because of the length of the sequences. This option is the default.

-relax-all
     Replace branch instructions not determinable to be in range and all call instructions with jmp and callr sequences (respectively).  This option generates absolute relocations against the target symbols and is not appropriate for position-independent code.

-no-relax
     Do not replace any branches or calls.

-EB
     Generate big-endian output.

-EL
     Generate little-endian output.  This is the default.

Syntax
======

Special Characters
------------------

# is the line comment character. ; is the line separator character.

Nios II Machine Relocations
===========================

%hiadj(EXPRESSION)
     Extract the upper 16 bits of EXPRESSION and add one if the 15th bit is set.

     The value of %hiadj(EXPRESSION) is:

          ((EXPRESSION >> 16) & 0xffff) + ((EXPRESSION >> 15) & 0x01)

     The %hiadj relocation is intended to be used with the addi, ld or st instructions along with a %lo, in order to load a 32-bit constant.

          movhi r2, %hiadj(symbol)
          addi r2, r2, %lo(symbol)

%hi(EXPRESSION)
     Extract the upper 16 bits of EXPRESSION.

%lo(EXPRESSION)
     Extract the lower 16 bits of EXPRESSION.

%gprel(EXPRESSION)
     Subtract the value of the symbol _gp from EXPRESSION.

     The intention of the %gprel relocation is to have a fast small area of memory which only takes a 16-bit immediate to access.

          	.section .sdata
          fastint:
          	.int 123
          	.section .text
          	ldw r4, %gprel(fastint)(gp)

%call(EXPRESSION)

%call_lo(EXPRESSION)

%call_hiadj(EXPRESSION)
%got(EXPRESSION)
%got_lo(EXPRESSION)
%got_hiadj(EXPRESSION)
%gotoff(EXPRESSION)
%gotoff_lo(EXPRESSION)
%gotoff_hiadj(EXPRESSION)
%tls_gd(EXPRESSION)
%tls_ie(EXPRESSION)
%tls_le(EXPRESSION)
%tls_ldm(EXPRESSION)
%tls_ldo(EXPRESSION)

     These relocations support the ABI for Linux Systems documented in the Nios II Processor Reference Handbook.

Nios II Machine Directives
==========================

.align EXPRESSION [, EXPRESSION]
     This is the generic .align directive, however this aligns to a power of two.

.half EXPRESSION
     Create an aligned constant 2 bytes in size.

.word EXPRESSION
     Create an aligned constant 4 bytes in size.

.dword EXPRESSION
     Create an aligned constant 8 bytes in size.

.2byte EXPRESSION
     Create an unaligned constant 2 bytes in size.

.4byte EXPRESSION
     Create an unaligned constant 4 bytes in size.

.8byte EXPRESSION
     Create an unaligned constant 8 bytes in size.

.16byte EXPRESSION
     Create an unaligned constant 16 bytes in size.

.set noat
     Allows assembly code to use at register without warning.  Macro or relaxation expansions generate warnings.

.set at
     Assembly code using at register generates warnings, and macro expansion and relaxation are enabled.

.set nobreak
     Allows assembly code to use ba and bt registers without warning.

.set break
     Turns warnings back on for using ba and bt registers.

.set norelax
     Do not replace any branches or calls.

.set relaxsection
     Replace identified out-of-range branches with jmp sequences (default).

.set relaxsection
     Replace all branch and call instructions with jmp and callr sequences.

.set ...
     All other .set are the normal use.

Opcodes
=======

AS implements all the standard Nios II opcodes documented in the Nios II Processor Reference Handbook, including the assembler pseudo-instructions.