Nios II Classic Processor Reference Guide

ID 683620
Date 10/28/2016
Public
Document Table of Contents

7.3. Register Usage

The ABI adds additional usage conventions to the Nios II register file defined in the Programming Model chapter of the Nios® II Processor Reference Handbook.
Table 89.  Nios II ABI Register Usage
Register Name Used by Compiler Callee Saved40 Normal Usage
r0 zero v   0x00000000
r1 at     Assembler temporary
r2   v   Return value (least-significant 32 bits)
r3   v   Return value (most-significant 32 bits)
r4   v   Register arguments (first 32 bits)
r5   v   Register arguments (second 32 bits)
r6   v   Register arguments (third 32 bits)
r7   v   Register arguments (fourth 32 bits)
r8   v   Caller-saved general-purpose registers
r9   v  
r10   v  
r11   v  
r12   v  
r13   v  
r14   v  
r15   v  
r16   v v Callee-saved general-purpose registers
r17   v v
r18   v v
r19   v v
r20   v v
r21   v v
r22   v 41
r23   v 42
r24 et     Exception temporary
r25 bt     Break temporary
r26 gp v   Global pointer
r27 sp v   Stack pointer
r28 fp v 43 Frame pointer
r29 ea     Exception return address
r30 ba    
  • Normal register set: Break return address
  • Shadow register sets: SSTATUS register
r31 ra v   Return address

The endianness of values greater than 8 bits is little endian. The upper 8 bits of a value are stored at the higher byte address.

40 A function can use one of these registers if it saves it first. The function must restore the register’s original value before exiting.
41 In the GNU Linux operating system, r22 points to the global offset table (GOT). Otherwise, it is available as a callee-saved general-purpose register.
42 In the GNU Linux operating system, r23 is used as the thread pointer. Otherwise, it is available as a callee-saved general-purpose register.
43 If the frame pointer is not used, the register is available as a callee-saved temporary register. Refer to “Frame Pointer Elimination” .