[PATCH 3/6] Add IMUL tests

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



IMUL REG, R/M
IMUL REG, R/M, IMM8
IMUL REG, R/M, IMM

Signed-off-by: Avi Kivity <avi@xxxxxxxxxx>
---
 x86/emulator.c |   42 ++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 42 insertions(+), 0 deletions(-)

diff --git a/x86/emulator.c b/x86/emulator.c
index d30ca8e..b0d15c0 100644
--- a/x86/emulator.c
+++ b/x86/emulator.c
@@ -535,6 +535,47 @@ void test_bsfbsr(void *mem)
 	report("bsrq r/m, reg", rax == 1);
 }
 
+static void test_imul(ulong *mem)
+{
+    ulong a;
+
+    *mem = 51; a = 0x1234567812345678UL;
+    asm ("imulw %1, %%ax" : "+a"(a) : "m"(*mem));
+    report("imul ax, mem", a == 0x12345678123439e8);
+
+    *mem = 51; a = 0x1234567812345678UL;
+    asm ("imull %1, %%eax" : "+a"(a) : "m"(*mem));
+    report("imul eax, mem", a == 0xa06d39e8);
+
+    *mem = 51; a = 0x1234567812345678UL;
+    asm ("imulq %1, %%rax" : "+a"(a) : "m"(*mem));
+    report("imul rax, mem", a == 0xA06D39EBA06D39E8UL);
+
+    *mem  = 0x1234567812345678UL; a = 0x8765432187654321L;
+    asm ("imulw $51, %1, %%ax" : "+a"(a) : "m"(*mem));
+    report("imul ax, mem, imm8", a == 0x87654321876539e8);
+
+    *mem = 0x1234567812345678UL;
+    asm ("imull $51, %1, %%eax" : "+a"(a) : "m"(*mem));
+    report("imul eax, mem, imm8", a == 0xa06d39e8);
+
+    *mem = 0x1234567812345678UL;
+    asm ("imulq $51, %1, %%rax" : "+a"(a) : "m"(*mem));
+    report("imul rax, mem, imm8", a == 0xA06D39EBA06D39E8UL);
+
+    *mem  = 0x1234567812345678UL; a = 0x8765432187654321L;
+    asm ("imulw $311, %1, %%ax" : "+a"(a) : "m"(*mem));
+    report("imul ax, mem, imm", a == 0x8765432187650bc8);
+
+    *mem = 0x1234567812345678UL;
+    asm ("imull $311, %1, %%eax" : "+a"(a) : "m"(*mem));
+    report("imul eax, mem, imm", a == 0x1d950bc8);
+
+    *mem = 0x1234567812345678UL;
+    asm ("imulq $311, %1, %%rax" : "+a"(a) : "m"(*mem));
+    report("imul rax, mem, imm", a == 0x1D950BDE1D950BC8L);
+}
+
 int main()
 {
 	void *mem;
@@ -570,6 +611,7 @@ int main()
 	test_incdecnotneg(mem);
 	test_btc(mem);
 	test_bsfbsr(mem);
+	test_imul(mem);
 
 	printf("\nSUMMARY: %d tests, %d failures\n", tests, fails);
 	return fails ? 1 : 0;
-- 
1.7.1

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux