Specifications

Assembler Macros
The Nios II assembler provides macros to extract halfwords from labels and from 32-bit immediate
values. These macros return 16-bit signed values or 16-bit unsigned values depending on where they are
used. When used with an instruction that requires a 16-bit signed immediate value, these macros return a
value ranging from –32768 to 32767. When used with an instruction that requires a 16-bit unsigned
immediate value, these macros return a value ranging from 0 to 65535.
Table 8-7: Assembler Macros
Macro Description Operation
%lo(immed32) Extract bits [15..0] of immed32 immed32 & 0xFFFF
%hi(immed32) Extract bits [31..16] of immed32 (immed32 >> 16) & 0xFFFF
%hiadj(immed32) Extract bits [31..16] and adds bit 15 of
immed32
((immed32 >> 16) & 0xFFFF) +
((immed32 >> 15) & 0x1)
%gprel(immed32) Replace the immed32 address with an
offset from the global pointer
immed32 –_gp
Refer to the Application Binary Interface chapter of the Nios II Processor Reference Handbook for more
information about global pointers.
Related Information
Application Binary Interface on page 7-1
Application Binary Interface
Instruction Set Reference
The following pages list all Nios II instruction mnemonics in alphabetical order.
Table 8-8: Notation Conventions
Notation Meaning
X ← Y X is written with Y
PC ← X The program counter (PC) is written with address X; the instruction at X is the
next instruction to execute
PC The address of the assembly instruction in question
rA, rB, rC One of the 32-bit general-purpose registers
prs.rA General-purpose register rA in the previous register set
IMMn An n-bit immediate value, embedded in the instruction word
IMMED An immediate value
X
n
The nth bit of X, where n = 0 is the LSB
X
n..m
Consecutive bits n through m of X
NII51017
2015.04.02
Assembler Macros
8-5
Instruction Set Reference
Altera Corporation
Send Feedback