about summary refs log tree commit diff stats
path: root/tests/test25.c
blob: 6f0be714a26f0adf3c78db6dcda6c22557f8a63b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#include <stdio.h>
// Build with `gcc -march=core2 -O2 test25.c -o test25`

asm(
"foo:             \n\t"
  "flds 0(%rdi)   \n\t"
  "flds 4(%rdi)   \n\t"
  "flds 8(%rdi)   \n\t"
  "flds 12(%rdi)  \n\t"
  "flds 16(%rdi)  \n\t"
  "flds 20(%rdi)  \n\t"
  "flds 24(%rdi)  \n\t"
  "flds 28(%rdi)  \n\t"
  "cmp $0, %rdi   \n\t"
  "je     1f      \n\t"
  "jne    1f      \n\t"
  "flds 32(%rdi)  \n\t"
  "flds 36(%rdi)  \n\t"
"1:               \n\t"
  "fstps 0(%rsi)  \n\t"
  "fstps 4(%rsi)  \n\t"
  "fstps 8(%rsi)  \n\t"
  "fstps 12(%rsi) \n\t"
  "fstps 16(%rsi) \n\t"
  "fstps 20(%rsi) \n\t"
  "fstps 24(%rsi) \n\t"
  "fstps 28(%rsi) \n\t"
  "je     1f      \n\t"
  "jne    1f      \n\t"
  "fstps 32(%rdi) \n\t"
  "fstps 36(%rdi) \n\t"
"1:               \n\t"
  "ret            \n\t"
);

extern void foo(float* src, float* dst);

int main(void)
{
    float src[10] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
    float dst[10] = { 0 };
    foo(src, dst);
    for (int i = 0; i < 10; ++i) {
        printf("%f\n", dst[i]);
    }
    return 0;
}