xref: /netbsd-src/sys/external/bsd/gnu-efi/dist/lib/arm/ldivmod.S (revision d1b935f8e85510a16a1b49122bd2ccf5ad7e104c)
1/*	$NetBSD: ldivmod.S,v 1.1.1.1 2018/08/16 18:17:47 jmcneill Exp $	*/
2
3//------------------------------------------------------------------------------
4//
5// Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>
6//
7// This program and the accompanying materials
8// are licensed and made available under the terms and conditions of the BSD License
9// which accompanies this distribution.  The full text of the license may be found at
10// http://opensource.org/licenses/bsd-license.php
11//
12// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
13// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
14//
15//------------------------------------------------------------------------------
16
17
18#include "edk2asm.h"
19
20  .text
21  .align 2
22  GCC_ASM_EXPORT(__aeabi_ldivmod)
23
24//
25// A pair of (unsigned) long longs is returned in {{r0, r1}, {r2, r3}},
26//  the quotient in {r0, r1}, and the remainder in {r2, r3}.
27//
28//__value_in_regs lldiv_t
29//EFIAPI
30//__aeabi_ldivmod (
31//  IN UINT64  Dividen
32//  IN UINT64  Divisor
33//  )//
34//
35
36ASM_PFX(__aeabi_ldivmod):
37    push     {r4,lr}
38    asrs     r4,r1,#1
39    eor      r4,r4,r3,LSR #1
40    bpl      L_Test1
41    rsbs     r0,r0,#0
42    rsc      r1,r1,#0
43L_Test1:
44    tst      r3,r3
45    bpl      L_Test2
46    rsbs     r2,r2,#0
47    rsc      r3,r3,#0
48L_Test2:
49    bl       ASM_PFX(__aeabi_uldivmod)
50    tst      r4,#0x40000000
51    beq      L_Test3
52    rsbs     r0,r0,#0
53    rsc      r1,r1,#0
54L_Test3:
55    tst      r4,#0x80000000
56    beq      L_Exit
57    rsbs     r2,r2,#0
58    rsc      r3,r3,#0
59L_Exit:
60    pop      {r4,pc}
61
62
63
64