Skip to content

Latest commit

 

History

History
57 lines (50 loc) · 943 Bytes

getcpuflags_x86_64.S

File metadata and controls

57 lines (50 loc) · 943 Bytes
 
Nov 10, 2019
Nov 10, 2019
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
/*
getcpuflags_x86_64: get cpuflags for x86-64
copyright 1995-2013 by the mpg123 project - free software under the terms of the LGPL 2.1
see COPYING and AUTHORS files in distribution or http://mpg123.org
initially written by Taihei Monma
*/
#include "mangle.h"
.text
ALIGN4
.globl ASM_NAME(getcpuflags)
ASM_NAME(getcpuflags):
push %rbp
mov %rsp, %rbp
push %rbx
#ifdef IS_MSABI
push %rdi
mov %rcx, %rdi
#endif
movl $0, 12(%rdi)
movl $0, 16(%rdi)
mov $0x80000000, %eax
cpuid
cmp $0x80000001, %eax
jb 1f
mov $0x80000001, %eax
cpuid
movl %edx, 12(%rdi)
1:
mov $0x00000001, %eax
cpuid
movl %eax, (%rdi)
movl %ecx, 4(%rdi)
movl %edx, 8(%rdi)
test $0x04000000, %ecx
jz 2f
test $0x08000000, %ecx
jz 2f
xor %ecx, %ecx
.byte 0x0f, 0x01, 0xd0 /* xgetbv instruction */
movl %eax, 16(%rdi)
movl (%rdi), %eax
2:
#ifdef IS_MSABI
pop %rdi
#endif
pop %rbx
mov %rbp, %rsp
pop %rbp
ret
NONEXEC_STACK