summaryrefslogtreecommitdiff
path: root/com32/lib/libgcc/__muldi3.S
blob: 424787c81e61ac83adbc8c7a247e6bc9ae67d9c7 (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
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
/*
 * arch/i386/libgcc/__muldi3.S
 *
 * 64*64 = 64 bit unsigned multiplication
 */

	.text
	.align 4
	.globl __muldi3
	.type __muldi3,@function
__muldi3:
#if __SIZEOF_POINTER__ == 4
	/* i386 */
	push  %esi
#ifndef REGPARM
	movl  8(%esp),%eax
	movl  %eax,%esi
	movl  16(%esp),%ecx
	mull  %ecx
	imull 12(%esp),%ecx
	imull 20(%esp),%esi
	addl  %ecx,%edx
	addl  %esi,%edx
#else
	movl  %eax,%esi
	push  %edx
	mull  %ecx
	imull 8(%esp),%esi
	addl  %esi,%edx
	pop   %esi
	imull %esi,%ecx
	addl  %ecx,%edx
#endif
	pop   %esi
	ret
#elif __SIZEOF_POINTER__ == 8
	/* x86_64 */
	push  %rsi
#ifndef REGPARM
/*
	movl  8(%esp),%eax
	movl %eax,%esi
	movl  16(%esp),%ecx
	mull  %ecx
	imull 12(%esp),%ecx
	imull 20(%esp),%esi
	addl  %ecx,%edx
	addl  %esi,%edx
*/
	movq  8(%rsp),%rax
	movq %rax,%rsi
	movq  16(%rsp),%rcx
	mulq  %rcx
	imulq 12(%rsp),%rcx
	imulq 20(%rsp),%rsi
	addq  %rcx,%rdx
	addq  %rsi,%rdx
#else
/*
	movl  %eax,%esi
	push  %edx
	mull  %ecx
	imull 8(%esp),%esi
	addl  %esi,%edx
	pop   %rsi
	imull %esi,%ecx
	addl  %ecx,%edx
*/
	movq  %rax,%rsi
	pushq  %rdx
	mulq  %rcx
	imulq 8(%rsp),%rsi
	addq  %rsi,%rdx
	popq  %rsi
	imulq %rsi,%rcx
	addq  %rcx,%rdx
#endif
	pop   %rsi
	ret
#else
#error "Unsupported architecture for __muldi3.S"
#endif
	.size __muldi3,.-__muldi3