-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSIBTests.cs
executable file
·72 lines (64 loc) · 2.13 KB
/
SIBTests.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
// 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 SIBTests
{
private Byte[] code;
[Test]
public void EvGvSIBNoIndexToEspFromEax()
{
code = new Byte[] {0x89, 0x04, 0x24};
Assert.IsTrue(ModRM.HasSIB(code));
Assert.AreEqual(RegisterName.ESP, SIB.GetBaseRegister(code));
}
[Test]
[ExpectedException(typeof(InvalidOperationException))]
public void GetBaseRegisterWhenNoSIBPresent()
{
// mov ebp,esp
code = new Byte[] {0x89, 0xe5};
Assert.IsFalse(ModRM.HasSIB(code));
SIB.GetBaseRegister(code);
}
[Test]
[ExpectedException(typeof(InvalidOperationException))]
public void GetScaledRegisterWhenNoSIBPresent()
{
// mov ebp,esp
code = new Byte[] {0x89, 0xe5};
Assert.IsFalse(ModRM.HasSIB(code));
SIB.GetScaledRegister(code);
}
[Test]
[ExpectedException(typeof(InvalidOperationException))]
public void GetScalerWhenNoSIBPresent()
{
// mov ebp,esp
code = new Byte[] {0x89, 0xe5};
Assert.IsFalse(ModRM.HasSIB(code));
SIB.GetScaler(code);
}
[Test]
public void GvMSIBRegisterIndex()
{
code = new Byte[] {0x8d, 0x04, 0x02};
Assert.AreEqual(RegisterName.EDX, SIB.GetBaseRegister(code));
Assert.AreEqual(RegisterName.EAX, SIB.GetScaledRegister(code));
Assert.AreEqual(1, SIB.GetScaler(code));
}
[Test]
[ExpectedException(typeof(InvalidOperationException))]
public void HasSIBWhenNoModRMPresent()
{
code = new Byte[] {0x00};
ModRM.HasSIB(code);
}
}
}