Implement instruction cvttps2pi

This commit is contained in:
David Bullado 2018-09-20 16:54:12 +02:00 committed by Fabian
parent 1e9c93252f
commit 43f9cd429f
2 changed files with 64 additions and 1 deletions

View file

@ -2122,7 +2122,39 @@ t[0x2B] = cpu => {
cpu.safe_write128(addr, data[0], data[1], data[2], data[3]);
}
};
t[0x2C] = cpu => { cpu.unimplemented_sse(); };
t[0x2C] = cpu => {
// cvttps2pi mm, xmm/m64
dbg_assert((cpu.prefixes & (PREFIX_MASK_REP | PREFIX_MASK_OPSIZE)) === 0);
cpu.task_switch_test_mmx();
cpu.read_modrm_byte();
let data = cpu.read_xmm_mem64s();
let float32 = new Float32Array(data.buffer);
let low = 0;
let high = 0;
var res0 = Math.trunc(float32[0]);
if(res0 <= 0x7FFFFFFF && res0 >= -0x80000000)
{
low = res0;
}
else
{
low = 0x80000000|0;
}
var res1 = Math.trunc(float32[1]);
if(res1 <= 0x7FFFFFFF && res1 >= -0x80000000)
{
high = res1;
}
else
{
high = 0x80000000|0;
}
cpu.write_mmx64s(low, high);
};
t[0x2D] = cpu => { cpu.unimplemented_sse(); };
t[0x2E] = cpu => { cpu.unimplemented_sse(); };
t[0x2F] = cpu => { cpu.unimplemented_sse(); };

31
tests/nasm/cvttps2pi.asm Normal file
View file

@ -0,0 +1,31 @@
global _start
section .data
align 16
float0low:
dd 2147483647.0
float0high:
dd -2147483648.0
float1low:
dd 1235.678
float1high:
dd 1325400064
float2low:
dd -54.321
float2high:
dd -12345.6
float3low:
dd 123.456
float3high:
dd 1234.5678
myaddress:
dd 0xdeadbeef
%include "header.inc"
movaps xmm0, [float0low]
cvttps2pi mm0, xmm0
cvttps2pi mm1, [float1low]
cvttps2pi mm2, [float2low]
cvttps2pi mm3, [float3low]
%include "footer.inc"