1#
2# OpenRISC instruction decode definitions.
3#
4# Copyright (c) 2018 Richard Henderson <rth@twiddle.net>
5#
6# This library is free software; you can redistribute it and/or
7# modify it under the terms of the GNU Lesser General Public
8# License as published by the Free Software Foundation; either
9# version 2 of the License, or (at your option) any later version.
10#
11# This library is distributed in the hope that it will be useful,
12# but WITHOUT ANY WARRANTY; without even the implied warranty of
13# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14# Lesser General Public License for more details.
15#
16# You should have received a copy of the GNU Lesser General Public
17# License along with this library; if not, see <http://www.gnu.org/licenses/>.
18#
19
20&dab            d a b
21&da             d a
22&ab             a b
23&dal            d a l
24&ai             a i
25
26####
27# System Instructions
28####
29
30l_sys           001000 0000000000 k:16
31l_trap          001000 0100000000 k:16
32l_msync         001000 1000000000 00000000 00000000
33l_psync         001000 1010000000 00000000 00000000
34l_csync         001000 1100000000 00000000 00000000
35
36l_rfe           001001 ----- ----- -------- --------
37
38####
39# Branch Instructions
40####
41
42l_j             000000 n:s26
43l_jal           000001 n:s26
44l_bnf           000011 n:s26
45l_bf            000100 n:s26
46
47l_jr            010001 ---------- b:5 -----------
48l_jalr          010010 ---------- b:5 -----------
49
50####
51# Memory Instructions
52####
53
54&load           d a i
55@load           ...... d:5 a:5 i:s16                    &load
56
57%store_i        21:s5 0:11
58&store          a b i
59@store          ...... ..... a:5 b:5 ...........        &store i=%store_i
60
61l_lwa           011011 ..... ..... ........ ........    @load
62l_lwz           100001 ..... ..... ........ ........    @load
63l_lws           100010 ..... ..... ........ ........    @load
64l_lbz           100011 ..... ..... ........ ........    @load
65l_lbs           100100 ..... ..... ........ ........    @load
66l_lhz           100101 ..... ..... ........ ........    @load
67l_lhs           100110 ..... ..... ........ ........    @load
68
69l_swa           110011 ..... ..... ..... ...........    @store
70l_sw            110101 ..... ..... ..... ...........    @store
71l_sb            110110 ..... ..... ..... ...........    @store
72l_sh            110111 ..... ..... ..... ...........    @store
73
74####
75# Immediate Operand Instructions
76####
77
78%mtspr_k        21:5 0:11
79
80&rri            d a i
81&rrk            d a k
82@rri            ...... d:5 a:5 i:s16                    &rri
83@rrk            ...... d:5 a:5 k:16                     &rrk
84
85l_nop           000101 01--- ----- k:16
86
87l_addi          100111 ..... ..... ........ ........    @rri
88l_addic         101000 ..... ..... ........ ........    @rri
89l_andi          101001 ..... ..... ........ ........    @rrk
90l_ori           101010 ..... ..... ........ ........    @rrk
91l_xori          101011 ..... ..... ........ ........    @rri
92l_muli          101100 ..... ..... ........ ........    @rri
93
94l_mfspr         101101 ..... ..... ........ ........    @rrk
95l_mtspr         110000 ..... a:5 b:5 ...........        k=%mtspr_k
96
97l_maci          010011 ----- a:5 i:s16
98
99l_movhi         000110 d:5 ----0 k:16
100l_macrc         000110 d:5 ----1 00000000 00000000
101
102####
103# Arithmetic Instructions
104####
105
106l_exths         111000 d:5 a:5 ----- - 0000 -- 1100
107l_extbs         111000 d:5 a:5 ----- - 0001 -- 1100
108l_exthz         111000 d:5 a:5 ----- - 0010 -- 1100
109l_extbz         111000 d:5 a:5 ----- - 0011 -- 1100
110
111l_add           111000 d:5 a:5 b:5   - 00 ---- 0000
112l_addc          111000 d:5 a:5 b:5   - 00 ---- 0001
113l_sub           111000 d:5 a:5 b:5   - 00 ---- 0010
114l_and           111000 d:5 a:5 b:5   - 00 ---- 0011
115l_or            111000 d:5 a:5 b:5   - 00 ---- 0100
116l_xor           111000 d:5 a:5 b:5   - 00 ---- 0101
117l_cmov          111000 d:5 a:5 b:5   - 00 ---- 1110
118l_ff1           111000 d:5 a:5 ----- - 00 ---- 1111
119l_fl1           111000 d:5 a:5 ----- - 01 ---- 1111
120
121l_sll           111000 d:5 a:5 b:5   - 0000 -- 1000
122l_srl           111000 d:5 a:5 b:5   - 0001 -- 1000
123l_sra           111000 d:5 a:5 b:5   - 0010 -- 1000
124l_ror           111000 d:5 a:5 b:5   - 0011 -- 1000
125
126l_mul           111000 d:5 a:5 b:5   - 11 ---- 0110
127l_mulu          111000 d:5 a:5 b:5   - 11 ---- 1011
128l_div           111000 d:5 a:5 b:5   - 11 ---- 1001
129l_divu          111000 d:5 a:5 b:5   - 11 ---- 1010
130
131l_muld          111000 ----- a:5 b:5 - 11 ---- 0111
132l_muldu         111000 ----- a:5 b:5 - 11 ---- 1100
133
134l_mac           110001 ----- a:5 b:5 ------- 0001
135l_macu          110001 ----- a:5 b:5 ------- 0011
136l_msb           110001 ----- a:5 b:5 ------- 0010
137l_msbu          110001 ----- a:5 b:5 ------- 0100
138
139l_slli          101110 d:5 a:5 -------- 00 l:6
140l_srli          101110 d:5 a:5 -------- 01 l:6
141l_srai          101110 d:5 a:5 -------- 10 l:6
142l_rori          101110 d:5 a:5 -------- 11 l:6
143
144####
145# Compare Instructions
146####
147
148l_sfeq          111001 00000 a:5 b:5 -----------
149l_sfne          111001 00001 a:5 b:5 -----------
150l_sfgtu         111001 00010 a:5 b:5 -----------
151l_sfgeu         111001 00011 a:5 b:5 -----------
152l_sfltu         111001 00100 a:5 b:5 -----------
153l_sfleu         111001 00101 a:5 b:5 -----------
154l_sfgts         111001 01010 a:5 b:5 -----------
155l_sfges         111001 01011 a:5 b:5 -----------
156l_sflts         111001 01100 a:5 b:5 -----------
157l_sfles         111001 01101 a:5 b:5 -----------
158
159l_sfeqi         101111 00000 a:5 i:s16
160l_sfnei         101111 00001 a:5 i:s16
161l_sfgtui        101111 00010 a:5 i:s16
162l_sfgeui        101111 00011 a:5 i:s16
163l_sfltui        101111 00100 a:5 i:s16
164l_sfleui        101111 00101 a:5 i:s16
165l_sfgtsi        101111 01010 a:5 i:s16
166l_sfgesi        101111 01011 a:5 i:s16
167l_sfltsi        101111 01100 a:5 i:s16
168l_sflesi        101111 01101 a:5 i:s16
169
170####
171# FP Instructions
172####
173
174lf_add_s        110010 d:5 a:5 b:5   --- 00000000
175lf_sub_s        110010 d:5 a:5 b:5   --- 00000001
176lf_mul_s        110010 d:5 a:5 b:5   --- 00000010
177lf_div_s        110010 d:5 a:5 b:5   --- 00000011
178lf_rem_s        110010 d:5 a:5 b:5   --- 00000110
179lf_madd_s       110010 d:5 a:5 b:5   --- 00000111
180
181lf_itof_s       110010 d:5 a:5 00000 --- 00000100
182lf_ftoi_s       110010 d:5 a:5 00000 --- 00000101
183
184lf_sfeq_s       110010 ----- a:5 b:5 --- 00001000
185lf_sfne_s       110010 ----- a:5 b:5 --- 00001001
186lf_sfgt_s       110010 ----- a:5 b:5 --- 00001010
187lf_sfge_s       110010 ----- a:5 b:5 --- 00001011
188lf_sflt_s       110010 ----- a:5 b:5 --- 00001100
189lf_sfle_s       110010 ----- a:5 b:5 --- 00001101
190