Skip to content

Commit 65dfb13

Browse files
committed
Merging
2 parents f422ca4 + 9c16ec7 commit 65dfb13

File tree

6 files changed

+319
-6
lines changed

6 files changed

+319
-6
lines changed

BEXTR.c

+11-3
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,20 @@ int __stdcall BEXTRInstructionEmulator(
2323
unsigned int start = src2 & 0xFF;
2424
unsigned int len = (src2 & 0xFF00) >> 8;
2525

26+
unsigned int s_field;
27+
unsigned int l_field;
28+
2629
if (start >= 32)
27-
start = 0;
30+
s_field = 0;
31+
else
32+
s_field = (src1 >> start);
33+
2834
if (len >= 32)
29-
len = 0;
35+
l_field = 0;
36+
else
37+
l_field = (1 << len);
3038

31-
unsigned int dest = (src1 >> start) & ((1 << len) - 1);
39+
unsigned int dest = s_field & (l_field - 1);
3240

3341
// Set flags
3442
context->flags &= (~FLAG_ZF) & (~FLAG_CF) & (~FLAG_OF);

UDEmulator.sln

+14
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "UDEmulator", "UDEmulator.vc
77
EndProject
88
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "UDTest", "UDTest\UDTest.vcxproj", "{8931079B-57DA-4CAF-BA3D-9B64E0898522}"
99
EndProject
10+
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "UDMachineTester", "UDMachineTester\UDMachineTester.vcxproj", "{9B074301-533B-4CC8-8EF2-05697FDD1B8F}"
11+
EndProject
1012
Global
1113
GlobalSection(SolutionConfigurationPlatforms) = preSolution
1214
Debug|ARM = Debug|ARM
@@ -55,6 +57,18 @@ Global
5557
{8931079B-57DA-4CAF-BA3D-9B64E0898522}.Release|x64.Build.0 = Release|x64
5658
{8931079B-57DA-4CAF-BA3D-9B64E0898522}.Release|x86.ActiveCfg = Release|Win32
5759
{8931079B-57DA-4CAF-BA3D-9B64E0898522}.Release|x86.Build.0 = Release|Win32
60+
{9B074301-533B-4CC8-8EF2-05697FDD1B8F}.Debug|ARM.ActiveCfg = Debug|Win32
61+
{9B074301-533B-4CC8-8EF2-05697FDD1B8F}.Debug|ARM64.ActiveCfg = Debug|Win32
62+
{9B074301-533B-4CC8-8EF2-05697FDD1B8F}.Debug|x64.ActiveCfg = Debug|x64
63+
{9B074301-533B-4CC8-8EF2-05697FDD1B8F}.Debug|x64.Build.0 = Debug|x64
64+
{9B074301-533B-4CC8-8EF2-05697FDD1B8F}.Debug|x86.ActiveCfg = Debug|Win32
65+
{9B074301-533B-4CC8-8EF2-05697FDD1B8F}.Debug|x86.Build.0 = Debug|Win32
66+
{9B074301-533B-4CC8-8EF2-05697FDD1B8F}.Release|ARM.ActiveCfg = Release|Win32
67+
{9B074301-533B-4CC8-8EF2-05697FDD1B8F}.Release|ARM64.ActiveCfg = Release|Win32
68+
{9B074301-533B-4CC8-8EF2-05697FDD1B8F}.Release|x64.ActiveCfg = Release|x64
69+
{9B074301-533B-4CC8-8EF2-05697FDD1B8F}.Release|x64.Build.0 = Release|x64
70+
{9B074301-533B-4CC8-8EF2-05697FDD1B8F}.Release|x86.ActiveCfg = Release|Win32
71+
{9B074301-533B-4CC8-8EF2-05697FDD1B8F}.Release|x86.Build.0 = Release|Win32
5872
EndGlobalSection
5973
GlobalSection(SolutionProperties) = preSolution
6074
HideSolutionNode = FALSE
+150
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,150 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<ItemGroup Label="ProjectConfigurations">
4+
<ProjectConfiguration Include="Debug|Win32">
5+
<Configuration>Debug</Configuration>
6+
<Platform>Win32</Platform>
7+
</ProjectConfiguration>
8+
<ProjectConfiguration Include="Release|Win32">
9+
<Configuration>Release</Configuration>
10+
<Platform>Win32</Platform>
11+
</ProjectConfiguration>
12+
<ProjectConfiguration Include="Debug|x64">
13+
<Configuration>Debug</Configuration>
14+
<Platform>x64</Platform>
15+
</ProjectConfiguration>
16+
<ProjectConfiguration Include="Release|x64">
17+
<Configuration>Release</Configuration>
18+
<Platform>x64</Platform>
19+
</ProjectConfiguration>
20+
</ItemGroup>
21+
<PropertyGroup Label="Globals">
22+
<ProjectGuid>{9B074301-533B-4CC8-8EF2-05697FDD1B8F}</ProjectGuid>
23+
<Keyword>Win32Proj</Keyword>
24+
<RootNamespace>UDMachineTester</RootNamespace>
25+
<WindowsTargetPlatformVersion>8.1</WindowsTargetPlatformVersion>
26+
</PropertyGroup>
27+
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
28+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
29+
<ConfigurationType>Application</ConfigurationType>
30+
<UseDebugLibraries>true</UseDebugLibraries>
31+
<PlatformToolset>v140</PlatformToolset>
32+
<CharacterSet>Unicode</CharacterSet>
33+
</PropertyGroup>
34+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
35+
<ConfigurationType>Application</ConfigurationType>
36+
<UseDebugLibraries>false</UseDebugLibraries>
37+
<PlatformToolset>v140</PlatformToolset>
38+
<WholeProgramOptimization>true</WholeProgramOptimization>
39+
<CharacterSet>Unicode</CharacterSet>
40+
</PropertyGroup>
41+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
42+
<ConfigurationType>Application</ConfigurationType>
43+
<UseDebugLibraries>true</UseDebugLibraries>
44+
<PlatformToolset>v140</PlatformToolset>
45+
<CharacterSet>Unicode</CharacterSet>
46+
</PropertyGroup>
47+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
48+
<ConfigurationType>Application</ConfigurationType>
49+
<UseDebugLibraries>false</UseDebugLibraries>
50+
<PlatformToolset>v140</PlatformToolset>
51+
<WholeProgramOptimization>true</WholeProgramOptimization>
52+
<CharacterSet>Unicode</CharacterSet>
53+
</PropertyGroup>
54+
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
55+
<ImportGroup Label="ExtensionSettings">
56+
</ImportGroup>
57+
<ImportGroup Label="Shared">
58+
</ImportGroup>
59+
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
60+
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
61+
</ImportGroup>
62+
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
63+
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
64+
</ImportGroup>
65+
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
66+
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
67+
</ImportGroup>
68+
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
69+
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
70+
</ImportGroup>
71+
<PropertyGroup Label="UserMacros" />
72+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
73+
<LinkIncremental>true</LinkIncremental>
74+
</PropertyGroup>
75+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
76+
<LinkIncremental>true</LinkIncremental>
77+
</PropertyGroup>
78+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
79+
<LinkIncremental>false</LinkIncremental>
80+
</PropertyGroup>
81+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
82+
<LinkIncremental>false</LinkIncremental>
83+
</PropertyGroup>
84+
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
85+
<ClCompile>
86+
<PrecompiledHeader>
87+
</PrecompiledHeader>
88+
<WarningLevel>Level3</WarningLevel>
89+
<Optimization>Disabled</Optimization>
90+
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
91+
</ClCompile>
92+
<Link>
93+
<SubSystem>Console</SubSystem>
94+
<GenerateDebugInformation>true</GenerateDebugInformation>
95+
</Link>
96+
</ItemDefinitionGroup>
97+
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
98+
<ClCompile>
99+
<PrecompiledHeader>
100+
</PrecompiledHeader>
101+
<WarningLevel>Level3</WarningLevel>
102+
<Optimization>Disabled</Optimization>
103+
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
104+
</ClCompile>
105+
<Link>
106+
<SubSystem>Console</SubSystem>
107+
<GenerateDebugInformation>true</GenerateDebugInformation>
108+
</Link>
109+
</ItemDefinitionGroup>
110+
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
111+
<ClCompile>
112+
<WarningLevel>Level3</WarningLevel>
113+
<PrecompiledHeader>
114+
</PrecompiledHeader>
115+
<Optimization>MaxSpeed</Optimization>
116+
<FunctionLevelLinking>true</FunctionLevelLinking>
117+
<IntrinsicFunctions>true</IntrinsicFunctions>
118+
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
119+
</ClCompile>
120+
<Link>
121+
<SubSystem>Console</SubSystem>
122+
<EnableCOMDATFolding>true</EnableCOMDATFolding>
123+
<OptimizeReferences>true</OptimizeReferences>
124+
<GenerateDebugInformation>true</GenerateDebugInformation>
125+
</Link>
126+
</ItemDefinitionGroup>
127+
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
128+
<ClCompile>
129+
<WarningLevel>Level3</WarningLevel>
130+
<PrecompiledHeader>
131+
</PrecompiledHeader>
132+
<Optimization>MaxSpeed</Optimization>
133+
<FunctionLevelLinking>true</FunctionLevelLinking>
134+
<IntrinsicFunctions>true</IntrinsicFunctions>
135+
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
136+
</ClCompile>
137+
<Link>
138+
<SubSystem>Console</SubSystem>
139+
<EnableCOMDATFolding>true</EnableCOMDATFolding>
140+
<OptimizeReferences>true</OptimizeReferences>
141+
<GenerateDebugInformation>true</GenerateDebugInformation>
142+
</Link>
143+
</ItemDefinitionGroup>
144+
<ItemGroup>
145+
<ClCompile Include="main.c" />
146+
</ItemGroup>
147+
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
148+
<ImportGroup Label="ExtensionTargets">
149+
</ImportGroup>
150+
</Project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<ItemGroup>
4+
<Filter Include="Source Files">
5+
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
6+
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
7+
</Filter>
8+
<Filter Include="Header Files">
9+
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
10+
<Extensions>h;hh;hpp;hxx;hm;inl;inc;xsd</Extensions>
11+
</Filter>
12+
<Filter Include="Resource Files">
13+
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
14+
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
15+
</Filter>
16+
</ItemGroup>
17+
<ItemGroup>
18+
<ClCompile Include="main.c">
19+
<Filter>Source Files</Filter>
20+
</ClCompile>
21+
</ItemGroup>
22+
</Project>

UDMachineTester/main.c

+119
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
#include <stdio.h>
2+
#include <stdlib.h>
3+
4+
int main()
5+
{
6+
printf("ANDN: ");
7+
__try
8+
{
9+
_asm
10+
{
11+
andn eax, eax, eax;
12+
}
13+
printf("supported\n");
14+
}
15+
__except (1)
16+
{
17+
printf("not supported\n");
18+
}
19+
20+
printf("BEXTR: ");
21+
__try
22+
{
23+
_asm
24+
{
25+
bextr eax, eax, eax;
26+
}
27+
printf("supported\n");
28+
}
29+
__except (1)
30+
{
31+
printf("not supported\n");
32+
}
33+
34+
printf("BLSI: ");
35+
__try
36+
{
37+
_asm
38+
{
39+
blsi eax, eax;
40+
}
41+
printf("supported\n");
42+
}
43+
__except (1)
44+
{
45+
printf("not supported\n");
46+
}
47+
48+
printf("BLSMSK: ");
49+
__try
50+
{
51+
_asm
52+
{
53+
blsmsk eax, eax;
54+
}
55+
printf("supported\n");
56+
}
57+
__except (1)
58+
{
59+
printf("not supported\n");
60+
}
61+
62+
printf("BLSR: ");
63+
__try
64+
{
65+
_asm
66+
{
67+
blsr eax, eax;
68+
}
69+
printf("supported\n");
70+
}
71+
__except (1)
72+
{
73+
printf("not supported\n");
74+
}
75+
76+
printf("LZCNT: ");
77+
__try
78+
{
79+
_asm
80+
{
81+
lzcnt eax, eax;
82+
}
83+
printf("supported\n");
84+
}
85+
__except (1)
86+
{
87+
printf("not supported\n");
88+
}
89+
90+
printf("POPCNT: ");
91+
__try
92+
{
93+
_asm
94+
{
95+
popcnt eax, eax;
96+
}
97+
printf("supported\n");
98+
}
99+
__except (1)
100+
{
101+
printf("not supported\n");
102+
}
103+
104+
printf("TZCNT: ");
105+
__try
106+
{
107+
_asm
108+
{
109+
tzcnt eax, eax;
110+
}
111+
printf("supported\n");
112+
}
113+
__except (1)
114+
{
115+
printf("not supported\n");
116+
}
117+
118+
system("pause");
119+
}

UDTest/udtest.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ int main()
8787
mov eax, 0xCC88CC88
8888
mov edx, 0xFFFF // from 24 to 31
8989
mov ecx, 0xFFFFFFFF
90-
bextr ecx, eax, edx // ecx = 0x0
90+
bextr ecx, eax, edx // ecx = 0x0 (?!!!)
9191
}
9292
_asm {
9393
int 3h
@@ -125,7 +125,7 @@ int main()
125125
////////////////////////////////////////////////// BLSMSK
126126
_asm {
127127
mov eax, 0xF0F0F0A8
128-
blsmsk ecx, eax // ecx = 0xF0F0F0AF
128+
blsmsk ecx, eax // ecx = 0x0000000F
129129
}
130130
_asm {
131131
int 3h
@@ -137,7 +137,7 @@ int main()
137137
};
138138
_asm {
139139
mov eax, 0xF0E00000
140-
blsmsk ecx, eax // ecx = 0xF0FFFFFF
140+
blsmsk ecx, eax // ecx = 0x003FFFFF
141141
}
142142
_asm {
143143
int 3h

0 commit comments

Comments
 (0)