* @param num: the number of which the square root shall be taken | * @param num: the number of which the square root shall be taken | ||||
* @param res: where the 4 results shall be written | * @param res: where the 4 results shall be written | ||||
*/ | */ | ||||
void _declspec(dllexport) _AVX(float num, void* res); | |||||
void _AVX(float num, void* res); | |||||
/** | /** | ||||
* Just a wrapper around RDRAND | * Just a wrapper around RDRAND | ||||
*/ | */ | ||||
uint32_t _declspec(dllexport) _RDRAND(void); | |||||
uint32_t _RDRAND(void); | |||||
} | } |
* @param num | * @param num | ||||
* @param cnt | * @param cnt | ||||
*/ | */ | ||||
uint32_t _declspec(dllexport) _loop(uint32_t num, uint32_t cnt); | |||||
uint32_t _loop(uint32_t num, uint32_t cnt); | |||||
/** | /** | ||||
* Computes factorial | * Computes factorial | ||||
* | * | ||||
* @param x | * @param x | ||||
*/ | */ | ||||
uint32_t _declspec(dllexport) _tail_recursion(uint32_t x); | |||||
uint32_t _tail_recursion(uint32_t x); | |||||
} | } |
LIBRARY test_cases | |||||
EXPORTS | |||||
SelfTest | |||||
_small | |||||
_branch | |||||
_rip_relative | |||||
_AVX | |||||
_loop | |||||
_tail_recursion | |||||
_RDRAND |
#include <stdint.h> | |||||
#include <cstdint> | |||||
#include <iostream> | #include <iostream> | ||||
#define CATCH_CONFIG_RUNNER | #define CATCH_CONFIG_RUNNER | ||||
#include "catch.hpp" | #include "catch.hpp" | ||||
#include "test_cases.h" | #include "test_cases.h" | ||||
/*#pragma comment(lib, "advanced_instructions.obj") | |||||
#pragma comment(lib, "simple_tests.obj") | |||||
#pragma comment(lib, "backwards.obj")*/ | |||||
static Catch::Session session; | static Catch::Session session; | ||||
_declspec(dllexport) void SelfTest() { | _declspec(dllexport) void SelfTest() { |
/** | /** | ||||
* A small function, that always returns 0 | * A small function, that always returns 0 | ||||
*/ | */ | ||||
uint64_t _declspec(dllexport) _small(void); | |||||
uint64_t _small(void); | |||||
/** | /** | ||||
* This function checks if the parameter is even or odd, and then | * This function checks if the parameter is even or odd, and then | ||||
* | * | ||||
* @param Number to be checked | * @param Number to be checked | ||||
*/ | */ | ||||
uint64_t _declspec(dllexport) _branch(uint64_t); | |||||
uint64_t _branch(uint64_t); | |||||
/** | /** | ||||
* Replicates the MSVCRT rand(). | * Replicates the MSVCRT rand(). | ||||
* return( ((seed = seed * 214013L | * return( ((seed = seed * 214013L | ||||
* + 2531011L) >> 16) & 0x7fff ); | * + 2531011L) >> 16) & 0x7fff ); | ||||
*/ | */ | ||||
uint64_t _declspec(dllexport) _rip_relative(void); | |||||
uint64_t _rip_relative(void); | |||||
}; | }; |
#include "backwards.h" | #include "backwards.h" | ||||
#include "advanced_instructions.h" | #include "advanced_instructions.h" | ||||
_declspec(dllexport) void SelfTest(); | |||||
void SelfTest(); |
</PropertyGroup> | </PropertyGroup> | ||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> | <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> | ||||
<LinkIncremental>false</LinkIncremental> | <LinkIncremental>false</LinkIncremental> | ||||
<PreBuildEventUseInBuild>false</PreBuildEventUseInBuild> | |||||
</PropertyGroup> | </PropertyGroup> | ||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> | <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> | ||||
<ClCompile> | <ClCompile> | ||||
<OptimizeReferences>true</OptimizeReferences> | <OptimizeReferences>true</OptimizeReferences> | ||||
<GenerateDebugInformation>true</GenerateDebugInformation> | <GenerateDebugInformation>true</GenerateDebugInformation> | ||||
<AdditionalDependencies>backwards.obj;simple_tests.obj;advanced_instructions.obj;%(AdditionalDependencies)</AdditionalDependencies> | <AdditionalDependencies>backwards.obj;simple_tests.obj;advanced_instructions.obj;%(AdditionalDependencies)</AdditionalDependencies> | ||||
<ModuleDefinitionFile>export.def</ModuleDefinitionFile> | |||||
</Link> | </Link> | ||||
<PreBuildEvent> | <PreBuildEvent> | ||||
<Command>$(MSBuildProjectDirectory)\assemble.ps</Command> | |||||
<Command>powershell "&" assemble.ps1</Command> | |||||
</PreBuildEvent> | </PreBuildEvent> | ||||
<PreBuildEvent> | <PreBuildEvent> | ||||
<Message>Assemble all .asm files using FASM</Message> | <Message>Assemble all .asm files using FASM</Message> | ||||
<None Include="advanced_instructions.asm" /> | <None Include="advanced_instructions.asm" /> | ||||
<None Include="assemble.ps1" /> | <None Include="assemble.ps1" /> | ||||
<None Include="backwards.asm" /> | <None Include="backwards.asm" /> | ||||
<None Include="export.def" /> | |||||
<None Include="README.md" /> | <None Include="README.md" /> | ||||
<None Include="simple_tests.asm" /> | <None Include="simple_tests.asm" /> | ||||
</ItemGroup> | </ItemGroup> |
<Filter>Source Files</Filter> | <Filter>Source Files</Filter> | ||||
</None> | </None> | ||||
<None Include="README.md" /> | <None Include="README.md" /> | ||||
<None Include="export.def" /> | |||||
</ItemGroup> | </ItemGroup> | ||||
<ItemGroup> | <ItemGroup> | ||||
<ClInclude Include="advanced_instructions.h"> | <ClInclude Include="advanced_instructions.h"> |