div64.S 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. ! Copyright (C) 2012 Imagination Technologies Ltd.
  2. !
  3. ! Signed/unsigned 64-bit division routines.
  4. !
  5. .text
  6. .global _div_u64
  7. .type _div_u64,function
  8. _div_u64:
  9. $L1:
  10. ORS A0.3,D1Ar3,D0Ar4
  11. BNE $L3
  12. $L2:
  13. MOV D0Re0,D0Ar2
  14. MOV D1Re0,D1Ar1
  15. MOV PC,D1RtP
  16. $L3:
  17. CMP D1Ar3,D1Ar1
  18. CMPEQ D0Ar4,D0Ar2
  19. MOV D0Re0,#1
  20. MOV D1Re0,#0
  21. BHS $L6
  22. $L4:
  23. ADDS D0Ar6,D0Ar4,D0Ar4
  24. ADD D1Ar5,D1Ar3,D1Ar3
  25. ADDCS D1Ar5,D1Ar5,#1
  26. CMP D1Ar5,D1Ar3
  27. CMPEQ D0Ar6,D0Ar4
  28. BLO $L6
  29. $L5:
  30. MOV D0Ar4,D0Ar6
  31. MOV D1Ar3,D1Ar5
  32. ADDS D0Re0,D0Re0,D0Re0
  33. ADD D1Re0,D1Re0,D1Re0
  34. ADDCS D1Re0,D1Re0,#1
  35. CMP D1Ar3,D1Ar1
  36. CMPEQ D0Ar4,D0Ar2
  37. BLO $L4
  38. $L6:
  39. ORS A0.3,D1Re0,D0Re0
  40. MOV D0Ar6,#0
  41. MOV D1Ar5,D0Ar6
  42. BEQ $L10
  43. $L7:
  44. CMP D1Ar1,D1Ar3
  45. CMPEQ D0Ar2,D0Ar4
  46. BLO $L9
  47. $L8:
  48. ADDS D0Ar6,D0Ar6,D0Re0
  49. ADD D1Ar5,D1Ar5,D1Re0
  50. ADDCS D1Ar5,D1Ar5,#1
  51. SUBS D0Ar2,D0Ar2,D0Ar4
  52. SUB D1Ar1,D1Ar1,D1Ar3
  53. SUBCS D1Ar1,D1Ar1,#1
  54. $L9:
  55. LSL A0.3,D1Re0,#31
  56. LSR D0Re0,D0Re0,#1
  57. LSR D1Re0,D1Re0,#1
  58. OR D0Re0,D0Re0,A0.3
  59. LSL A0.3,D1Ar3,#31
  60. LSR D0Ar4,D0Ar4,#1
  61. LSR D1Ar3,D1Ar3,#1
  62. OR D0Ar4,D0Ar4,A0.3
  63. ORS A0.3,D1Re0,D0Re0
  64. BNE $L7
  65. $L10:
  66. MOV D0Re0,D0Ar6
  67. MOV D1Re0,D1Ar5
  68. MOV PC,D1RtP
  69. .size _div_u64,.-_div_u64
  70. .text
  71. .global _div_s64
  72. .type _div_s64,function
  73. _div_s64:
  74. MSETL [A0StP],D0FrT,D0.5
  75. XOR D0.5,D0Ar2,D0Ar4
  76. XOR D1.5,D1Ar1,D1Ar3
  77. TSTT D1Ar1,#HI(0x80000000)
  78. BZ $L25
  79. NEGS D0Ar2,D0Ar2
  80. NEG D1Ar1,D1Ar1
  81. SUBCS D1Ar1,D1Ar1,#1
  82. $L25:
  83. TSTT D1Ar3,#HI(0x80000000)
  84. BZ $L27
  85. NEGS D0Ar4,D0Ar4
  86. NEG D1Ar3,D1Ar3
  87. SUBCS D1Ar3,D1Ar3,#1
  88. $L27:
  89. CALLR D1RtP,_div_u64
  90. TSTT D1.5,#HI(0x80000000)
  91. BZ $L29
  92. NEGS D0Re0,D0Re0
  93. NEG D1Re0,D1Re0
  94. SUBCS D1Re0,D1Re0,#1
  95. $L29:
  96. GETL D0FrT,D1RtP,[A0StP+#(-16)]
  97. GETL D0.5,D1.5,[A0StP+#(-8)]
  98. SUB A0StP,A0StP,#16
  99. MOV PC,D1RtP
  100. .size _div_s64,.-_div_s64