Advertisement
Guest User

Untitled

a guest
Jan 4th, 2018
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.39 KB | None | 0 0
  1. ; -----------------------------------------
  2. ; function usqrt
  3. ; -----------------------------------------
  4. _usqrt:
  5. sub sp, #25
  6. ; util.c: 43: uint32_t a = 0; /* accumulator */
  7. clrw x
  8. ldw (0x0b, sp), x
  9. ldw (0x09, sp), x
  10. ; util.c: 44: uint32_t r = 0; /* remainder */
  11. clrw x
  12. ldw (0x07, sp), x
  13. ldw (0x05, sp), x
  14. ; util.c: 49: for (i = 0; i < 16 + ADC_ARR_BITSIZE - ADC_SHIFT; i++) /* NOTE 1 */
  15. ld a, #0x16
  16. ld (0x15, sp), a
  17. 00106$:
  18. ; util.c: 51: r = (r << 2) + TOP2BITS(x);
  19. ldw y, (0x05, sp)
  20. ldw (0x11, sp), y
  21. ldw x, (0x07, sp)
  22. ld a, #0x02
  23. 00121$:
  24. sllw x
  25. rlc (0x12, sp)
  26. rlc (0x11, sp)
  27. dec a
  28. jrne 00121$
  29. ldw (0x13, sp), x
  30. ldw y, (0x1c, sp)
  31. ldw (0x16, sp), y
  32. ldw x, (0x1e, sp)
  33. ld a, #0x1e
  34. 00123$:
  35. srl (0x16, sp)
  36. rrc (0x17, sp)
  37. rrcw x
  38. dec a
  39. jrne 00123$
  40. ldw (0x18, sp), x
  41. ldw x, (0x13, sp)
  42. addw x, (0x18, sp)
  43. ldw (0x0f, sp), x
  44. ld a, (0x12, sp)
  45. adc a, (0x17, sp)
  46. ld (0x0e, sp), a
  47. ld a, (0x11, sp)
  48. adc a, (0x16, sp)
  49. ld (0x05, sp), a
  50. ldw y, (0x0f, sp)
  51. ldw (0x07, sp), y
  52. ld a, (0x0e, sp)
  53. ld (0x06, sp), a
  54. ; util.c: 52: x <<= 2; /* NOTE 2 */
  55. ldw y, (0x1e, sp)
  56. ldw x, (0x1c, sp)
  57. ld a, #0x02
  58. 00125$:
  59. sllw y
  60. rlcw x
  61. dec a
  62. jrne 00125$
  63. ldw (0x1e, sp), y
  64. ldw (0x1c, sp), x
  65. ; util.c: 53: a <<= 1;
  66. ldw y, (0x0b, sp)
  67. ldw x, (0x09, sp)
  68. sllw y
  69. rlcw x
  70. ldw (0x0b, sp), y
  71. ldw (0x09, sp), x
  72. ; util.c: 54: e = (a << 1) + 1;
  73. ldw y, (0x0b, sp)
  74. ldw x, (0x09, sp)
  75. sllw y
  76. rlcw x
  77. addw y, #0x0001
  78. ld a, xl
  79. adc a, #0x00
  80. rlwa x
  81. adc a, #0x00
  82. ld xh, a
  83. ldw (0x03, sp), y
  84. ldw (0x01, sp), x
  85. ; util.c: 55: if (r >= e)
  86. ldw x, (0x07, sp)
  87. cpw x, (0x03, sp)
  88. ld a, (0x06, sp)
  89. sbc a, (0x02, sp)
  90. ld a, (0x05, sp)
  91. sbc a, (0x01, sp)
  92. jrc 00102$
  93. ; util.c: 57: r -= e;
  94. ldw y, (0x07, sp)
  95. subw y, (0x03, sp)
  96. ld a, (0x06, sp)
  97. sbc a, (0x02, sp)
  98. ld xl, a
  99. ld a, (0x05, sp)
  100. sbc a, (0x01, sp)
  101. ld xh, a
  102. ldw (0x07, sp), y
  103. ldw (0x05, sp), x
  104. ; util.c: 58: a++;
  105. ldw y, (0x0b, sp)
  106. addw y, #0x0001
  107. ld a, (0x0a, sp)
  108. adc a, #0x00
  109. ld xl, a
  110. ld a, (0x09, sp)
  111. adc a, #0x00
  112. ld xh, a
  113. ldw (0x0b, sp), y
  114. ldw (0x09, sp), x
  115. 00102$:
  116. ld a, (0x15, sp)
  117. dec a
  118. ld (0x15, sp), a
  119. ; util.c: 49: for (i = 0; i < 16 + ADC_ARR_BITSIZE - ADC_SHIFT; i++) /* NOTE 1 */
  120. tnz a
  121. jreq 00128$
  122. jp 00106$
  123. 00128$:
  124. ; util.c: 61: return a;
  125. ldw x, (0x0b, sp)
  126. addw sp, #25
  127. ret
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement