-
Notifications
You must be signed in to change notification settings - Fork 157
/
Copy pathsnd_mix_x86_64.s
126 lines (121 loc) · 1.78 KB
/
snd_mix_x86_64.s
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
#if defined(__APPLE__)
#undef ELF
#endif
#ifdef __ELF__
.section .note.GNU-stack,"",@progbits
#endif
#ifdef ELF
#define C(label) label
#else
#define C(label) _##label
#endif
.intel_syntax noprefix
.text
.globl C(S_WriteLinearBlastStereo16_SSE_x64)
C(S_WriteLinearBlastStereo16_SSE_x64):
push rbx
#ifdef _WIN32
// RCX RDX R8 R9
push rsi
push rdi
mov rsi, rcx
mov rdi, rdx
mov ebx, r8d
#else
// RDI RSI RDX RCX R8 R9
xchg rsi, rdi
mov ebx, edx
#endif
test ebx,ebx
jz LExit
mov ecx,esi
and ecx,63
jz LMain
and ecx,3
jnz LTail
shr ecx,2
not ecx
add ecx,17
LClamp1:
mov eax,[rsi]
sar eax,8
cmp eax,32767
jg LClampHigh1
cmp eax,-32768
jnl LClampDone1
mov eax,-32768
jmp LClampDone1
LClampHigh1:
mov eax,32767
LClampDone1:
mov [rdi],ax
add rsi,4
add rdi,2
dec ebx
jz LExit
dec ecx
jnz LClamp1
LMain:
mov ecx,ebx
shr ecx,4
jz LTail
and ebx,15
LAgain:
movq mm0, qword ptr [rsi+ 0]
movq mm1, qword ptr [rsi+ 8]
movq mm2, qword ptr [rsi+16]
movq mm3, qword ptr [rsi+24]
movq mm4, qword ptr [rsi+32]
movq mm5, qword ptr [rsi+40]
movq mm6, qword ptr [rsi+48]
movq mm7, qword ptr [rsi+56]
psrad mm0,8
psrad mm1,8
psrad mm2,8
psrad mm3,8
psrad mm4,8
psrad mm5,8
psrad mm6,8
psrad mm7,8
packssdw mm0, mm1
packssdw mm2, mm3
packssdw mm4, mm5
packssdw mm6, mm7
movntq qword ptr [rdi+ 0], mm0
movntq qword ptr [rdi+ 8], mm2
movntq qword ptr [rdi+16], mm4
movntq qword ptr [rdi+24], mm6
add rsi, 64
add rdi, 32
dec ecx
jnz LAgain
LTail:
test ebx, ebx
jz LEnd
LClamp2:
mov eax,[rsi]
sar eax,8
cmp eax,32767
jg LClampHigh2
cmp eax,-32768
jnl LClampDone2
mov eax,-32768
jmp LClampDone2
LClampHigh2:
mov eax,32767
LClampDone2:
mov [rdi],ax
add rsi,4
add rdi,2
dec ebx
jnz LClamp2
LEnd:
sfence
emms
LExit:
#ifdef _WIN32
pop rdi
pop rsi
#endif
pop rbx
ret