blob: 69d79b785c5b0955f3495abc501aaf28ee608241 [file] [log] [blame]
wdenkef3386f2004-10-10 21:27:30 +00001/*
2 * (C) Copyright 2004, Psyent Corporation <www.psyent.com>
3 * Scott McNutt <smcnutt@psyent.com>
4 *
Wolfgang Denkd79de1d2013-07-08 09:37:19 +02005 * SPDX-License-Identifier: GPL-2.0+
wdenkef3386f2004-10-10 21:27:30 +00006 */
7
8#ifndef __ASM_NIOS2_OPCODES_H_
9#define __ASM_NIOS2_OPCODES_H_
10
11#define OPCODE_OP(inst) ((inst) & 0x3f)
12#define OPCODE_OPX(inst) (((inst)>>11) & 0x3f)
13#define OPCODE_RA(inst) (((inst)>>27) & 01f)
14#define OPCODE_RB(inst) (((inst)>>22) & 01f)
15#define OPCODE_RC(inst) (((inst)>>17) & 01f)
16
17/* I-TYPE (immediate) and J-TYPE (jump) opcodes
18 */
19#define OPCODE_CALL 0x00
20#define OPCODE_LDBU 0x03
21#define OPCODE_ADDI 0x04
22#define OPCODE_STB 0x05
23#define OPCODE_BR 0x06
24#define OPCODE_LDB 0x07
25#define OPCODE_CMPGEI 0x08
26#define OPCODE_LDHU 0x0B
27#define OPCODE_ANDI 0x0C
28#define OPCODE_STH 0x0D
29#define OPCODE_BGE 0x0E
30#define OPCODE_LDH 0x0F
31#define OPCODE_CMPLTI 0x10
32#define OPCODE_XORI 0x1C
33#define OPCODE_ORI 0x14
34#define OPCODE_STW 0x15
35#define OPCODE_BLT 0x16
36#define OPCODE_LDW 0x17
37#define OPCODE_CMPNEI 0x18
38#define OPCODE_BNE 0x1E
39#define OPCODE_CMPEQI 0x20
40#define OPCODE_LDBUIO 0x23
41#define OPCODE_MULI 0x24
42#define OPCODE_STBIO 0x25
43#define OPCODE_BEQ 0x26
44#define OPCODE_LDBIO 0x27
45#define OPCODE_CMPGEUI 0x28
46#define OPCODE_ANDHI 0x2C
47#define OPCODE_STHIO 0x2D
48#define OPCODE_BGEU 0x2E
49#define OPCODE_LDHIO 0x2F
50#define OPCODE_CMPLTUI 0x30
51#define OPCODE_CUSTOM 0x32
52#define OPCODE_INITD 0x33
53#define OPCODE_ORHI 0x34
54#define OPCODE_STWIO 0x35
55#define OPCODE_BLTU 0x36
56#define OPCODE_LDWIO 0x37
57#define OPCODE_RTYPE 0x3A
58#define OPCODE_LDHUIO 0x2B
59#define OPCODE_FLUSHD 0x3B
60#define OPCODE_XORHI 0x3C
61
62/* R-Type (register) OPX field encodings
63 */
64#define OPCODE_ERET 0x01
65#define OPCODE_ROLI 0x02
66#define OPCODE_ROL 0x03
67#define OPCODE_FLUSHP 0x04
68#define OPCODE_RET 0x05
69#define OPCODE_NOR 0x06
70#define OPCODE_MULXUU 0x07
71#define OPCODE_CMPGE 0x08
72#define OPCODE_BRET 0x09
73#define OPCODE_ROR 0x0B
74#define OPCODE_FLUSHI 0x0C
75#define OPCODE_JMP 0x0D
76#define OPCODE_AND 0x0E
77
78#define OPCODE_CMPLT 0x10
79#define OPCODE_SLLI 0x12
80#define OPCODE_SLL 0x13
81#define OPCODE_OR 0x16
82#define OPCODE_MULXSU 0x17
83#define OPCODE_CMPNE 0x18
84#define OPCODE_SRLI 0x1A
85#define OPCODE_SRL 0x1B
86#define OPCODE_NEXTPC 0x1C
87#define OPCODE_CALLR 0x1D
88#define OPCODE_XOR 0x1E
89#define OPCODE_MULXSS 0x1F
90
91#define OPCODE_CMPEQ 0x20
92#define OPCODE_CMPLTU 0x30
93#define OPCODE_ADD 0x31
94#define OPCODE_DIVU 0x24
95#define OPCODE_DIV 0x25
96#define OPCODE_RDCTL 0x26
97#define OPCODE_MUL 0x27
98#define OPCODE_CMPGEU 0x28
99#define OPCODE_TRAP 0x2D
100#define OPCODE_WRCTL 0x2E
101
102#define OPCODE_BREAK 0x34
103#define OPCODE_SYNC 0x36
104#define OPCODE_INITI 0x29
105#define OPCODE_SUB 0x39
106#define OPCODE_SRAI 0x3A
107#define OPCODE_SRA 0x3B
108
109/*Full instruction encodings for R-Type, without the R's ;-)
110 *
111 * TODO: BREAK, BRET, ERET, RET, SYNC (as needed)
112 */
113#define OPC_TRAP 0x003b683a
114
115#endif /* __ASM_NIOS2_OPCODES_H_ */