moddi.s 699 B

123456789101112131415161718192021222324252627282930
  1. |moddi3 routine copyright (C) 2002, Kevin Kofler
  2. |WARNING: Division by 0 will be handled the same way as in the unsigned variant.
  3. | For my __umoddi3, this means:
  4. | A division by 0 will not cause an exception, but just crash in an
  5. | infinite loop!
  6. .xdef __moddi3
  7. .text
  8. __moddi3:
  9. tst.b 12(%a7)
  10. bge.s .L__moddi3_denom_positive
  11. neg.l 16(%a7)
  12. negx.l 12(%a7)
  13. .L__moddi3_denom_positive:
  14. tst.b 4(%a7)
  15. blt.s .L__moddi3_numer_negative
  16. .L__moddi3_umoddi3:
  17. jbra __umoddi3
  18. .L__moddi3_numer_negative:
  19. neg.l 8(%a7)
  20. negx.l 4(%a7)
  21. lea.l (.L__moddi3_return_jump+2,%PC),%a0
  22. move.l (%a7)+,(%a0)
  23. bsr.s .L__moddi3_umoddi3
  24. neg.l %d1
  25. negx.l %d0
  26. .L__moddi3_return_jump:
  27. jmp.l 0:l