xref: /freebsd/contrib/llvm-project/compiler-rt/lib/builtins/i386/muldi3.S (revision 59c8e88e72633afbc47a4ace0d2170d00d51f7dc)
1// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
2// See https://llvm.org/LICENSE.txt for license information.
3// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
4
5#include "../assembly.h"
6
7// di_int __muldi3(di_int a, di_int b);
8
9#ifdef __i386__
10
11.text
12.balign 4
13DEFINE_COMPILERRT_FUNCTION(__muldi3)
14	pushl	%ebx
15	movl  16(%esp),		%eax	// b.lo
16	movl  12(%esp),		%ecx	// a.hi
17	imull	%eax,		%ecx	// b.lo * a.hi
18
19	movl   8(%esp),		%edx	// a.lo
20	movl  20(%esp),		%ebx	// b.hi
21	imull	%edx,		%ebx	// a.lo * b.hi
22
23	mull	%edx				// EDX:EAX = a.lo * b.lo
24	addl	%ecx,		%ebx	// EBX = (a.lo*b.hi + a.hi*b.lo)
25	addl	%ebx,		%edx
26
27	popl	%ebx
28	retl
29END_COMPILERRT_FUNCTION(__muldi3)
30
31#endif // __i386__
32
33NO_EXEC_STACK_DIRECTIVE
34
35