xref: /openbsd-src/sys/lib/libkern/arch/arm/__aeabi_uldivmod.S (revision a33d4b18e9c06c133991074ecd6f5c09abc13a4a)
1*a33d4b18Skettenis/*-
2*a33d4b18Skettenis * Copyright (c) 2012 The NetBSD Foundation, Inc.
3*a33d4b18Skettenis * All rights reserved.
4*a33d4b18Skettenis *
5*a33d4b18Skettenis * This code is derived from software contributed to The NetBSD Foundation
6*a33d4b18Skettenis * by Matt Thomas of 3am Software Foundry.
7*a33d4b18Skettenis *
8*a33d4b18Skettenis * Redistribution and use in source and binary forms, with or without
9*a33d4b18Skettenis * modification, are permitted provided that the following conditions
10*a33d4b18Skettenis * are met:
11*a33d4b18Skettenis * 1. Redistributions of source code must retain the above copyright
12*a33d4b18Skettenis *    notice, this list of conditions and the following disclaimer.
13*a33d4b18Skettenis * 2. Redistributions in binary form must reproduce the above copyright
14*a33d4b18Skettenis *    notice, this list of conditions and the following disclaimer in the
15*a33d4b18Skettenis *    documentation and/or other materials provided with the distribution.
16*a33d4b18Skettenis *
17*a33d4b18Skettenis * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
18*a33d4b18Skettenis * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
19*a33d4b18Skettenis * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
20*a33d4b18Skettenis * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
21*a33d4b18Skettenis * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22*a33d4b18Skettenis * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23*a33d4b18Skettenis * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24*a33d4b18Skettenis * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25*a33d4b18Skettenis * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26*a33d4b18Skettenis * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27*a33d4b18Skettenis * POSSIBILITY OF SUCH DAMAGE.
28*a33d4b18Skettenis */
29*a33d4b18Skettenis
30*a33d4b18Skettenis#include <machine/asm.h>
31*a33d4b18Skettenis
32*a33d4b18Skettenis/*
33*a33d4b18Skettenis * typedef struct { unsigned long long quo, rem } ulldiv_t;
34*a33d4b18Skettenis * __value_in_regs ulldiv_t __aeabi_uldivmod(unsigned long long n,
35*a33d4b18Skettenis *	unsigned long long d);
36*a33d4b18Skettenis */
37*a33d4b18Skettenis
38*a33d4b18SkettenisENTRY(__aeabi_uldivmod)
39*a33d4b18Skettenis	push	{r4,lr}
40*a33d4b18Skettenis	sub	sp, sp, #16
41*a33d4b18Skettenis	add	r4, sp, #8
42*a33d4b18Skettenis	str	r4, [sp]
43*a33d4b18Skettenis	bl	__qdivrem
44*a33d4b18Skettenis	add	sp, sp, #8
45*a33d4b18Skettenis	/*
46*a33d4b18Skettenis	 * The remainder is already on the stack just waiting to be popped
47*a33d4b18Skettenis	 * into r2/r3.
48*a33d4b18Skettenis	 */
49*a33d4b18Skettenis	pop	{r2-r4,pc}
50*a33d4b18SkettenisEND(__aeabi_uldivmod)
51