aboutsummaryrefslogtreecommitdiffstats
path: root/libgsmhr/asm.s
blob: d1d491ea7591d487810b2ce6dc2104a7bcda7fd9 (plain)
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
.globl sat_adds32b
.type   sat_adds32b,@function
sat_adds32b:
	mov    %edi, %eax
	shr    $0x1f, %edi
	add    $0x7fffffff, %edi
	add    %esi, %eax
	cmovo  %edi, %eax
	retq
.size	sat_adds32b, .-sat_adds32b

.globl sat_subs32b
.type   sat_subs32b,@function
sat_subs32b:
	mov    %edi, %eax
	shr    $0x1f, %edi
	add    $0x7fffffff, %edi
	sub    %esi, %eax
	cmovo  %edi, %eax
	retq
.size	sat_subs32b, .-sat_subs32b

.globl sat_divs32b
.type   sat_divs32b,@function
sat_divs32b:
	mov    %edi, %eax
	lea    0x1(%rsi), %edx
	add    $0x80000000, %edi
	or     %edx, %edi
	cdq
	neg    %edi
	sbb    $-1, %eax
	idiv   %esi
	retq
.size	sat_divs32b, .-sat_divs32b

.globl sat_muls32b
.type   sat_muls32b,@function
sat_muls32b:
	mov    %edi, %eax
	xor    %esi, %edi
	shr    $0x1f, %edi
	add    $0x7fffffff, %edi
	imul   %esi
	cmovc  %edi, %eax
	retq
.size	sat_muls32b, .-sat_muls32b