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