|
From: <sv...@va...> - 2011-08-12 15:48:20
|
Author: tom
Date: 2011-08-12 16:43:31 +0100 (Fri, 12 Aug 2011)
New Revision: 11969
Log:
Add test for address size override prefixes for REP prefixed string
instructions on amd64. Fixes remaining issues from #211371.
Added:
trunk/none/tests/amd64/asorep.c
trunk/none/tests/amd64/asorep.stderr.exp
trunk/none/tests/amd64/asorep.stdout.exp
trunk/none/tests/amd64/asorep.vgtest
Modified:
trunk/none/tests/amd64/Makefile.am
Modified: trunk/none/tests/amd64/Makefile.am
===================================================================
--- trunk/none/tests/amd64/Makefile.am 2011-08-12 15:21:31 UTC (rev 11968)
+++ trunk/none/tests/amd64/Makefile.am 2011-08-12 15:43:31 UTC (rev 11969)
@@ -22,6 +22,7 @@
EXTRA_DIST = \
amd64locked.vgtest amd64locked.stdout.exp amd64locked.stderr.exp \
+ asorep.stderr.exp asorep.stdout.exp asorep.vgtest \
bug127521-64.vgtest bug127521-64.stdout.exp bug127521-64.stderr.exp \
bug132813-amd64.vgtest bug132813-amd64.stdout.exp \
bug132813-amd64.stderr.exp \
@@ -66,6 +67,7 @@
check_PROGRAMS = \
amd64locked \
+ asorep \
bug127521-64 bug132813-amd64 bug132918 \
clc \
cmpxchg \
Added: trunk/none/tests/amd64/asorep.c
===================================================================
--- trunk/none/tests/amd64/asorep.c (rev 0)
+++ trunk/none/tests/amd64/asorep.c 2011-08-12 15:43:31 UTC (rev 11969)
@@ -0,0 +1,77 @@
+#include <stdint.h>
+#include <string.h>
+#include <stdio.h>
+
+char buf1[64], buf2[64];
+
+int
+main (void)
+{
+ unsigned long rdi, rsi, rcx, rax;
+ uintptr_t b1 = (uintptr_t) buf1, b2 = (uintptr_t) buf2;
+
+ if (b1 > 0xffffffffULL || b2 > 0xffffffffULL)
+ return 0;
+
+ b1 += 0x100000000ULL;
+ b2 += 0xfff00000000ULL;
+ memcpy (buf1, "abcde", 4);
+ asm volatile ("addr32 rep movsb"
+ : "=D" (rdi), "=S" (rsi), "=c" (rcx)
+ : "D" (b2), "S" (b1), "c" (0x100000004ULL)
+ : "memory");
+ if (memcmp (buf2, "abcd", 5) != 0
+ || rdi != (uintptr_t) buf2 + 4
+ || rsi != (uintptr_t) buf1 + 4
+ || rcx)
+ fprintf (stderr, "addr32 rep movsb wrong\n");
+
+ rax = 0x751234560000ULL + (' ' << 8) + '0';
+ asm volatile ("addr32 rep stosw"
+ : "=D" (rdi), "=c" (rcx), "+a" (rax)
+ : "D" (b2), "c" (0x100000003ULL)
+ : "memory");
+ if (memcmp (buf2, "0 0 0 ", 7) != 0
+ || rdi != (uintptr_t) buf2 + 6
+ || rcx
+ || rax != 0x751234560000ULL + (' ' << 8) + '0')
+ fprintf (stderr, "addr32 rep stosw wrong\n");
+
+ asm volatile ("addr32 lodsl"
+ : "=S" (rsi), "=a" (rax)
+ : "S" (b2), "a" (2ULL));
+ if (rsi != (uintptr_t) buf2 + 4
+ || rax != 0x20302030ULL)
+ fprintf (stderr, "addr32 lodsl wrong\n");
+
+ memcpy (buf1, "abcdefghijklmno", 16);
+ memcpy (buf2, "abcdefghijklmnO", 16);
+ asm volatile ("addr32 repe cmpsb"
+ : "=D" (rdi), "=S" (rsi), "=c" (rcx)
+ : "D" (b2), "S" (b1), "c" (0x100000020ULL));
+ if (rdi != (uintptr_t) buf2 + 15
+ || rsi != (uintptr_t) buf1 + 15
+ || rcx != 17ULL)
+ fprintf (stderr, "addr32 repe cmpsb wrong\n");
+
+ memcpy (buf2, "ababababababababcdab", 20);
+ rax = 0x123450000ULL + ('d' << 8) + 'c';
+ asm volatile ("addr32 repne scasw"
+ : "=D" (rdi), "=c" (rcx), "+a" (rax)
+ : "D" (b2), "c" (0x100000020ULL));
+ if (rdi != (uintptr_t) buf2 + 18
+ || rcx != 23ULL
+ || rax != 0x123450000ULL + ('d' << 8) + 'c')
+ fprintf (stderr, "addr32 repne scasw wrong\n");
+
+ rax = 0x543210000ULL + ('b' << 8) + 'a';
+ asm volatile ("addr32 repe scasw"
+ : "=D" (rdi), "=c" (rcx), "+a" (rax)
+ : "D" (b2), "c" (0x100000020ULL));
+ if (rdi != (uintptr_t) buf2 + 18
+ || rcx != 23ULL
+ || rax != 0x543210000ULL + ('b' << 8) + 'a')
+ fprintf (stderr, "addr32 repe scasw wrong\n");
+
+ return 0;
+}
Property changes on: trunk/none/tests/amd64/asorep.c
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
Added: trunk/none/tests/amd64/asorep.stderr.exp
===================================================================
--- trunk/none/tests/amd64/asorep.stderr.exp (rev 0)
+++ trunk/none/tests/amd64/asorep.stderr.exp 2011-08-12 15:43:31 UTC (rev 11969)
@@ -0,0 +1,2 @@
+
+
Added: trunk/none/tests/amd64/asorep.stdout.exp
===================================================================
Added: trunk/none/tests/amd64/asorep.vgtest
===================================================================
--- trunk/none/tests/amd64/asorep.vgtest (rev 0)
+++ trunk/none/tests/amd64/asorep.vgtest 2011-08-12 15:43:31 UTC (rev 11969)
@@ -0,0 +1 @@
+prog: asorep
|