ldivmod.S 1.6 KB

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