muldi3.S revision 276789
1178476Sjb// This file is dual licensed under the MIT and the University of Illinois Open
2178476Sjb// Source Licenses. See LICENSE.TXT for details.
3178476Sjb
4178476Sjb#include "../assembly.h"
5178476Sjb
6178476Sjb// di_int __muldi3(di_int a, di_int b);
7178476Sjb
8178476Sjb#ifdef __i386__
9178476Sjb
10178476Sjb.text
11178476Sjb.balign 4
12178476SjbDEFINE_COMPILERRT_FUNCTION(__muldi3)
13178476Sjb	pushl	%ebx
14178476Sjb	movl  16(%esp),		%eax	// b.lo
15178476Sjb	movl  12(%esp),		%ecx	// a.hi
16178476Sjb	imull	%eax,		%ecx	// b.lo * a.hi
17178476Sjb
18178476Sjb	movl   8(%esp),		%edx	// a.lo
19178476Sjb	movl  20(%esp),		%ebx	// b.hi
20178476Sjb	imull	%edx,		%ebx	// a.lo * b.hi
21178476Sjb
22178476Sjb	mull	%edx				// EDX:EAX = a.lo * b.lo
23178476Sjb	addl	%ecx,		%ebx	// EBX = (a.lo*b.hi + a.hi*b.lo)
24178476Sjb	addl	%ebx,		%edx
25178476Sjb
26178476Sjb	popl	%ebx
27178476Sjb	retl
28178476SjbEND_COMPILERRT_FUNCTION(__muldi3)
29178476Sjb
30178476Sjb#endif // __i386__
31178476Sjb