xref: /linux/arch/sh/lib/div64.S (revision c532de5a67a70f8533d495f8f2aaa9a0491c3ad0)
1/* SPDX-License-Identifier: GPL-2.0 */
2/*
3 * unsigned long __xdiv64_32(unsigned long long n, unsigned long d);
4 */
5
6#include <linux/linkage.h>
7
8.text
9ENTRY(__xdiv64_32)
10#ifdef CONFIG_CPU_LITTLE_ENDIAN
11	mov	r4, r0
12	mov	r5, r1
13#else
14	mov	r4, r1
15	mov	r5, r0
16#endif
17	cmp/hs	r6, r1
18	bf.s	1f
19	 mov	#0, r2
20
21	mov	r1, r2
22	mov	#0, r3
23	div0u
24	.rept	32
25	rotcl	r2
26	div1	r6, r3
27	.endr
28	rotcl	r2
29	mul.l	r6, r2
30	sts	macl, r3
31	sub	r3, r1
321:
33	div0u
34	.rept	32
35	rotcl	r0
36	div1	r6, r1
37	.endr
38#ifdef CONFIG_CPU_LITTLE_ENDIAN
39	mov	r2, r1
40	rts
41	 rotcl	r0
42#else
43	rotcl	r0
44	mov	r0, r1
45	rts
46	 mov	r2, r0
47#endif
48