xref: /aosp_15_r20/external/compiler-rt/lib/builtins/i386/muldi3.S (revision 7c3d14c8b49c529e04be81a3ce6f5cc23712e4c6)
1*7c3d14c8STreehugger Robot// This file is dual licensed under the MIT and the University of Illinois Open
2*7c3d14c8STreehugger Robot// Source Licenses. See LICENSE.TXT for details.
3*7c3d14c8STreehugger Robot
4*7c3d14c8STreehugger Robot#include "../assembly.h"
5*7c3d14c8STreehugger Robot
6*7c3d14c8STreehugger Robot// di_int __muldi3(di_int a, di_int b);
7*7c3d14c8STreehugger Robot
8*7c3d14c8STreehugger Robot#ifdef __i386__
9*7c3d14c8STreehugger Robot
10*7c3d14c8STreehugger Robot.text
11*7c3d14c8STreehugger Robot.balign 4
12*7c3d14c8STreehugger RobotDEFINE_COMPILERRT_FUNCTION(__muldi3)
13*7c3d14c8STreehugger Robot	pushl	%ebx
14*7c3d14c8STreehugger Robot	movl  16(%esp),		%eax	// b.lo
15*7c3d14c8STreehugger Robot	movl  12(%esp),		%ecx	// a.hi
16*7c3d14c8STreehugger Robot	imull	%eax,		%ecx	// b.lo * a.hi
17*7c3d14c8STreehugger Robot
18*7c3d14c8STreehugger Robot	movl   8(%esp),		%edx	// a.lo
19*7c3d14c8STreehugger Robot	movl  20(%esp),		%ebx	// b.hi
20*7c3d14c8STreehugger Robot	imull	%edx,		%ebx	// a.lo * b.hi
21*7c3d14c8STreehugger Robot
22*7c3d14c8STreehugger Robot	mull	%edx				// EDX:EAX = a.lo * b.lo
23*7c3d14c8STreehugger Robot	addl	%ecx,		%ebx	// EBX = (a.lo*b.hi + a.hi*b.lo)
24*7c3d14c8STreehugger Robot	addl	%ebx,		%edx
25*7c3d14c8STreehugger Robot
26*7c3d14c8STreehugger Robot	popl	%ebx
27*7c3d14c8STreehugger Robot	retl
28*7c3d14c8STreehugger RobotEND_COMPILERRT_FUNCTION(__muldi3)
29*7c3d14c8STreehugger Robot
30*7c3d14c8STreehugger Robot#endif // __i386__
31*7c3d14c8STreehugger Robot
32*7c3d14c8STreehugger RobotNO_EXEC_STACK_DIRECTIVE
33*7c3d14c8STreehugger Robot
34