mirror of
https://github.com/ptitSeb/box86.git
synced 2025-01-21 06:04:56 +00:00
Added ucomiss test
This commit is contained in:
parent
25f43108fe
commit
3c0b7830de
@ -665,6 +665,11 @@ add_test(NAME linkingIndirectVersion COMMAND ${CMAKE_COMMAND} -D TEST_PROGRAM=${
|
||||
-D TEST_REFERENCE=${CMAKE_SOURCE_DIR}/tests/ref16.txt
|
||||
-P ${CMAKE_SOURCE_DIR}/runTest.cmake )
|
||||
|
||||
add_test(NAME ucomiss COMMAND ${CMAKE_COMMAND} -D TEST_PROGRAM=${CMAKE_BINARY_DIR}/${BOX86}
|
||||
-D TEST_ARGS=${CMAKE_SOURCE_DIR}/tests/test17 -D TEST_OUTPUT=tmpfile.txt
|
||||
-D TEST_REFERENCE=${CMAKE_SOURCE_DIR}/tests/ref17.txt
|
||||
-P ${CMAKE_SOURCE_DIR}/runTest.cmake )
|
||||
|
||||
file(GLOB extension_tests "${CMAKE_SOURCE_DIR}/tests/extensions/*.c")
|
||||
foreach(file ${extension_tests})
|
||||
get_filename_component(testname "${file}" NAME_WE)
|
||||
|
11
tests/ref17.txt
Normal file
11
tests/ref17.txt
Normal file
@ -0,0 +1,11 @@
|
||||
ucomiss 1.000000, 2.000000 => 0x202
|
||||
ucomiss 2.000000, 1.000000 => 0x203
|
||||
ucomiss 1.000000, inf => 0x202
|
||||
ucomiss inf, 1.000000 => 0x203
|
||||
ucomiss 1.000000, -inf => 0x203
|
||||
ucomiss -inf, 1.000000 => 0x202
|
||||
ucomiss 1.000000, nan => 0x247
|
||||
ucomiss nan, 1.000000 => 0x247
|
||||
ucomiss 1.000000, 1.000000 => 0x242
|
||||
ucomiss inf, inf => 0x242
|
||||
ucomiss nan, nan => 0x247
|
BIN
tests/test17
Executable file
BIN
tests/test17
Executable file
Binary file not shown.
69
tests/test17.c
Normal file
69
tests/test17.c
Normal file
@ -0,0 +1,69 @@
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <stddef.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
#include <math.h>
|
||||
|
||||
#if defined(__x86_64__)
|
||||
uint64_t _ucomiss_(float a, float b)
|
||||
{
|
||||
uint64_t ret;
|
||||
asm volatile (
|
||||
"ucomiss %%xmm0, %%xmm1\n"
|
||||
"pushf\n"
|
||||
"pop %%rax"
|
||||
:"=a" (ret)::"xmm0","xmm1","cc");
|
||||
return ret;
|
||||
}
|
||||
#else
|
||||
uint64_t _ucomiss_(float a, float b)
|
||||
{
|
||||
uint32_t ret;
|
||||
asm volatile (
|
||||
"movss %1, %%xmm0\n"
|
||||
"movss %2, %%xmm1\n"
|
||||
"ucomiss %%xmm0, %%xmm1\n"
|
||||
"pushf\n"
|
||||
"pop %%eax"
|
||||
:"=a" (ret):"m"(a), "m"(b):"xmm0", "xmm1", "cc");
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
int main(int argc, const char** argv)
|
||||
{
|
||||
float a, b;
|
||||
uint64_t flags;
|
||||
a = 1.0f; b = 2.0f;
|
||||
flags = _ucomiss_(a, b);
|
||||
printf("ucomiss %f, %f => 0x%lx\n", a, b, flags);
|
||||
flags = _ucomiss_(b, a);
|
||||
printf("ucomiss %f, %f => 0x%lx\n", b, a, flags);
|
||||
b = INFINITY;
|
||||
flags = _ucomiss_(a, b);
|
||||
printf("ucomiss %f, %f => 0x%lx\n", a, b, flags);
|
||||
flags = _ucomiss_(b, a);
|
||||
printf("ucomiss %f, %f => 0x%lx\n", b, a, flags);
|
||||
b = -INFINITY;
|
||||
flags = _ucomiss_(a, b);
|
||||
printf("ucomiss %f, %f => 0x%lx\n", a, b, flags);
|
||||
flags = _ucomiss_(b, a);
|
||||
printf("ucomiss %f, %f => 0x%lx\n", b, a, flags);
|
||||
b = NAN;
|
||||
flags = _ucomiss_(a, b);
|
||||
printf("ucomiss %f, %f => 0x%lx\n", a, b, flags);
|
||||
flags = _ucomiss_(b, a);
|
||||
printf("ucomiss %f, %f => 0x%lx\n", b, a, flags);
|
||||
b = a;
|
||||
flags = _ucomiss_(a, b);
|
||||
printf("ucomiss %f, %f => 0x%lx\n", a, b, flags);
|
||||
a = b = INFINITY;
|
||||
flags = _ucomiss_(a, b);
|
||||
printf("ucomiss %f, %f => 0x%lx\n", a, b, flags);
|
||||
a = b = NAN;
|
||||
flags = _ucomiss_(a, b);
|
||||
printf("ucomiss %f, %f => 0x%lx\n", a, b, flags);
|
||||
|
||||
return 0;
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user