-
Notifications
You must be signed in to change notification settings - Fork 0
/
X86OpcodeTest.cs
executable file
·562 lines (497 loc) · 22.5 KB
/
X86OpcodeTest.cs
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
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
// This file is part of bugreport.
// Copyright (c) 2006-2009 The bugreport Developers.
// See AUTHORS.txt for details.
// Licensed under the GNU General Public License, Version 3 (GPLv3).
// See LICENSE.txt for details.
using System;
using NUnit.Framework;
namespace bugreport
{
[TestFixture]
public class X86OpcodeTest
{
private readonly Opcode opcode = new X86Opcode();
private Byte[] code;
private OpcodeEncoding encoding;
[Test]
public void AnotherGvM()
{
code = new Byte[] {0x8d, 0x04, 0x02};
Assert.AreEqual(code.Length, opcode.GetInstructionLengthFor(code));
Assert.IsTrue(opcode.HasModRM(code));
encoding = opcode.GetEncodingFor(code);
Assert.AreEqual(OpcodeEncoding.GvM, encoding);
var operatorEffect = opcode.GetOperatorEffectFor(code);
Assert.AreEqual(OperatorEffect.Assignment, operatorEffect);
Assert.AreEqual(RegisterName.EAX, opcode.GetDestinationRegisterFor(code));
}
[Test]
public void EbGb()
{
// mov BYTE PTR [eax+16],bl
code = new Byte[] {0x88, 0x58, 0x10};
Assert.AreEqual(code.Length, opcode.GetInstructionLengthFor(code));
encoding = opcode.GetEncodingFor(code);
Assert.AreEqual(OpcodeEncoding.EbGb, encoding);
var operatorEffect = opcode.GetOperatorEffectFor(code);
Assert.AreEqual(OperatorEffect.Assignment, operatorEffect);
Assert.AreEqual(RegisterName.EBX, opcode.GetSourceRegisterFor(code));
}
[Test]
public void EbIb()
{
const byte IMMEDIATE = 0;
code = new Byte[] {0xc6, 0x40, 0x10, IMMEDIATE};
Assert.AreEqual(code.Length, opcode.GetInstructionLengthFor(code));
encoding = opcode.GetEncodingFor(code);
Assert.AreEqual(OpcodeEncoding.EbIb, encoding);
Assert.AreEqual(IMMEDIATE, opcode.GetImmediateFor(code));
}
[Test]
public void EvGv()
{
code = new Byte[] {0x89, 0x00};
Assert.AreEqual(code.Length, opcode.GetInstructionLengthFor(code));
encoding = opcode.GetEncodingFor(code);
Assert.AreEqual(OpcodeEncoding.EvGv, encoding);
}
[Test]
public void EvGvSub()
{
code = new Byte[] {0x29, 0xc4};
Assert.AreEqual(code.Length, opcode.GetInstructionLengthFor(code));
encoding = opcode.GetEncodingFor(code);
Assert.AreEqual(OpcodeEncoding.EvGv, encoding);
var operatorEffect = opcode.GetOperatorEffectFor(code);
Assert.AreEqual(OperatorEffect.Sub, operatorEffect);
}
[Test]
public void EvIbAdd()
{
// 83 c0 0f add eax,0xf
code = new Byte[] {0x83, 0xc0, 0x0f};
Assert.AreEqual(code.Length, opcode.GetInstructionLengthFor(code));
encoding = opcode.GetEncodingFor(code);
Assert.AreEqual(OpcodeEncoding.EvIb, encoding);
var operatorEffect = opcode.GetOperatorEffectFor(code);
Assert.AreEqual(OperatorEffect.Add, operatorEffect);
}
[Test]
public void EvIbAnd()
{
code = new Byte[] {0x83, 0xe4, 0xf0};
Assert.AreEqual(code.Length, opcode.GetInstructionLengthFor(code));
encoding = opcode.GetEncodingFor(code);
Assert.AreEqual(OpcodeEncoding.EvIb, encoding);
var operatorEffect = opcode.GetOperatorEffectFor(code);
Assert.AreEqual(OperatorEffect.And, operatorEffect);
}
[Test]
public void EvIbCmp()
{
code = new Byte[] {0x83, 0x7d, 0x08, 0x01};
Assert.AreEqual(code.Length, opcode.GetInstructionLengthFor(code));
encoding = opcode.GetEncodingFor(code);
Assert.AreEqual(OpcodeEncoding.EvIb, encoding);
var operatorEffect = opcode.GetOperatorEffectFor(code);
Assert.AreEqual(OperatorEffect.Cmp, operatorEffect);
}
[Test]
public void EvIbShl()
{
code = new Byte[] {0xc1, 0xe0, 0x04};
Assert.AreEqual(code.Length, opcode.GetInstructionLengthFor(code));
encoding = opcode.GetEncodingFor(code);
Assert.AreEqual(OpcodeEncoding.EvIb, encoding);
var operatorEffect = opcode.GetOperatorEffectFor(code);
Assert.AreEqual(OperatorEffect.Shl, operatorEffect);
}
[Test]
public void EvIbShr()
{
code = new Byte[] {0xc1, 0xe8, 0x04};
Assert.AreEqual(code.Length, opcode.GetInstructionLengthFor(code));
encoding = opcode.GetEncodingFor(code);
Assert.AreEqual(OpcodeEncoding.EvIb, encoding);
var operatorEffect = opcode.GetOperatorEffectFor(code);
Assert.AreEqual(OperatorEffect.Shr, operatorEffect);
}
[Test]
public void EvIbSub()
{
code = new Byte[] {0x83, 0xec, 0x08};
Assert.AreEqual(code.Length, opcode.GetInstructionLengthFor(code));
encoding = opcode.GetEncodingFor(code);
Assert.AreEqual(OpcodeEncoding.EvIb, encoding);
var operatorEffect = opcode.GetOperatorEffectFor(code);
Assert.AreEqual(OperatorEffect.Sub, operatorEffect);
}
[Test]
public void EvIz()
{
code = new Byte[] {0xc7, 0x04, 0x24, 0x10, 0x00, 0x00, 0x00};
Assert.AreEqual(code.Length, opcode.GetInstructionLengthFor(code));
encoding = opcode.GetEncodingFor(code);
Assert.AreEqual(OpcodeEncoding.EvIz, encoding);
Assert.IsTrue(opcode.HasDestinationRegister(code));
Assert.AreEqual(RegisterName.ESP, opcode.GetDestinationRegisterFor(code));
Assert.AreEqual(0x10, opcode.GetImmediateFor(code));
}
[Test]
public void GvEbOffsetToRegister()
{
// movzx edx,BYTE PTR ds:0x80495e0
code = new Byte[] {0x0f, 0xb6, 0x15, 0xe0, 0x95, 0x04, 0x08};
Assert.AreEqual(code.Length, opcode.GetInstructionLengthFor(code));
encoding = opcode.GetEncodingFor(code);
Assert.AreEqual(OpcodeEncoding.GvEb, encoding);
var operatorEffect = opcode.GetOperatorEffectFor(code);
Assert.AreEqual(OperatorEffect.Assignment, operatorEffect);
}
[Test]
public void GvEbRegisterToRegister()
{
// movzx ebx,BYTE PTR [eax]
code = new Byte[] {0x0f, 0xb6, 0x18};
Assert.AreEqual(code.Length, opcode.GetInstructionLengthFor(code));
encoding = opcode.GetEncodingFor(code);
Assert.AreEqual(OpcodeEncoding.GvEb, encoding);
var operatorEffect = opcode.GetOperatorEffectFor(code);
Assert.AreEqual(OperatorEffect.Assignment, operatorEffect);
Assert.AreEqual(RegisterName.EAX, opcode.GetSourceRegisterFor(code));
}
[Test]
public void GvEv()
{
// mov eax, [eax]
code = new Byte[] {0x8b, 0x00};
Assert.AreEqual(code.Length, opcode.GetInstructionLengthFor(code));
encoding = opcode.GetEncodingFor(code);
Assert.AreEqual(OpcodeEncoding.GvEv, encoding);
Assert.AreEqual(RegisterName.EAX, opcode.GetSourceRegisterFor(code));
Assert.AreEqual(RegisterName.EAX, opcode.GetDestinationRegisterFor(code));
}
[Test]
public void GvEvDword()
{
// mov eax, [0x11223344]
code = new Byte[] {0x8b, 0x05, 0x44, 0x33, 0x22, 0x11};
Assert.AreEqual(code.Length, opcode.GetInstructionLengthFor(code));
encoding = opcode.GetEncodingFor(code);
Assert.AreEqual(OpcodeEncoding.GvEv, encoding);
Assert.AreEqual(RegisterName.None, opcode.GetSourceRegisterFor(code));
Assert.AreEqual(RegisterName.EAX, opcode.GetDestinationRegisterFor(code));
}
[Test]
public void GvEvSIB()
{
// mov eax, [base_register+scale_register*scaler
code = new Byte[] {0x8b, 0x04, 0x24};
Assert.AreEqual(code.Length, opcode.GetInstructionLengthFor(code));
encoding = opcode.GetEncodingFor(code);
Assert.AreEqual(OpcodeEncoding.GvEv, encoding);
Assert.AreEqual(RegisterName.None, opcode.GetSourceRegisterFor(code));
Assert.AreEqual(RegisterName.EAX, opcode.GetDestinationRegisterFor(code));
}
[Test]
public void GvM()
{
// lea edx, [eax+16]
code = new Byte[] {0x8d, 0x50, 0x10};
Assert.IsTrue(opcode.HasModRM(code));
Assert.AreEqual(code.Length, opcode.GetInstructionLengthFor(code));
encoding = opcode.GetEncodingFor(code);
Assert.AreEqual(OpcodeEncoding.GvM, encoding);
Assert.AreEqual(RegisterName.EAX, opcode.GetSourceRegisterFor(code));
var operatorEffect = opcode.GetOperatorEffectFor(code);
Assert.AreEqual(OperatorEffect.Assignment, operatorEffect);
}
[Test]
public void Halt()
{
code = new Byte[] {0xf4};
Assert.AreEqual(code.Length, opcode.GetInstructionLengthFor(code));
encoding = opcode.GetEncodingFor(code);
Assert.AreEqual(OpcodeEncoding.None, encoding);
Assert.AreEqual(StackEffect.None, opcode.GetStackEffectFor(code));
Assert.IsTrue(opcode.TerminatesFunction(code));
}
[Test]
[ExpectedException(typeof(InvalidOperationException))]
public void InvalidGetImmediate()
{
code = new Byte[] {0x90};
Assert.IsFalse(opcode.HasImmediate(code));
opcode.GetImmediateFor(code);
}
[Test]
public void Jb()
{
code = new Byte[] {0x75, 0x06};
Assert.AreEqual(code.Length, opcode.GetInstructionLengthFor(code));
encoding = opcode.GetEncodingFor(code);
Assert.AreEqual(OpcodeEncoding.Jb, encoding);
var operatorEffect = opcode.GetOperatorEffectFor(code);
Assert.AreEqual(OperatorEffect.Jnz, operatorEffect);
}
[Test]
public void Jz()
{
code = new Byte[] {0xe8, 0x14, 0xff, 0xff, 0xff};
Assert.AreEqual(code.Length, opcode.GetInstructionLengthFor(code));
encoding = opcode.GetEncodingFor(code);
Assert.AreEqual(OpcodeEncoding.Jz, encoding);
Assert.AreEqual(OperatorEffect.Call, opcode.GetOperatorEffectFor(code));
Assert.IsTrue(opcode.HasImmediate(code));
Assert.AreEqual(0xffffff14, opcode.GetImmediateFor(code));
}
[Test]
public void LeaveReturn()
{
code = new Byte[] {0xc9};
Assert.AreEqual(OperatorEffect.Leave, opcode.GetOperatorEffectFor(code));
Assert.IsFalse(opcode.TerminatesFunction(code));
code = new Byte[] {0xc3};
Assert.AreEqual(OperatorEffect.Return, opcode.GetOperatorEffectFor(code));
Assert.IsTrue(opcode.TerminatesFunction(code));
}
[Test]
public void None()
{
code = new Byte[] {0x90};
Assert.AreEqual(code.Length, opcode.GetInstructionLengthFor(code));
encoding = opcode.GetEncodingFor(code);
Assert.AreEqual(OpcodeEncoding.None, encoding);
Assert.AreEqual(StackEffect.None, opcode.GetStackEffectFor(code));
}
[Test]
public void ObAL()
{
// mov ds:0x80495e0,al
code = new Byte[] {0xa2, 0xe0, 0x95, 0x04, 0x08};
Assert.AreEqual(code.Length, opcode.GetInstructionLengthFor(code));
encoding = opcode.GetEncodingFor(code);
Assert.AreEqual(OpcodeEncoding.ObAL, encoding);
var operatorEffect = opcode.GetOperatorEffectFor(code);
Assert.AreEqual(OperatorEffect.Assignment, operatorEffect);
}
[Test]
public void PoprAX()
{
code = new Byte[] {0x58};
encoding = opcode.GetEncodingFor(code);
Assert.AreEqual(OpcodeEncoding.rAX, encoding);
Assert.AreEqual(StackEffect.Pop, opcode.GetStackEffectFor(code));
Assert.IsFalse(opcode.HasSourceRegister(code));
Assert.IsTrue(opcode.HasDestinationRegister(code));
Assert.AreEqual(RegisterName.EAX, opcode.GetDestinationRegisterFor(code));
}
[Test]
public void PoprBP()
{
code = new Byte[] {0x5d};
encoding = opcode.GetEncodingFor(code);
Assert.AreEqual(OpcodeEncoding.rBP, encoding);
Assert.AreEqual(StackEffect.Pop, opcode.GetStackEffectFor(code));
Assert.AreEqual(RegisterName.None, opcode.GetSourceRegisterFor(code));
Assert.AreEqual(RegisterName.EBP, opcode.GetDestinationRegisterFor(code));
}
[Test]
public void PoprBX()
{
code = new Byte[] {0x5b};
encoding = opcode.GetEncodingFor(code);
Assert.AreEqual(OpcodeEncoding.rBX, encoding);
Assert.AreEqual(StackEffect.Pop, opcode.GetStackEffectFor(code));
Assert.AreEqual(RegisterName.EBX, opcode.GetDestinationRegisterFor(code));
Assert.AreEqual(RegisterName.None, opcode.GetSourceRegisterFor(code));
}
[Test]
public void PoprCX()
{
code = new Byte[] {0x59};
Assert.AreEqual(code.Length, opcode.GetInstructionLengthFor(code));
encoding = opcode.GetEncodingFor(code);
Assert.AreEqual(OpcodeEncoding.rCX, encoding);
Assert.AreEqual(StackEffect.Pop, opcode.GetStackEffectFor(code));
Assert.IsFalse(opcode.HasSourceRegister(code));
Assert.IsTrue(opcode.HasDestinationRegister(code));
Assert.AreEqual(RegisterName.ECX, opcode.GetDestinationRegisterFor(code));
}
[Test]
public void PoprDX()
{
code = new Byte[] {0x5a};
encoding = opcode.GetEncodingFor(code);
Assert.AreEqual(OpcodeEncoding.rDX, encoding);
Assert.AreEqual(StackEffect.Pop, opcode.GetStackEffectFor(code));
Assert.IsFalse(opcode.HasSourceRegister(code));
Assert.IsTrue(opcode.HasDestinationRegister(code));
Assert.AreEqual(RegisterName.EDX, opcode.GetDestinationRegisterFor(code));
}
[Test]
public void PoprSI()
{
code = new Byte[] {0x5e};
Assert.AreEqual(code.Length, opcode.GetInstructionLengthFor(code));
encoding = opcode.GetEncodingFor(code);
Assert.AreEqual(OpcodeEncoding.rSI, encoding);
Assert.AreEqual(StackEffect.Pop, opcode.GetStackEffectFor(code));
Assert.IsFalse(opcode.HasSourceRegister(code));
Assert.IsTrue(opcode.HasDestinationRegister(code));
Assert.AreEqual(RegisterName.ESI, opcode.GetDestinationRegisterFor(code));
}
[Test]
public void PoprSP()
{
code = new Byte[] {0x5c};
encoding = opcode.GetEncodingFor(code);
Assert.AreEqual(OpcodeEncoding.rSP, encoding);
Assert.AreEqual(StackEffect.Pop, opcode.GetStackEffectFor(code));
Assert.IsFalse(opcode.HasSourceRegister(code));
Assert.IsTrue(opcode.HasDestinationRegister(code));
Assert.AreEqual(RegisterName.None, opcode.GetSourceRegisterFor(code));
Assert.AreEqual(RegisterName.ESP, opcode.GetDestinationRegisterFor(code));
}
[Test]
public void PushIz()
{
code = new Byte[] {0x68, 0x10, 0x84, 0x04, 0x08};
Assert.AreEqual(code.Length, opcode.GetInstructionLengthFor(code));
encoding = opcode.GetEncodingFor(code);
Assert.AreEqual(OpcodeEncoding.Iz, encoding);
Assert.AreEqual(StackEffect.Push, opcode.GetStackEffectFor(code));
Assert.IsFalse(opcode.HasSourceRegister(code));
Assert.IsFalse(opcode.HasDestinationRegister(code));
Assert.IsTrue(opcode.HasImmediate(code));
Assert.AreEqual(0x08048410, opcode.GetImmediateFor(code));
}
[Test]
public void PushrAX()
{
code = new Byte[] {0x50};
Assert.AreEqual(code.Length, opcode.GetInstructionLengthFor(code));
encoding = opcode.GetEncodingFor(code);
Assert.AreEqual(OpcodeEncoding.rAX, encoding);
Assert.AreEqual(StackEffect.Push, opcode.GetStackEffectFor(code));
Assert.IsTrue(opcode.HasSourceRegister(code));
Assert.IsFalse(opcode.HasDestinationRegister(code));
Assert.AreEqual(RegisterName.EAX, opcode.GetSourceRegisterFor(code));
}
[Test]
public void PushrBP()
{
code = new Byte[] {0x55};
encoding = opcode.GetEncodingFor(code);
Assert.AreEqual(OpcodeEncoding.rBP, encoding);
Assert.AreEqual(StackEffect.Push, opcode.GetStackEffectFor(code));
Assert.AreEqual(RegisterName.None, opcode.GetDestinationRegisterFor(code));
Assert.AreEqual(RegisterName.EBP, opcode.GetSourceRegisterFor(code));
}
[Test]
public void PushrBX()
{
code = new Byte[] {0x53};
encoding = opcode.GetEncodingFor(code);
Assert.AreEqual(OpcodeEncoding.rBX, encoding);
Assert.AreEqual(StackEffect.Push, opcode.GetStackEffectFor(code));
Assert.AreEqual(RegisterName.None, opcode.GetDestinationRegisterFor(code));
Assert.AreEqual(RegisterName.EBX, opcode.GetSourceRegisterFor(code));
}
[Test]
public void PushrCX()
{
code = new Byte[] {0x51};
Assert.AreEqual(code.Length, opcode.GetInstructionLengthFor(code));
encoding = opcode.GetEncodingFor(code);
Assert.AreEqual(OpcodeEncoding.rCX, encoding);
Assert.AreEqual(StackEffect.Push, opcode.GetStackEffectFor(code));
Assert.IsTrue(opcode.HasSourceRegister(code));
Assert.IsFalse(opcode.HasDestinationRegister(code));
Assert.AreEqual(RegisterName.ECX, opcode.GetSourceRegisterFor(code));
}
[Test]
public void PushrDX()
{
code = new Byte[] {0x52};
encoding = opcode.GetEncodingFor(code);
Assert.AreEqual(OpcodeEncoding.rDX, encoding);
Assert.AreEqual(StackEffect.Push, opcode.GetStackEffectFor(code));
Assert.IsTrue(opcode.HasSourceRegister(code));
Assert.IsFalse(opcode.HasDestinationRegister(code));
Assert.AreEqual(RegisterName.EDX, opcode.GetSourceRegisterFor(code));
}
[Test]
public void PushrSI()
{
code = new Byte[] {0x56};
Assert.AreEqual(code.Length, opcode.GetInstructionLengthFor(code));
encoding = opcode.GetEncodingFor(code);
Assert.AreEqual(OpcodeEncoding.rSI, encoding);
Assert.AreEqual(StackEffect.Push, opcode.GetStackEffectFor(code));
Assert.IsTrue(opcode.HasSourceRegister(code));
Assert.IsFalse(opcode.HasDestinationRegister(code));
Assert.AreEqual(RegisterName.ESI, opcode.GetSourceRegisterFor(code));
}
[Test]
public void PushrSP()
{
code = new Byte[] {0x54};
encoding = opcode.GetEncodingFor(code);
Assert.AreEqual(OpcodeEncoding.rSP, encoding);
Assert.AreEqual(StackEffect.Push, opcode.GetStackEffectFor(code));
Assert.IsTrue(opcode.HasSourceRegister(code));
Assert.IsFalse(opcode.HasDestinationRegister(code));
Assert.AreEqual(RegisterName.ESP, opcode.GetSourceRegisterFor(code));
Assert.AreEqual(RegisterName.None, opcode.GetDestinationRegisterFor(code));
}
[Test]
[ExpectedException(typeof(InvalidOpcodeException))]
public void UnknownOpcode()
{
code = new Byte[] {0xf0, 0x00};
opcode.GetEncodingFor(code);
}
[Test]
public void XorEvGv()
{
// xor EBP,EBP
code = new Byte[] {0x31, 0xed};
Assert.AreEqual(code.Length, opcode.GetInstructionLengthFor(code));
encoding = opcode.GetEncodingFor(code);
Assert.AreEqual(OpcodeEncoding.EvGv, encoding);
Assert.AreEqual(OperatorEffect.Xor, opcode.GetOperatorEffectFor(code));
Assert.AreEqual(RegisterName.EBP, opcode.GetDestinationRegisterFor(code));
Assert.AreEqual(RegisterName.EBP, opcode.GetSourceRegisterFor(code));
}
[Test]
public void rAxIv()
{
code = new Byte[] {0xb8, 0x00, 0x00, 0x00, 0x00};
Assert.AreEqual(code.Length, opcode.GetInstructionLengthFor(code));
encoding = opcode.GetEncodingFor(code);
Assert.AreEqual(OpcodeEncoding.rAxIv, encoding);
Assert.AreEqual(RegisterName.EAX, opcode.GetDestinationRegisterFor(code));
}
[Test]
public void rAxIz()
{
code = new Byte[] {0x05, 0x04, 0x01, 0x00, 0x00};
Assert.AreEqual(code.Length, opcode.GetInstructionLengthFor(code));
encoding = opcode.GetEncodingFor(code);
Assert.AreEqual(OpcodeEncoding.rAxIz, encoding);
var operatorEffect = opcode.GetOperatorEffectFor(code);
Assert.AreEqual(OperatorEffect.Add, operatorEffect);
}
[Test]
public void rAxOv()
{
code = new Byte[] {0xa1, 0xe4, 0x84, 0x04, 0x08};
Assert.AreEqual(code.Length, opcode.GetInstructionLengthFor(code));
encoding = opcode.GetEncodingFor(code);
Assert.AreEqual(OpcodeEncoding.rAxOv, encoding);
var operatorEffect = opcode.GetOperatorEffectFor(code);
Assert.AreEqual(OperatorEffect.Assignment, operatorEffect);
}
}
}