about summary refs log tree commit diff stats
path: root/tests/test24.c
blob: cd07e139f886c3f0e0c58e9616ccfbe9d882008e (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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#include <stdio.h>
#include <string.h>
#include <stddef.h>
#include <stdint.h>
// Build with `gcc -march=core2 -O2 test24.c -o test24`


uint64_t a = 0x12345678abcdefed;
uint32_t b = 0x12345678;
uint16_t c = 0x1234;

int main()
{
    uint64_t ret1;
    uint32_t ret2;
    uint16_t ret3;

    asm volatile(
        "movbe %1, %0\n"
        : "=r"(ret1)
        : "m"(a)
        : "memory");
    printf("ret = 0x%lx\n", ret1);

    asm volatile(
        "movbe %1, %0\n"
        : "=r"(ret2)
        : "m"(b)
        : "memory");
    printf("ret = 0x%x\n", ret2);

    asm volatile(
        "movbe %1, %0\n"
        : "=r"(ret3)
        : "m"(c)
        : "memory");
    printf("ret = 0x%x\n", ret3);

    asm volatile(
        "movbe %1, %0\n"
        : "=m"(ret1)
        : "r"(a)
        : "memory");
    printf("ret = 0x%lx\n", ret1);

    asm volatile(
        "movbe %1, %0\n"
        : "=m"(ret2)
        : "r"(b)
        : "memory");
    printf("ret = 0x%x\n", ret2);

    asm volatile(
        "movbe %1, %0\n"
        : "=m"(ret3)
        : "r"(c)
        : "memory");
    printf("ret = 0x%x\n", ret3);

    asm volatile(
        "bswap %0\n"
        : "+r"(ret1)
        :
        :);
    printf("ret = 0x%lx\n", ret1);

    asm volatile(
        "bswap %0\n"
        : "+r"(ret2)
        :
        :);
    printf("ret = 0x%x\n", ret2);
    return 0;
}