[DYNAREC] Fixed FIST(T)(P) on 16bit value

This commit is contained in:
ptitSeb 2019-11-04 09:43:47 +01:00
parent 48c3f927eb
commit 2fef0f9652
6 changed files with 21 additions and 6 deletions

View File

@ -290,6 +290,11 @@ add_test(test11 ${CMAKE_COMMAND} -D TEST_PROGRAM=${CMAKE_BINARY_DIR}/${BOX86}
-D TEST_REFERENCE=${CMAKE_SOURCE_DIR}/tests/ref11.txt
-P ${CMAKE_SOURCE_DIR}/runTest.cmake )
add_test(test12 ${CMAKE_COMMAND} -D TEST_PROGRAM=${CMAKE_BINARY_DIR}/${BOX86}
-D TEST_ARGS=${CMAKE_SOURCE_DIR}/tests/test12 -D TEST_OUTPUT=tmpfile.txt
-D TEST_REFERENCE=${CMAKE_SOURCE_DIR}/tests/ref12.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)

View File

@ -148,7 +148,7 @@ uintptr_t dynarecDF(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
case 1:
INST_NAME("FISTTP Ew, ST0");
v1 = x87_get_st(dyn, ninst, x1, x2, 0);
u8 = x87_setround(dyn, ninst, x1, x2, x3);
u8 = x87_setround(dyn, ninst, x1, x2, x12);
addr = geted(dyn, addr, ninst, nextop, &wback, x2, &fixedaddress);
ed = x1;
s0 = fpu_get_scratch_single(dyn);
@ -168,7 +168,7 @@ uintptr_t dynarecDF(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
case 2:
INST_NAME("FIST Ew, ST0");
v1 = x87_get_st(dyn, ninst, x1, x2, 0);
u8 = x87_setround(dyn, ninst, x1, x2, x3);
u8 = x87_setround(dyn, ninst, x1, x2, x12);
addr = geted(dyn, addr, ninst, nextop, &wback, x2, &fixedaddress);
ed = x1;
s0 = fpu_get_scratch_single(dyn);
@ -187,7 +187,7 @@ uintptr_t dynarecDF(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
case 3:
INST_NAME("FISTP Ew, ST0");
v1 = x87_get_st(dyn, ninst, x1, x2, 0);
u8 = x87_setround(dyn, ninst, x1, x2, x3);
u8 = x87_setround(dyn, ninst, x1, x2, x12);
addr = geted(dyn, addr, ninst, nextop, &wback, x2, &fixedaddress);
ed = x1;
s0 = fpu_get_scratch_single(dyn);

View File

@ -1,3 +1,4 @@
1000000000000 => 1000000000000.000000
-1000000000000 => -1000000000000.000000
(angle_t)268435456.000000 = 268435456 == 0x10000000
go PI trucated=3, -PI rounded=-3

BIN
tests/test12 Executable file

Binary file not shown.

View File

@ -18,9 +18,18 @@ int main(int argc, char **argv)
d = d*(1<<30)/M_PI;
angle_t u32 = (angle_t)d;
printf("(angle_t)%f = %u == 0x%08X\n", d, u32, u32);
/*d = -d;
u32 = angle_t(d);
printf("(angle_t)%f = %u == 0x%08X\n", d, u32, u32);*/
int16_t a=0, b=0;
asm volatile (
"fldpi \n"
"fisttp %0 \n"
: "=m" (a));
asm volatile (
"fldpi \n"
"fchs \n"
"fistp %0 \n"
: "=m" (b));
printf("go PI trucated=%d, -PI rounded=%d\n", a, b);
return 0;
}

Binary file not shown.