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