]> git.proxmox.com Git - mirror_edk2.git/blob - ArmPkg/Library/CompilerIntrinsicsLib/Arm/ldivmod.S
UefiCpuPkg: Move AsmRelocateApLoopStart from Mpfuncs.nasm to AmdSev.nasm
[mirror_edk2.git] / ArmPkg / Library / CompilerIntrinsicsLib / Arm / ldivmod.S
1 //------------------------------------------------------------------------------
2 //
3 // Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>
4 //
5 // SPDX-License-Identifier: BSD-2-Clause-Patent
6 //
7 //------------------------------------------------------------------------------
8
9 #include <AsmMacroIoLib.h>
10
11 //
12 // A pair of (unsigned) long longs is returned in {{r0, r1}, {r2, r3}},
13 // the quotient in {r0, r1}, and the remainder in {r2, r3}.
14 //
15 //__value_in_regs lldiv_t
16 //EFIAPI
17 //__aeabi_ldivmod (
18 // IN UINT64 Dividen
19 // IN UINT64 Divisor
20 // )//
21 //
22
23 ASM_FUNC(__aeabi_ldivmod)
24 push {r4,lr}
25 asrs r4,r1,#1
26 eor r4,r4,r3,LSR #1
27 bpl L_Test1
28 rsbs r0,r0,#0
29 rsc r1,r1,#0
30 L_Test1:
31 tst r3,r3
32 bpl L_Test2
33 rsbs r2,r2,#0
34 rsc r3,r3,#0
35 L_Test2:
36 bl ASM_PFX(__aeabi_uldivmod)
37 tst r4,#0x40000000
38 beq L_Test3
39 rsbs r0,r0,#0
40 rsc r1,r1,#0
41 L_Test3:
42 tst r4,#0x80000000
43 beq L_Exit
44 rsbs r2,r2,#0
45 rsc r3,r3,#0
46 L_Exit:
47 pop {r4,pc}
48
49
50