xref: /kvm-unit-tests/lib/arm/ldivmod.S (revision 9e7a5929569d61414feefcb1d8024e7685cb7eb3)
1// EABI ldivmod and uldivmod implementation based on libcompiler-rt
2//
3// This file is dual licensed under the MIT and the University of Illinois Open
4// Source Licenses.
5
6	.syntax unified
7	.align 2
8	.globl __aeabi_uldivmod
9	.type __aeabi_uldivmod, %function
10__aeabi_uldivmod:
11	push	{r11, lr}
12	sub	sp, sp, #16
13	add	r12, sp, #8
14	str	r12, [sp]                // third argument to __udivmoddi4
15	bl	__udivmoddi4
16	ldr	r2, [sp, #8]             // remainder returned in r2-r3
17	ldr	r3, [sp, #12]
18	add	sp, sp, #16
19	pop	{r11, pc}
20
21	.globl __aeabi_ldivmod
22	.type __aeabi_ldivmod, %function
23__aeabi_ldivmod:
24	push	{r11, lr}
25	sub	sp, sp, #16
26	add	r12, sp, #8
27	str	r12, [sp]                // third argument to __divmoddi4
28	bl	__divmoddi4
29	ldr	r2, [sp, #8]             // remainder returned in r2-r3
30	ldr	r3, [sp, #12]
31	add	sp, sp, #16
32	pop	{r11, pc}
33