Nios II Instruction Set Summary

advertisement
Nios II Instruction Set Summary
Learning Goal: Assembly language basics.
1
Introduction
This document summaries the subset of instruction implemented in your multi-cycle Nios II and describes the function of its 32 registers.
2
Registers
The following table lists the conventional function and names1 of the 32 registers of the Register File.
Register
Name
Function
r0
r1
r2
r3
r4
r5
r6
r7
r8
r9
r10
r11
r12
r13
r14
r15
zero
at
v0
v1
a0
a1
a2
a3
t0
t1
t2
t3
t4
t5
t6
t7
0x00000000
Assembler Temporary
Return Value
Return Value
Register Arguments
Register Arguments
Register Arguments
Register Arguments
Temporary Register
Temporary Register
Temporary Register
Temporary Register
Temporary Register
Temporary Register
Temporary Register
Temporary Register
3
Register
Name
r16
r17
r18
r19
r20
r21
r22
r23
r24
r25
r26
r27
r28
r29
r30
r31
s0
s1
s2
s3
s4
s5
s6
s7
et
bt
gp
sp
fp
ea
ba
ra
Function
Saved Register
Saved Register
Saved Register
Saved Register
Saved Register
Saved Register
Saved Register
Saved Register
Exception Temporary
Breakpoint Temporary
Global Pointer
Stack Pointer
Frame Pointer
Exception Return Address
Breakpoint Return Address
Return Address
Instructions
The following table lists the instructions implemented by your Nios II processor. We write “rAs ” to
consider the rA as signed, and “rAu ” when it is unsigned. We write “imms ”, when the immediate value
is signed extend, and “immu ”, when the immediate value is unsigned (i.e., extended with zeros).
1 To improve the readability of the code, we extend the official Nios II registers naming: we added names to the registers r2 to
r23, which were unnamed. These names are only supported by the Nios2Sim simulator.
Version 1.2 of 21st March 2013, EPFL ©2013
1 of 3
Nios II Instruction Set Summary
Category
addi
add
sub
rB, rA, imm
rC, rA, rB
rC, rA, rB
rB ← rA + imms
rC ← rA + rB
rC ← rA − rB
Logical
and
andi
or
ori
xor
xori
nor
rC,
rB,
rC,
rB,
rC,
rB,
rC,
rA,
rA,
rA,
rA,
rA,
rA,
rA,
rB
imm
rB
imm
rB
imm
rB
rC ← rA and rB
rB ← rA and immu
rC ← rA or rB
rB ← rA or immu
rC ← rA xor rB
rB ← rA xor immu
rC ← rA nor rB
cmpgei
cmplti
cmpnei
cmpeqi
cmpgeui
cmpltui
cmpge
cmplt
cmpne
cmpeq
cmpgeu
cmpltu
rB,
rB,
rB,
rB,
rB,
rB,
rC,
rC,
rC,
rC,
rC,
rC,
rA,
rA,
rA,
rA,
rA,
rA,
rA,
rA,
rA,
rA,
rA,
rA,
imm
imm
imm
imm
imm
imm
rB
rB
rB
rB
rB
rB
rB ← (rA ≥ imms )? 1 : 0
rB ← (rA < imms )? 1 : 0
rB ← (rA 6= imms )? 1 : 0
rB ← (rA = imms )? 1 : 0
rB ← (rAu ≥ immu )? 1 : 0
rB ← (rAu < immu )? 1 : 0
rC ← (rA ≥ rB)? 1 : 0
rC ← (rA < rB)? 1 : 0
rC ← (rA 6= rB)? 1 : 0
rC ← (rA = rB)? 1 : 0
rC ← (rAu ≥ rBu )? 1 : 0
rC ← (rAu < rBu )? 1 : 0
Shift
sll
slli
srl
srli
sra
srai
rol
ror
roli
rC,
rC,
rC,
rC,
rC,
rC,
rC,
rC,
rC,
rA,
rA,
rA,
rA,
rA,
rA,
rA,
rA,
rA,
rB
imm
rB
imm
rB
imm
rB
rB
imm
rC ← rA rB4..0
rC ← rA imm4..0
rC ← rAu rB4..0
rC ← rAu imm4..0
rC ← rAs rB4..0
rC ← rAs imm4..0
rC ← rA rol rB4..0
rC ← rA ror rB4..0
rC ← rA rol imm4..0
Memory
ldw
stw
rB, imm (rA)
rB, imm (rA)
rB ← MEM[imms +rA]
MEM[imms +rA] ← rB
Branch
br
bge
blt
bne
beq
bgeu
bltu
imm
rA,
rA,
rA,
rA,
rA,
rA,
goto PC+4+imms
if (rA ≥ rB) goto PC+4+imms
if (rA < rB) goto PC+4+imms
if (rA 6= rB) goto PC+4+imms
if (rA = rB) goto PC+4+imms
if (rAu ≥ rBu ) goto PC+4+imms
if (rAu < rBu ) goto PC+4+imms
imm
rA
Jump
call
callr
ret
jmp
jmpi
Misc
2 of 3
Meaning
Arithmetic
Comparator
2 This
Instruction
rA
imm
break
rB,
rB,
rB,
rB,
rB,
rB,
imm
imm
imm
imm
imm
imm
goto imm 2; ra ← PC+4
goto rA; ra ← PC+4
goto ra
goto rA
goto imm 2
stops the processor2
is not the official function of the instruction.
Version 1.2 of 21st March 2013, EPFL ©2013
Nios II Instruction Set Summary
4
Interrupts
The following table lists the names of the 6 registers of the Control Registers, which are related to
interrupts.
Register
ctl0
ctl1
ctl2
ctl3
ctl4
ctl5
Name
status
estatus
bstatus
ienable
ipending
cpuid
31...1
Reserved
Reserved
Reserved
Interrupt-enable bits
Pending-interrupt bits
Unique processor identifier
0
PIE
EPIE
BPIE
The following table shows the interrupt-specific instructions of your Nios II processor.
Category
Instruction
Control
rdctl
wrctl
Jump
eret
Meaning
rC, ctlN
ctlN, rA
rC ← ctlN
ctlN ← rA
goto ea; PIE ← EPIE
Note: In your assembly programs, you can use the name of the control registers given in the previous section
instead of ctlN.
Version 1.2 of 21st March 2013, EPFL ©2013
3 of 3
Download