blob: 1d783ec87ca70261663e241a303b90e77ba873c5 [file] [log] [blame]
Gabe Black169c0df2013-10-08 18:24:10 -07001/*
2 * linux/arch/arm/lib/muldi3.S
3 *
4 * Author: Nicolas Pitre
5 * Created: Oct 19, 2005
6 * Copyright: Monta Vista Software, Inc.
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
Martin Roth4af58862016-01-21 13:15:16 -070011 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
Gabe Black169c0df2013-10-08 18:24:10 -070016 */
17
18#if defined __GNUC__
19
20#include <arch/asm.h>
21
22#ifdef __ARMEB__
23#define xh r0
24#define xl r1
25#define yh r2
26#define yl r3
27#else
28#define xl r0
29#define xh r1
30#define yl r2
31#define yh r3
32#endif
33
34ENTRY(__muldi3)
Julius Werner7c6e4892014-01-24 16:23:08 -080035.global __aeabi_lmul
36__aeabi_lmul:
Gabe Black169c0df2013-10-08 18:24:10 -070037
38 mul xh, yl, xh
39 mla xh, xl, yh, xh
40 mov ip, xl, lsr #16
41 mov yh, yl, lsr #16
42 bic xl, xl, ip, lsl #16
43 bic yl, yl, yh, lsl #16
44 mla xh, yh, ip, xh
45 mul yh, xl, yh
46 mul xl, yl, xl
47 mul ip, yl, ip
48 adds xl, xl, yh, lsl #16
49 adc xh, xh, yh, lsr #16
50 adds xl, xl, ip, lsl #16
51 adc xh, xh, ip, lsr #16
52 mov pc, lr
53
Julius Werner7c6e4892014-01-24 16:23:08 -080054.type __aeabi_lmul, %function
55.size __aeabi_lmul, .-__aeabi_lmul
Gabe Black169c0df2013-10-08 18:24:10 -070056ENDPROC(__muldi3)
Gabe Black169c0df2013-10-08 18:24:10 -070057
58#endif