Debian Codegraph @

src/libmpg123/getcpuflags_x86_64.S

raw
1 /*
2 getcpuflags_x86_64: get cpuflags for x86-64
3
4 copyright 1995-2026 by the mpg123 project - free software under the terms of the LGPL 2.1
5 see COPYING and AUTHORS files in distribution or http://mpg123.org
6 initially written by Taihei Monma
7 */
8
9 #include "x86_64_defs.h"
10 #include "mangle.h"
11
12 .text
13 ALIGN4
14 .globl ASM_NAME(INT123_getcpuflags)
15 ASM_NAME(INT123_getcpuflags):
16 push %rbp
17 mov %rsp, %rbp
18 push %rbx
19
20 #ifdef IS_MSABI
21 push %rdi
22 mov %rcx, %rdi
23 #endif
24
25 movl $0, 12(%rdi)
26 movl $0, 16(%rdi)
27
28 mov $0x80000000, %eax
29 cpuid
30 cmp $0x80000001, %eax
31 jb 1f
32 mov $0x80000001, %eax
33 cpuid
34 movl %edx, 12(%rdi)
35 1:
36 mov $0x00000001, %eax
37 cpuid
38 movl %eax, (%rdi)
39 movl %ecx, 4(%rdi)
40 movl %edx, 8(%rdi)
41 test $0x04000000, %ecx
42 jz 2f
43 test $0x08000000, %ecx
44 jz 2f
45 xor %ecx, %ecx
46 .byte 0x0f, 0x01, 0xd0 /* xgetbv instruction */
47 movl %eax, 16(%rdi)
48 movl (%rdi), %eax
49 2:
50 #ifdef IS_MSABI
51 pop %rdi
52 #endif
53 pop %rbx
54 mov %rbp, %rsp
55 pop %rbp
56 ret
57
58 NONEXEC_STACK