udivdi.s 751 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. |udivdi3 routine copyright (C) 2002, Kevin Kofler
  2. |WARNING: A division by 0 will not cause an exception, but just crash in an
  3. | infinite loop!
  4. .xdef __udivdi3
  5. .text
  6. __udivdi3:
  7. movem.l %d3-%d6,-(%a7)
  8. move.l 20(%a7),%d4
  9. move.l 24(%a7),%d5
  10. move.l 28(%a7),%d2
  11. move.l 32(%a7),%d3
  12. moveq.l #0,%d0
  13. moveq.l #0,%d1
  14. moveq.l #-1,%d6
  15. .L__udivdi3_shl:
  16. addq.w #1,%d6
  17. add.l %d3,%d3
  18. addx.l %d2,%d2
  19. bcc.s .L__udivdi3_shl
  20. roxr.l #1,%d2
  21. roxr.l #1,%d3
  22. .L__udivdi3_shr:
  23. add.l %d1,%d1
  24. addx.l %d0,%d0
  25. cmp.l %d2,%d4
  26. bne.s .L__udivdi3_cmp
  27. cmp.l %d3,%d5
  28. .L__udivdi3_cmp:
  29. bcs.s .L__udivdi3_skip
  30. sub.l %d3,%d5
  31. subx.l %d2,%d4
  32. addq.l #1,%d1
  33. .L__udivdi3_skip:
  34. lsr.l #1,%d2
  35. roxr.l #1,%d3
  36. dbra.w %d6,.L__udivdi3_shr
  37. movem.l (%a7)+,%d3-%d6
  38. rts