umoddi.s 689 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. |umoddi3 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 __umoddi3
  5. .text
  6. __umoddi3:
  7. movea.l %d3,%a0
  8. move.l 4(%a7),%d0
  9. move.l 8(%a7),%d1
  10. move.l 12(%a7),%d2
  11. move.l 16(%a7),%d3
  12. movea.l %d4,%a1
  13. moveq.l #-1,%d4
  14. .L__umoddi3_shl:
  15. addq.w #1,%d4
  16. add.l %d3,%d3
  17. addx.l %d2,%d2
  18. bcc.s .L__umoddi3_shl
  19. roxr.l #1,%d2
  20. roxr.l #1,%d3
  21. .L__umoddi3_shr:
  22. cmp.l %d2,%d0
  23. bne.s .L__umoddi3_cmp
  24. cmp.l %d3,%d1
  25. .L__umoddi3_cmp:
  26. bcs.s .L__umoddi3_skip
  27. sub.l %d3,%d1
  28. subx.l %d2,%d0
  29. .L__umoddi3_skip:
  30. lsr.l #1,%d2
  31. roxr.l #1,%d3
  32. dbra.w %d4,.L__umoddi3_shr
  33. move.l %a1,%d4
  34. move.l %a0,%d3
  35. rts