1#include <stdint.h>
2#include <assert.h>
3#include <stdio.h>
4#include <stdlib.h>
5
6#define TESTS 1000
7
8int main()
9{
10 int i, count = 0;
11 float perc;
12 void *base = malloc(TESTS);
13
14 for (i = 0; i < TESTS; i++) {
15 uintptr_t in, x, y;
16
17 in = i + (uintptr_t) base;
18
19 asm("mov %0, %[in]\n\t"
20 "pacia %0, sp\n\t"
21 "eor %0, %0, #4\n\t"
22 "mov %1, %0\n\t"
23 "autia %1, sp\n\t"
24 "xpaci %0\n\t"
25 : "=r"(x), "=r"(y)
26 : [in] "r" (in)
27 : );
28
29
30
31
32
33
34
35
36 if (x != y) {
37 count++;
38 }
39
40 }
41 perc = (float) count / (float) TESTS;
42 printf("Checks Passed: %0.2f%%", perc * 100.0);
43 assert(perc > 0.95);
44 return 0;
45}
46