5 char buf1
[64], buf2
[64];
10 unsigned long rdi
, rsi
, rcx
, rax
;
11 uintptr_t b1
= (uintptr_t) buf1
, b2
= (uintptr_t) buf2
;
13 if (b1
> 0xffffffffULL
|| b2
> 0xffffffffULL
)
17 b2
+= 0xfff00000000ULL
;
18 memcpy (buf1
, "abcde", 4);
19 asm volatile ("addr32 rep movsb"
20 : "=D" (rdi
), "=S" (rsi
), "=c" (rcx
)
21 : "D" (b2
), "S" (b1
), "c" (0x100000004ULL
)
23 if (memcmp (buf2
, "abcd", 5) != 0
24 || rdi
!= (uintptr_t) buf2
+ 4
25 || rsi
!= (uintptr_t) buf1
+ 4
27 fprintf (stderr
, "addr32 rep movsb wrong\n");
29 rax
= 0x751234560000ULL
+ (' ' << 8) + '0';
30 asm volatile ("addr32 rep stosw"
31 : "=D" (rdi
), "=c" (rcx
), "+a" (rax
)
32 : "D" (b2
), "c" (0x100000003ULL
)
34 if (memcmp (buf2
, "0 0 0 ", 7) != 0
35 || rdi
!= (uintptr_t) buf2
+ 6
37 || rax
!= 0x751234560000ULL
+ (' ' << 8) + '0')
38 fprintf (stderr
, "addr32 rep stosw wrong\n");
40 asm volatile ("addr32 lodsl"
41 : "=S" (rsi
), "=a" (rax
)
42 : "S" (b2
), "a" (2ULL));
43 if (rsi
!= (uintptr_t) buf2
+ 4
44 || rax
!= 0x20302030ULL
)
45 fprintf (stderr
, "addr32 lodsl wrong\n");
47 memcpy (buf1
, "abcdefghijklmno", 16);
48 memcpy (buf2
, "abcdefghijklmnO", 16);
49 asm volatile ("addr32 repe cmpsb"
50 : "=D" (rdi
), "=S" (rsi
), "=c" (rcx
)
51 : "D" (b2
), "S" (b1
), "c" (0x100000020ULL
));
52 if (rdi
!= (uintptr_t) buf2
+ 15
53 || rsi
!= (uintptr_t) buf1
+ 15
55 fprintf (stderr
, "addr32 repe cmpsb wrong\n");
57 memcpy (buf2
, "ababababababababcdab", 20);
58 rax
= 0x123450000ULL
+ ('d' << 8) + 'c';
59 asm volatile ("addr32 repne scasw"
60 : "=D" (rdi
), "=c" (rcx
), "+a" (rax
)
61 : "D" (b2
), "c" (0x100000020ULL
));
62 if (rdi
!= (uintptr_t) buf2
+ 18
64 || rax
!= 0x123450000ULL
+ ('d' << 8) + 'c')
65 fprintf (stderr
, "addr32 repne scasw wrong\n");
67 rax
= 0x543210000ULL
+ ('b' << 8) + 'a';
68 asm volatile ("addr32 repe scasw"
69 : "=D" (rdi
), "=c" (rcx
), "+a" (rax
)
70 : "D" (b2
), "c" (0x100000020ULL
));
71 if (rdi
!= (uintptr_t) buf2
+ 18
73 || rax
!= 0x543210000ULL
+ ('b' << 8) + 'a')
74 fprintf (stderr
, "addr32 repe scasw wrong\n");