1 | #include <cinttypes> |
2 | #include <cstdint> |
3 | #include <cstdio> |
4 | |
5 | union alignas(16) xmm_t { |
6 | uint64_t as_uint64[2]; |
7 | uint8_t as_uint8[16]; |
8 | }; |
9 | |
10 | int main() { |
11 | constexpr xmm_t xmm_fill = { |
12 | .as_uint64 = { 0, 0 } |
13 | }; |
14 | |
15 | uint64_t r64[8]; |
16 | xmm_t xmm[8]; |
17 | |
18 | asm volatile( |
19 | "movq %2, %%r8\n\t" |
20 | "movq %2, %%r9\n\t" |
21 | "movq %2, %%r10\n\t" |
22 | "movq %2, %%r11\n\t" |
23 | "movq %2, %%r12\n\t" |
24 | "movq %2, %%r13\n\t" |
25 | "movq %2, %%r14\n\t" |
26 | "movq %2, %%r15\n\t" |
27 | "\n\t" |
28 | "movaps %2, %%xmm8\n\t" |
29 | "movaps %2, %%xmm9\n\t" |
30 | "movaps %2, %%xmm10\n\t" |
31 | "movaps %2, %%xmm11\n\t" |
32 | "movaps %2, %%xmm12\n\t" |
33 | "movaps %2, %%xmm13\n\t" |
34 | "movaps %2, %%xmm14\n\t" |
35 | "movaps %2, %%xmm15\n\t" |
36 | "\n\t" |
37 | "int3\n\t" |
38 | "\n\t" |
39 | "movq %%r8, 0x00(%0)\n\t" |
40 | "movq %%r9, 0x08(%0)\n\t" |
41 | "movq %%r10, 0x10(%0)\n\t" |
42 | "movq %%r11, 0x18(%0)\n\t" |
43 | "movq %%r12, 0x20(%0)\n\t" |
44 | "movq %%r13, 0x28(%0)\n\t" |
45 | "movq %%r14, 0x30(%0)\n\t" |
46 | "movq %%r15, 0x38(%0)\n\t" |
47 | "\n\t" |
48 | "movaps %%xmm8, 0x00(%1)\n\t" |
49 | "movaps %%xmm9, 0x10(%1)\n\t" |
50 | "movaps %%xmm10, 0x20(%1)\n\t" |
51 | "movaps %%xmm11, 0x30(%1)\n\t" |
52 | "movaps %%xmm12, 0x40(%1)\n\t" |
53 | "movaps %%xmm13, 0x50(%1)\n\t" |
54 | "movaps %%xmm14, 0x60(%1)\n\t" |
55 | "movaps %%xmm15, 0x70(%1)\n\t" |
56 | : |
57 | : "a" (r64), "b" (xmm), "m" (xmm_fill) |
58 | : "%r8" , "%r9" , "%r10" , "%r11" , "%r12" , "%r13" , "%r14" , "%r15" , "%xmm8" , |
59 | "%xmm9" , "%xmm10" , "%xmm11" , "%xmm12" , "%xmm13" , "%xmm14" , "%xmm15" |
60 | ); |
61 | |
62 | for (int i = 0; i < 8; ++i) |
63 | printf(format: "r%d = 0x%016" PRIx64 "\n" , i+8, r64[i]); |
64 | for (int i = 0; i < 8; ++i) { |
65 | printf(format: "xmm%d = { " , i+8); |
66 | for (int j = 0; j < sizeof(xmm->as_uint8); ++j) |
67 | printf(format: "0x%02x " , xmm[i].as_uint8[j]); |
68 | printf(format: "}\n" ); |
69 | } |
70 | |
71 | return 0; |
72 | } |
73 | |