This repository has been archived by the owner on Nov 22, 2023. It is now read-only.
forked from gek169/SISA64
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinsns.h
356 lines (336 loc) · 4.42 KB
/
insns.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
static const char* insn_names[98] = {
"hlt",
"nop",
"become_user",
"dread",
"dwrite",
"syscall",
"im64",
"im32",
"im16",
"im8",
"ld64",
"ld32",
"ld16",
"ld8",
"st64",
"st32",
"st16",
"st8",
"ild64",
"ild32",
"ild16",
"ild8",
"ist64",
"ist32",
"ist16",
"ist8",
"mov",
"lsh",
"rsh",
"and",
"or",
"xor",
"compl",
"neg",
"bool",
"not",
"iadd",
"isub",
"imul",
"udiv",
"umod",
"idiv",
"imod",
"se32",
"se16",
"se8",
"ucmp",
"icmp",
"jmp",
"jnz",
"ret",
"call",
"getstp",
"setstp",
"push64",
"push32",
"push16",
"push8",
"pop64",
"pop32",
"pop16",
"pop8",
//float
"itod",
"itof",
"dtoi",
"ftoi",
"dadd",
"dsub",
"dmul",
"ddiv",
"fadd",
"fsub",
"fmul",
"fdiv",
//float cmp
"dcmp",
"fcmp",
//increment, decrement
"inc",
"dec",
//stack-relative load and store
"ldsp64",
"ldsp32",
"ldsp16",
"ldsp8",
"stsp64",
"stsp32",
"stsp16",
"stsp8",
//big-endian or little-endian swap.
"bswap64",
"bswap32",
"bswap16",
//conditional move
"mnz",
//jump if zero. Makes compares a bit easier.
"jiz",
"jlt",
"jgt",
"ze8",
"ze16",
"ze32",
//float-to-float conversion
"ftod",
"dtof"
//dummy
//,""
};
//how many bytes of arguments does the instruction take?
static const unsigned insn_nargs[98] = {
//halt and nop,
0,
0,
//become user takes 4 regids and 1 uint8 immediate.
5,
//dread
1,
//dwrite
2,
//syscall
0,
//immediate loads
9,
5,
3,
2,
//static loads all take a regid and a qword address.
9,9,
9,9,
//static stores are the same
9,9,
9,9,
//iloads and istores all take 2 regids
2,2,2,2,
2,2,2,2,
//mov takes 2 regids
2,
//lsh,rsh,and,or,xor
2, 2, 2, 2, 2,
//compl, neg, bool, not,
1, 1, 1, 1,
//iadd-umod
2,2,2, //iadd, isub, imul
2,2, //udiv,umod,
2,2, //idiv,imod,
//sign extend
1,
1,
1,
//ucmp and icmp take 3
3,3,
//jmp takes just a qword
8,
//jnz needs a regid and a qword...
9,
//ret needs nothing
0,
//call needs a qword
8,
//stack pointer manip needs a regid
1,1,
//all pushes and pops need a regid
1,1,1,1,
1,1,1,1,
//floating point <-> int conversions need 1 regid
1,1,1,1,
//double and float ops need 2 regids
2,2,2,2,
2,2,2,2,
//float compares need 3 regids
3,3,
//increment decrement both take a regid
1,1,
//stack relative load/store
5,5,5,5,
5,5,5,5,
//bswap
1,1,1,
//mnz takes 3 regids.
3,
//jiz needs a regid and a qword...
9,
//jlt and jgt are the same
9,
9,
//zero extend 8,16,32
1,
1,
1,
//ftod, dtof
1,
1
//dummy
//,0
};
static const char* insn_repl[98] = {
"bytes0;",
"bytes1;",
//become user has arguments
"bytes2,",
//dread and dwrite have arguments
"bytes3,",
"bytes4,",
//syscall has no arguments.
"bytes5;",
//imXX has args
"bytes6,",
"bytes7,",
"bytes8,",
"bytes9,",
//ldXX has args
"bytes10,",
"bytes11,",
"bytes12,",
"bytes13,",
//stXX has args
"bytes14,",
"bytes15,",
"bytes16,",
"bytes17,",
//ildXX has args
"bytes18,",
"bytes19,",
"bytes20,",
"bytes21,",
//istXX has args
"bytes22,",
"bytes23,",
"bytes24,",
"bytes25,",
//mov has args
"bytes26,",
//lsh,rsh have args
"bytes27,",
"bytes28,",
//and,or,xor
"bytes29,",
"bytes30,",
"bytes31,",
//compl, neg, bool, not have args
"bytes32,",
"bytes33,",
"bytes34,",
"bytes35,",
//iadd,isub,imul have args
"bytes36,",
"bytes37,",
"bytes38,",
//udiv,umod
"bytes39,",
"bytes40,",
//idiv, imod
"bytes41,",
"bytes42,",
//sign extend
"bytes43,",
"bytes44,",
"bytes45,",
//int compares
"bytes46,",
"bytes47,",
//jumps
"bytes48,",
"bytes49,", //JNZ
//ret
"bytes50;",
//call
"bytes51,",
//getstp/setstp
"bytes52,",
"bytes53,",
//pushXX
"bytes54,",
"bytes55,",
"bytes56,",
"bytes57,",
//popXX
"bytes58,",
"bytes59,",
"bytes60,",
"bytes61,",
//float <-> int
"bytes62,",
"bytes63,",
"bytes64,",
"bytes65,",
//double ops
"bytes66,",
"bytes67,",
"bytes68,",
"bytes69,",
//float ops
"bytes70,",
"bytes71,",
"bytes72,",
"bytes73,",
//float compares
"bytes74,",
"bytes75,",
//inc dec
"bytes76,",
"bytes77,",
//,"dummy"
//stack relative load
"bytes78,",
"bytes79,",
"bytes80,",
"bytes81,",
//stack relative store
"bytes82,",
"bytes83,",
"bytes84,",
"bytes85,",
//bswap64,32,16
"bytes86,",
"bytes87,",
"bytes88,",
//mnz
"bytes89,",
//jiz
"bytes90,",
//jlt, jgt
"bytes91,",
"bytes92,",
/*ze8,ze16,ze32*/
"bytes93,",
"bytes94,",
"bytes95,",
/*float-to-float*/
"bytes96,",
"bytes97,"
//,""
};
static const unsigned n_insns = 98;