/
XS.FPU.cs
138 lines (122 loc) · 3.42 KB
/
XS.FPU.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
using System;
using XSharp.Assembler.x86.x87;
namespace XSharp
{
public partial class XS
{
public static class FPU
{
public static void FloatCompareAndSet(XSRegisters.RegisterFPU register)
{
new FloatCompareAndSet
{
DestinationReg = register.RegEnum
};
}
public static void FloatStoreAndPop(XSRegisters.Register32 register, bool isIndirect = false, int? displacement = null, XSRegisters.RegisterSize? size = null)
{
if (displacement != null)
{
isIndirect = true;
if (displacement == 0)
{
displacement = null;
}
}
if (size == null)
{
if (isIndirect)
{
throw new InvalidOperationException("No size specified!");
}
size = register.Size;
}
new FloatStoreAndPop
{
DestinationReg = register.RegEnum,
DestinationIsIndirect = isIndirect,
DestinationDisplacement = displacement,
Size = (byte)size
};
}
public static void FloatStoreAndPop(XSRegisters.RegisterFPU register)
{
new FloatStoreAndPop
{
DestinationReg = register.RegEnum
};
}
public static void FloatLoad(XSRegisters.Register32 register, bool destinationIsIndirect = false, int? displacement = null, XSRegisters.RegisterSize? size = null)
{
Do<FloatLoad>(register, isIndirect: destinationIsIndirect, displacement: displacement, size: size);
}
public static void FloatAbs()
{
new FloatABS();
}
public static void FloatInit()
{
new FloatInit();
}
public static void FloatNegate()
{
new FloatNegate();
}
public static void FloatAdd(XSRegisters.Register32 destination, bool isIndirect = false, XSRegisters.RegisterSize? size = null)
{
if (size == null)
{
if (isIndirect)
{
throw new InvalidOperationException("No size specified!");
}
size = destination.Size;
}
new FloatAdd
{
DestinationReg = destination,
DestinationIsIndirect = isIndirect,
Size = (byte)size.Value
};
}
public static void IntLoad(XSRegisters.Register32 destination, bool isIndirect = false, int? displacement = null, XSRegisters.RegisterSize? size = null)
{
if (size == null)
{
if (isIndirect)
{
throw new InvalidOperationException("No size specified!");
}
size = destination.Size;
}
if (displacement != null)
{
isIndirect = true;
}
new IntLoad
{
DestinationReg = destination,
DestinationIsIndirect = isIndirect,
Size = (byte)size.Value
};
}
public static void IntStoreWithTruncate(XSRegisters.Register32 destination, bool isIndirect = false, XSRegisters.RegisterSize? size = null)
{
if (size == null)
{
if (isIndirect)
{
throw new InvalidOperationException("No size specified!");
}
size = destination.Size;
}
new IntStoreWithTrunc
{
DestinationReg = destination,
DestinationIsIndirect = isIndirect,
Size = (byte)size.Value
};
}
}
}
}