File: test_asm_mixed.cpp

package info (click to toggle)
libcrypto%2B%2B 8.9.0-2
  • links: PTS
  • area: main
  • in suites: forky, sid, trixie
  • size: 23,960 kB
  • sloc: cpp: 110,116; asm: 10,493; sh: 8,937; makefile: 55
file content (31 lines) | stat: -rw-r--r-- 965 bytes parent folder | download | duplicates (6)
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
// Most Clang cannot handle mixed asm with positional arguments, where the
// body is Intel style with no prefix and the templates are AT&T style.
// Also see https://bugs.llvm.org/show_bug.cgi?id=39895 .
#include <cstddef>
int main(int argc, char* argv[])
{
    size_t ret = 1, N = 1;
    asm __volatile__
    (
#if defined(__amd64__) || defined(__x86_64__)
        ".intel_syntax   noprefix ;\n"
        "xor rsi, rsi    ;\n"
        "neg %1          ;\n"
        "inc %1          ;\n"
        "push %1         ;\n"
        "pop rax         ;\n"
        ".att_syntax     prefix ;\n"
        : "=a" (ret) : "c" (N) : "%rsi"
#else
        ".intel_syntax   noprefix ;\n"
        "xor esi, esi    ;\n"
        "neg %1          ;\n"
        "inc %1          ;\n"
        "push %1         ;\n"
        "pop eax         ;\n"
        ".att_syntax     prefix ;\n"
        : "=a" (ret) : "c" (N) : "%esi"
#endif
    );
    return (int)ret;
}