udivdi.s 756 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. .data
  5. xdef __udivdi3
  6. .even
  7. __udivdi3:
  8. movem.l %d3-%d6,-(%a7)
  9. move.l 20(%a7),%d4
  10. move.l 24(%a7),%d5
  11. move.l 28(%a7),%d2
  12. move.l 32(%a7),%d3
  13. moveq.l #0,%d0
  14. moveq.l #0,%d1
  15. moveq.l #-1,%d6
  16. .L__udivdi3_shl:
  17. addq.w #1,%d6
  18. add.l %d3,%d3
  19. addx.l %d2,%d2
  20. bcc.s .L__udivdi3_shl
  21. roxr.l #1,%d2
  22. roxr.l #1,%d3
  23. .L__udivdi3_shr:
  24. add.l %d1,%d1
  25. addx.l %d0,%d0
  26. cmp.l %d2,%d4
  27. bne.s .L__udivdi3_cmp
  28. cmp.l %d3,%d5
  29. .L__udivdi3_cmp:
  30. bcs.s .L__udivdi3_skip
  31. sub.l %d3,%d5
  32. subx.l %d2,%d4
  33. addq.l #1,%d1
  34. .L__udivdi3_skip:
  35. lsr.l #1,%d2
  36. roxr.l #1,%d3
  37. dbra.w %d6,.L__udivdi3_shr
  38. movem.l (%a7)+,%d3-%d6
  39. rts